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.133.124]) by sourceware.org (Postfix) with ESMTPS id E28553858D32 for ; Mon, 14 Nov 2022 23:17:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E28553858D32 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=1668467874; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=P+ehG1Gpx4wZZX5RYSQP6dFEnTsWrWG/mq12bJ31+xY=; b=XXTMra4sqDfPMoB1W0bh25SvH4wRRIiuwTrOVCsRETyOlk4mj9NEyENuRp80ZH1y8WgSWt WBy3BmfxegAK/PtfAjpbSE33CsjrqZlZvlfigk4J6b5fUwwYc/S1ZRpft5bq8r8UfdoA7f BJox2LHXzMfs4HRqdhSAG0BDcH//ekE= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-360-Lj_NUZ08PbOft-tmCsIMSQ-1; Mon, 14 Nov 2022 18:17:53 -0500 X-MC-Unique: Lj_NUZ08PbOft-tmCsIMSQ-1 Received: by mail-qv1-f70.google.com with SMTP id 71-20020a0c804d000000b004b2fb260447so9433245qva.10 for ; Mon, 14 Nov 2022 15:17:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=P+ehG1Gpx4wZZX5RYSQP6dFEnTsWrWG/mq12bJ31+xY=; b=MoOL/6psMT+KdkVaB6tZaxgHX6nemevqNvNhRcTTSb3sm7R5fkdS1MVoXi7zZO3uHE YLtLHt+tr8wwFMmEPNONjRhoM7z91vf7anbNEPGft84cJUD2sKGNFEl2kcGqty6OJwK/ P4R7uvA0QWVMZjLektsnfkKOA9hd4MF71cBV4smhadVj52qFF+2TqRzXXUsOiz7SJR7N 2q8V/c0BpD5U5XJPG+Fcdz494awK0oXAIW8D0fGNj0gPeaf3JW07EAE0SiHCiNTF0e8V pvD0cVA6Ef/Q91j4VaFasK189t1VqtScJi+AK9Y7dWiTtA8vQELFttUvyOJNbgwLRkg/ 2mYA== X-Gm-Message-State: ANoB5pl1xUw09pdjbSyl1VFXptcLxR+IUwTpHE+4s4RyaB1NKTwyYx3o JTW1qdULflDZYDIWHgSxh5tsrGK4pZy8NycuSXa6ezWqBjUgJ6m4njT3ZnudyMb0Kel0Zv4mNqh E6NRAsHUuzgaR6XXP6A== X-Received: by 2002:a05:6214:3187:b0:4c6:11e7:51f8 with SMTP id lb7-20020a056214318700b004c611e751f8mr14380356qvb.41.1668467872647; Mon, 14 Nov 2022 15:17:52 -0800 (PST) X-Google-Smtp-Source: AA0mqf7TtIidCMvlh7Q95dGMBhkkOzCPlvzeYGpcyJeAzUl2BbCZ/FYHLlygGCJlM5qkRs/fakCRWQ== X-Received: by 2002:a05:6214:3187:b0:4c6:11e7:51f8 with SMTP id lb7-20020a056214318700b004c611e751f8mr14380346qvb.41.1668467872391; Mon, 14 Nov 2022 15:17:52 -0800 (PST) Received: from [192.168.1.101] (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 e7-20020a05622a110700b0038b684a1642sm6320300qty.32.2022.11.14.15.17.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 14 Nov 2022 15:17:51 -0800 (PST) Message-ID: <6aed5534-4021-15bd-1a51-de35c295afb7@redhat.com> Date: Mon, 14 Nov 2022 18:17:51 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [PATCH] c++: init_priority and SUPPORTS_INIT_PRIORITY [PR107638] To: Patrick Palka , gcc-patches@gcc.gnu.org References: <20221111184759.2531849-1-ppalka@redhat.com> From: Jason Merrill In-Reply-To: <20221111184759.2531849-1-ppalka@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.5 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 11/11/22 08:47, Patrick Palka wrote: > The commit r13-3706-gd0a492faa6478c for correcting the result of > __has_attribute(init_priority) causes a bootstrap failure on hppa64-hpux > because it assumes SUPPORTS_INIT_PRIORITY expands to a simple constant, > but on this target SUPPORTS_INIT_PRIORITY is defined as > > #define SUPPORTS_INIT_PRIORITY (TARGET_GNU_LD ? 1 : 0) > > (where TARGET_GNU_LD expands to something in terms of global_options) > which means we can't use this macro to statically exclude the entry > for init_priority when defining the cxx_attribute_table. > > So instead of trying to exclude init_priority from the attribute table > for sake of __has_attribute, this patch just makes __has_attribute > handle init_priority specially. > > Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for > trunk? Also sanity checked by artificially defining SUPPORTS_INIT_PRIORITY > to 0. OK. > PR c++/107638 > > gcc/c-family/ChangeLog: > > * c-lex.cc (c_common_has_attribute): Return 1 for init_priority > iff SUPPORTS_INIT_PRIORITY. > > gcc/cp/ChangeLog: > > * tree.cc (cxx_attribute_table): Don't conditionally exclude > the init_priority entry. > (handle_init_priority_attribute): Remove ATTRIBUTE_UNUSED. > Return error_mark_node if !SUPPORTS_INIT_PRIORITY. > --- > gcc/c-family/c-lex.cc | 9 +++++++++ > gcc/cp/tree.cc | 11 +++++++---- > 2 files changed, 16 insertions(+), 4 deletions(-) > > diff --git a/gcc/c-family/c-lex.cc b/gcc/c-family/c-lex.cc > index 89c65aca28a..2fe562c7ccf 100644 > --- a/gcc/c-family/c-lex.cc > +++ b/gcc/c-family/c-lex.cc > @@ -380,6 +380,15 @@ c_common_has_attribute (cpp_reader *pfile, bool std_syntax) > result = 201907; > else if (is_attribute_p ("assume", attr_name)) > result = 202207; > + else if (is_attribute_p ("init_priority", attr_name)) > + { > + /* The (non-standard) init_priority attribute is always > + included in the attribute table, but we don't want to > + advertise the attribute unless the target actually > + supports init priorities. */ > + result = SUPPORTS_INIT_PRIORITY ? 1 : 0; > + attr_name = NULL_TREE; > + } > } > else > { > diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc > index c30bbeb0839..2324c2269fc 100644 > --- a/gcc/cp/tree.cc > +++ b/gcc/cp/tree.cc > @@ -5010,10 +5010,8 @@ const struct attribute_spec cxx_attribute_table[] = > { > /* { name, min_len, max_len, decl_req, type_req, fn_type_req, > affects_type_identity, handler, exclude } */ > -#if SUPPORTS_INIT_PRIORITY > { "init_priority", 1, 1, true, false, false, false, > handle_init_priority_attribute, NULL }, > -#endif > { "abi_tag", 1, -1, false, false, false, true, > handle_abi_tag_attribute, NULL }, > { NULL, 0, 0, false, false, false, false, NULL, NULL } > @@ -5041,13 +5039,19 @@ const struct attribute_spec std_attribute_table[] = > > /* Handle an "init_priority" attribute; arguments as in > struct attribute_spec.handler. */ > -ATTRIBUTE_UNUSED static tree > +static tree > handle_init_priority_attribute (tree* node, > tree name, > tree args, > int /*flags*/, > bool* no_add_attrs) > { > + if (!SUPPORTS_INIT_PRIORITY) > + /* Treat init_priority as an unrecognized attribute (mirroring the > + result of __has_attribute) if the target doesn't support init > + priorities. */ > + return error_mark_node; > + > tree initp_expr = TREE_VALUE (args); > tree decl = *node; > tree type = TREE_TYPE (decl); > @@ -5105,7 +5109,6 @@ handle_init_priority_attribute (tree* node, > pri); > } > > - gcc_assert (SUPPORTS_INIT_PRIORITY); > SET_DECL_INIT_PRIORITY (decl, pri); > DECL_HAS_INIT_PRIORITY_P (decl) = 1; > return NULL_TREE;