From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 513783858D1E for ; Mon, 13 Mar 2023 20:47:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 513783858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678740478; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MybC2K3LcCYhp71/GPioAcMSTKjlBATurIxMf8oARtU=; b=CCa3S00tYulD3/sjUCv1l8QwUY6eDMn5iJ4cpLNQE3BepZ+glDGrgjmQQNTjhk/6vn/Wyj U9tI+OL7BefWvTt+F7ON0A1x5yW3a8dbj/7qMEbY0ikOGRbDlRLMHFjyAc1oAx8xM9rdap 1BS0D5X//NaMP3pDgc2CPbiEEcx5Lq8= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-43-hBKoOPEVOWSB7bS48-pyaw-1; Mon, 13 Mar 2023 16:47:57 -0400 X-MC-Unique: hBKoOPEVOWSB7bS48-pyaw-1 Received: by mail-qv1-f69.google.com with SMTP id o101-20020a0c906e000000b005ab9fa335c8so273716qvo.19 for ; Mon, 13 Mar 2023 13:47:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678740476; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=MybC2K3LcCYhp71/GPioAcMSTKjlBATurIxMf8oARtU=; b=YKOWNoRBFqiAhq58gKTVsf+HIGTyDX1cvaJdTQu5mWXdrxh6I9tPOz50FUTvgwaAj8 s/QutelUU/KF8vTx3f9wo3Na0CYBhobGXQXbfFmTy4+FoiPV8FmRcUiPFghYE5Sg95d2 i1xfChIooG9H/JQTX3catqWeD9DCB+maE4Yoe4epyqXgL2hCV4wKRFvg5XdzSCIfEVYb cFfrXargjDwikG4bIyKHctwUClJtwhde7wMj1cAryDjLNmw+Eep6RAeui1eO2jiXfRO7 lHmTUKwMmUxGg49C7bmDPtMVGvjcFwOuCG2meoNRJQtF3atusqFquvsmOwT35CTnx7B8 4kVA== X-Gm-Message-State: AO0yUKXWQnj/OTsVUUwx9M573+o+Y35YQHl5m6/qQpjAy+YI3GB083ln YmyPFdvG4k9lGI+vj6HxQxoIunN50CeimxYA4p9EQrcfBZvQCRi033HBUb3h4HY2No/eKS9XCS6 gS7OIn2olnpQTItNuoIWUN49mpQHc1IMCaRVU0zC6hTc6Y2gOarKGdlzwamgtHatliF3ILkFszg == X-Received: by 2002:ad4:5c48:0:b0:5a3:9032:13ea with SMTP id a8-20020ad45c48000000b005a3903213eamr958836qva.3.1678740476257; Mon, 13 Mar 2023 13:47:56 -0700 (PDT) X-Google-Smtp-Source: AK7set9XSyAQa67bH1vAKokuB6RKurMExa0HxqPQzc35i/tG+fYEHZyLFpSScoIC6QKypEqNu3UiyA== X-Received: by 2002:ad4:5c48:0:b0:5a3:9032:13ea with SMTP id a8-20020ad45c48000000b005a3903213eamr958819qva.3.1678740475857; Mon, 13 Mar 2023 13:47:55 -0700 (PDT) Received: from [192.168.1.108] (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id y206-20020a3764d7000000b00741a984943fsm406087qkb.40.2023.03.13.13.47.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 13 Mar 2023 13:47:55 -0700 (PDT) Message-ID: <2e414d4a-7408-b29c-f67c-0d47b08ba2f9@redhat.com> Date: Mon, 13 Mar 2023 16:47:52 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH RFA] tree: define tree_code_type in C++11/14 [PR108634] From: Jason Merrill To: gcc-patches@gcc.gnu.org Cc: Jakub Jelinek References: <20230313201512.151814-1-jason@redhat.com> In-Reply-To: <20230313201512.151814-1-jason@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 3/13/23 16:15, Jason Merrill wrote: > Tested x86_64-pc-linux-gnu, OK for trunk? > > -- 8< -- > > The r13-6577 change to use tree_code_type_tmpl in earlier C++ dialects broke > gdbhooks, which expects tree_code_type to always be available. I considered > trying to make gdbhooks more robust, but it seemed simpler to define > tree_code_type as a reference to the template. This still ends up with a > definition of the reference in each translation unit, but that's allowed by the > ODR because it always refers to the same entity, and is much smaller than > having the whole table in each TU. ...or I could build with a newer bootstrap compiler, I suppose. > PR plugins/108634 > > gcc/ChangeLog: > > * tree-core.h (tree_code_type, tree_code_length): > Define even without inline variable support. > * tree.h (TREE_CODE_CLASS, TREE_CODE_LENGTH): > Only one definition. > --- > gcc/tree-core.h | 3 +++ > gcc/tree.h | 10 ---------- > 2 files changed, 3 insertions(+), 10 deletions(-) > > diff --git a/gcc/tree-core.h b/gcc/tree-core.h > index fd2be57b78c..545dfd30114 100644 > --- a/gcc/tree-core.h > +++ b/gcc/tree-core.h > @@ -2298,6 +2298,7 @@ struct tree_code_type_tmpl { > > template > constexpr enum tree_code_class tree_code_type_tmpl::tree_code_type[]; > +static constexpr auto &tree_code_type = tree_code_type_tmpl<0>::tree_code_type; > #else > constexpr inline enum tree_code_class tree_code_type[] = { > #include "all-tree.def" > @@ -2326,6 +2327,8 @@ struct tree_code_length_tmpl { > > template > constexpr unsigned char tree_code_length_tmpl::tree_code_length[]; > +static constexpr auto &tree_code_length > += tree_code_length_tmpl<0>::tree_code_length; > #else > constexpr inline unsigned char tree_code_length[] = { > #include "all-tree.def" > diff --git a/gcc/tree.h b/gcc/tree.h > index 91375f9652f..92ac0e6a214 100644 > --- a/gcc/tree.h > +++ b/gcc/tree.h > @@ -177,12 +177,7 @@ code_helper::is_builtin_fn () const > #define TREE_CODE_CLASS_STRING(CLASS)\ > tree_code_class_strings[(int) (CLASS)] > > -#if __cpp_inline_variables < 201606L > -#define TREE_CODE_CLASS(CODE) \ > - tree_code_type_tmpl <0>::tree_code_type[(int) (CODE)] > -#else > #define TREE_CODE_CLASS(CODE) tree_code_type[(int) (CODE)] > -#endif > > /* Nonzero if NODE represents an exceptional code. */ > > @@ -276,12 +271,7 @@ code_helper::is_builtin_fn () const > > #define EXPR_P(NODE) IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (NODE))) > > -#if __cpp_inline_variables < 201606L > -#define TREE_CODE_LENGTH(CODE) \ > - tree_code_length_tmpl <0>::tree_code_length[(int) (CODE)] > -#else > #define TREE_CODE_LENGTH(CODE) tree_code_length[(int) (CODE)] > -#endif > > > /* Helper macros for math builtins. */ > > base-commit: c227508d06a63f9b8fede3fd88813accb447060e