From patchwork Wed Jul 5 10:21:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 116058 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp1764032vqx; Wed, 5 Jul 2023 03:23:40 -0700 (PDT) X-Google-Smtp-Source: APBJJlF+oWTpdH41BKKI/FH2GBdqX7g9pjiSn+ZBmzuhRBlcqzTPYewQByp3yiUPDif117zhdKq7 X-Received: by 2002:a17:906:3c11:b0:991:ec83:c0aa with SMTP id h17-20020a1709063c1100b00991ec83c0aamr12170318ejg.70.1688552619989; Wed, 05 Jul 2023 03:23:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688552619; cv=none; d=google.com; s=arc-20160816; b=CeDF8DlQcg/AGniHfmJIgYxGYo2c10TRX2JpaOWGdw56muF020G12vWLrWpn27v+Uz gPMvaOjMbGUGnyVM3AB1djHLWdTzTshByw+LVW2u5qEbMaWmab2wuH7eiG4AltPYZa+R 2h7CiCsulr85xCWy+Dn4BF2fOlRzX2im8X2GYn1lXb9ld5+1sdgULpUHESpuCfFKm7Iv dRq44sM3kGAhgMmemRkpiwerX+bB7sD0KMjn/ORuf22S+3qTvfHhxk75hkzC8dYzvtqp hmFUgyKzu4c7Nx8h3cVyP93ypXWlIUDQv9FGg3p4mGHiWsOYkel908EVLRw37cwtByUK OdRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version:message-id:date :user-agent:references:in-reply-to:subject:cc:to:from:ironport-sdr :dmarc-filter:delivered-to; bh=qk7edipRfeRtJmhKOsC/c/locDCtDe87bpZF7FyAXOw=; fh=vWV3aFKV8wKse3sbBH1VvduZb5QtceMLg4g6GZUhacg=; b=w7lx86hvzBQr2TrcPC4+C7eGTS9fMbHKxF0ILiWcCDeihjv/B6AHJSLvCvWDHf+ERA BIZLFTGEdKbmD+rkLHePBcwKgattMyyRir3Wp8kSJgMjAPhj1nP76t0DGoqEgP1yK9nd AowOgpumRerbSbIjYY0UpfWF6j8Qes3IsZrcjXMYXDuwg26z7YsvjCAfNqPbqwdXjIMo gs2ptN94IEo8D82TrcbkQ9lIpEGOOGqbbRsanHGMmJ3voUcWZ1lqyCpfRJ63mZMmaRoP QJz6bnStG9Nh6aQUOVdNFOzuJaj8O76j2fi6txxcJK4zDYBX4xJ6NlZVEakqZe603/PC 6Pkw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id v3-20020a17090690c300b00992e2881836si6429402ejw.819.2023.07.05.03.23.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jul 2023 03:23:39 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 730A5385C6E4 for ; Wed, 5 Jul 2023 10:23:08 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id F1EC13857007 for ; Wed, 5 Jul 2023 10:21:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F1EC13857007 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="6.01,182,1684828800"; d="scan'208,223";a="12283792" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa2.mentor.iphmx.com with ESMTP; 05 Jul 2023 02:21:56 -0800 IronPort-SDR: qQ9ha9vk7+wtwKGw7wK4ik145qH4UI20ZtUnjSsrKzpCba9BtufLwLFVe1jvOOj9WnJzaKE+M5 ImOyqBIaiYlbF6fWOUVBLWW0DX5bXj/LQtjI9sUlq05EwRewJtmW6St1L11LMwrAbAALVWzkc9 Nsunz5gnyi65fDJp2vEIosGJELA6iaroBbIrsODSIYpug+XEab/bxbw7YDpt0ahbomlgEDfm0D GV26Q7B5NY+4o+uH37tIE5kThy+CpA1dGvrYl8/xWOYvhZf2GpfHUHZKMl2FBTdy0AhKeQkzPt aP8= From: Thomas Schwinge To: CC: Richard Biener Subject: GTY: Repair 'enum gty_token', 'token_names' desynchronization (was: [cxx-conversion] Support garbage-collected C++ templates) In-Reply-To: <50252386.8000505@google.com> References: <20120808195258.GA30576@google.com> <5022CDF8.9000300@google.com> <5022D9BD.4060708@google.com> <50252386.8000505@google.com> User-Agent: Notmuch/0.29.3+94~g74c3f1b (https://notmuchmail.org) Emacs/28.2 (x86_64-pc-linux-gnu) Date: Wed, 5 Jul 2023 12:21:49 +0200 Message-ID: <87jzveu08y.fsf@euler.schwinge.homeip.net> MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) To svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_LOTSOFHASH, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770575751910147088?= X-GMAIL-MSGID: =?utf-8?q?1770575751910147088?= Hi! On 2012-08-10T11:06:46-0400, Diego Novillo wrote: > * gengtype-lex.l (USER_GTY): Add pattern for "user". > * gengtype-parse.c (option): Handle USER_GTY. > (opts_have): New. > (type): Call it. > If the keyword 'user' is used, do not walk the fields > of the structure. > * gengtype.h (USER_GTY): Add. These changes got incorporated in commit 0823efedd0fb8669b7e840954bc54c3b2cf08d67 (Subversion r190402). > --- a/gcc/gengtype-lex.l > +++ b/gcc/gengtype-lex.l > @@ -108,6 +108,7 @@ EOID [^[:alnum:]_] > "enum"/{EOID} { return ENUM; } > "ptr_alias"/{EOID} { return PTR_ALIAS; } > "nested_ptr"/{EOID} { return NESTED_PTR; } > +"user"/{EOID} { return USER_GTY; } > [0-9]+ { return NUM; } > "param"[0-9]*"_is"/{EOID} { > *yylval = XDUPVAR (const char, yytext, yyleng, yyleng+1); > --- a/gcc/gengtype-parse.c > +++ b/gcc/gengtype-parse.c > @@ -499,6 +499,10 @@ option (options_p prev) > [...] > --- a/gcc/gengtype.h > +++ b/gcc/gengtype.h > @@ -463,6 +463,7 @@ enum > ELLIPSIS, > PTR_ALIAS, > NESTED_PTR, > + USER_GTY, > PARAM_IS, > NUM, > SCALAR, This did add 'USER_GTY' to what nowadays is known as 'enum gty_token', but didn't accordingly update 'gcc/gengtype-parse.c:token_names', leaving those out of sync. Updating 'gcc/gengtype-parse.c:token_value_format' wasn't necessary, as: /* print_token assumes that any token >= FIRST_TOKEN_WITH_VALUE may have a meaningful value to be printed. */ FIRST_TOKEN_WITH_VALUE = PARAM_IS This, in turn, got further confused -- or "fixed" -- by later changes: 2014 commit 63f5d5b818319129217e41bcb23db53f99ff11b0 (Subversion r218558) "remove gengtype support for param_is use_param, if_marked and splay tree allocators", which reciprocally missed corresponding clean-up. OK to push the attached "GTY: Repair 'enum gty_token', 'token_names' desynchronization"? On top of that, I'll then re-submit an adjusted "GTY: Clean up obsolete parametrized structs remnants". Grüße Thomas ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955 From 8d2b040e825acdcddb7e1ff991fd538db13392f2 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Wed, 5 Jul 2023 11:10:55 +0200 Subject: [PATCH] GTY: Repair 'enum gty_token', 'token_names' desynchronization For example, for the following (made-up) changes: --- gcc/ggc-tests.cc +++ gcc/ggc-tests.cc @@ -258 +258 @@ class GTY((tag("1"))) some_subclass : public example_base -class GTY((tag("2"))) some_other_subclass : public example_base +class GTY((tag(user))) some_other_subclass : public example_base @@ -384 +384 @@ test_chain_next () -struct GTY((user)) user_struct +struct GTY((user user)) user_struct ..., we get unexpected "have a param_is option" diagnostics: [...] build/gengtype \ -S [...]/source-gcc/gcc -I gtyp-input.list -w tmp-gtype.state [...]/source-gcc/gcc/ggc-tests.cc:258: parse error: expected a string constant, have a param_is option [...]/source-gcc/gcc/ggc-tests.cc:384: parse error: expected ')', have a param_is option make[2]: *** [Makefile:2888: s-gtype] Error 1 [...] This traces back to 2012 "Support garbage-collected C++ templates", which got incorporated in commit 0823efedd0fb8669b7e840954bc54c3b2cf08d67 (Subversion r190402), which did add 'USER_GTY' to what nowadays is known as 'enum gty_token', but didn't accordingly update 'gcc/gengtype-parse.c:token_names', leaving those out of sync. Updating 'gcc/gengtype-parse.c:token_value_format' wasn't necessary, as: /* print_token assumes that any token >= FIRST_TOKEN_WITH_VALUE may have a meaningful value to be printed. */ FIRST_TOKEN_WITH_VALUE = PARAM_IS This, in turn, got further confused -- or "fixed" -- by later changes: 2014 commit 63f5d5b818319129217e41bcb23db53f99ff11b0 (Subversion r218558) "remove gengtype support for param_is use_param, if_marked and splay tree allocators", which reciprocally missed corresponding clean-up. With that addressed via adding the missing '"user"' to 'token_names', and, until that is properly fixed, a temporary 'UNUSED_PARAM_IS' (re-)added for use with 'FIRST_TOKEN_WITH_VALUE', we then get the expected: [...]/source-gcc/gcc/ggc-tests.cc:258: parse error: expected a string constant, have 'user' [...]/source-gcc/gcc/ggc-tests.cc:384: parse error: expected ')', have 'user' gcc/ * gengtype-parse.cc (token_names): Add '"user"'. * gengtype.h (gty_token): Add 'UNUSED_PARAM_IS' for use with 'FIRST_TOKEN_WITH_VALUE'. --- gcc/gengtype-parse.cc | 3 +++ gcc/gengtype.h | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/gcc/gengtype-parse.cc b/gcc/gengtype-parse.cc index 2b2156c5f45..8791b35a3da 100644 --- a/gcc/gengtype-parse.cc +++ b/gcc/gengtype-parse.cc @@ -69,6 +69,7 @@ advance (void) /* Diagnostics. */ /* This array is indexed by the token code minus CHAR_TOKEN_OFFSET. */ +/* Keep in sync with 'gengtype.h:enum gty_token'. */ static const char *const token_names[] = { "GTY", "typedef", @@ -80,6 +81,7 @@ static const char *const token_names[] = { "...", "ptr_alias", "nested_ptr", + "user", "a param_is option", "a number", "a scalar type", @@ -91,6 +93,7 @@ static const char *const token_names[] = { }; /* This array is indexed by token code minus FIRST_TOKEN_WITH_VALUE. */ +/* Keep in sync with 'gengtype.h:enum gty_token'. */ static const char *const token_value_format[] = { "%s", "'%s'", diff --git a/gcc/gengtype.h b/gcc/gengtype.h index 4e5df544fbf..2122373edf2 100644 --- a/gcc/gengtype.h +++ b/gcc/gengtype.h @@ -458,6 +458,8 @@ extern void parse_file (const char *name); extern bool hit_error; /* Token codes. */ +/* Keep 'gengtype-parse.cc:token_names', 'gengtype-parse.cc:token_value_format' + in sync. */ enum gty_token { EOF_TOKEN = 0, @@ -476,6 +478,7 @@ enum gty_token PTR_ALIAS, NESTED_PTR, USER_GTY, + UNUSED_PARAM_IS, NUM, SCALAR, ID, @@ -486,7 +489,7 @@ enum gty_token /* print_token assumes that any token >= FIRST_TOKEN_WITH_VALUE may have a meaningful value to be printed. */ - FIRST_TOKEN_WITH_VALUE = USER_GTY + FIRST_TOKEN_WITH_VALUE = UNUSED_PARAM_IS }; -- 2.34.1