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 06FDB3858D38 for ; Fri, 30 Sep 2022 13:12:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 06FDB3858D38 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=1664543549; 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=EMZQMAeedLqvC3Hb5tOlaGFO9Gf0C6POiIDhZy1UwT4=; b=KoPZa6cdJEQBSeBjysTpZiI8wCRzTXwo6Bi8o7+T6lag4e6rmzMqfqyMfmcCZJ269SaNCc SHEeB/widfMpwXpfvp9w8AW0mRkPa79Tww4jrMzIXKOqSqAq+xTV63iAlQKwo7nyHFAOZB JJXj92aAsrmPMb9SIBHeVQNEsg3Gf0E= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-317-co0yyLy-MK-x00k4y9gm1Q-1; Fri, 30 Sep 2022 09:12:27 -0400 X-MC-Unique: co0yyLy-MK-x00k4y9gm1Q-1 Received: by mail-qt1-f197.google.com with SMTP id e8-20020ac85988000000b0035c39dd5eb9so2919711qte.16 for ; Fri, 30 Sep 2022 06:12:27 -0700 (PDT) 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; bh=EMZQMAeedLqvC3Hb5tOlaGFO9Gf0C6POiIDhZy1UwT4=; b=RuOoeZV5URwAVHEu6NORzKIj83uJnTURcI9hnkOM9mL3i4NZ+DhaaSY8n8E8T8Drza EnbryPA6rW+HP2tKWynHjfURGMj3Me2sQmULcZ6ex+vRXkgLQmto7Zu+1HmdQCh2wX7+ scKaBlPkBnzs1H1a7V7Y6LaxsHULIL4H4RnTVRE4X6aNCehcA4eVJ8nUR+fdEjQwGses XgMXkRZXTNwF8hdkj1/cXyUX4pRw4cJv8kTjDLuTiInMxC+tMjdWEAp5ZtLGBJXWGKEG 4LqEvvwlafYS2CUMLjb4xDBvDg6S1dF5WAhUiA/NYqSZ/miHpKfvGZW1EKMzKGKnQhTH H0/Q== X-Gm-Message-State: ACrzQf2BxmHIDfZu4unQDzkYIMj7mjA9yAFlVqK5MsE0oTVPjqJT1Qxs EiaCxxHl6RvBjOsEHm1KgqucxxI5vaUMa+RdzM44E9R6QT8p+8m0EKT+1EWnCu4PvNWKjo7UQdv m/zR+9KYbChXeIO0aZA== X-Received: by 2002:a05:6214:5018:b0:4b1:718c:26e3 with SMTP id jo24-20020a056214501800b004b1718c26e3mr724543qvb.19.1664543546650; Fri, 30 Sep 2022 06:12:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6l3/XaWFm8NYMGTi+G2Q7PE+jjYF90Rzx/EFtduTSIkmNykjNbJzBSUJbBZNnxpD7QF957OQ== X-Received: by 2002:a05:6214:5018:b0:4b1:718c:26e3 with SMTP id jo24-20020a056214501800b004b1718c26e3mr724526qvb.19.1664543546293; Fri, 30 Sep 2022 06:12:26 -0700 (PDT) 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 l18-20020a05620a28d200b006ce813bb306sm2518206qkp.125.2022.09.30.06.12.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 30 Sep 2022 06:12:25 -0700 (PDT) Message-ID: <1c85a5bf-82dd-772c-a960-75a495ded832@redhat.com> Date: Fri, 30 Sep 2022 09:12:24 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.13.1 Subject: Re: [PATCH] c-family: ICE with [[gnu::nocf_check]] [PR106937] To: Marek Polacek , GCC Patches , Joseph Myers References: <20220929224945.90798-1-polacek@redhat.com> From: Jason Merrill In-Reply-To: <20220929224945.90798-1-polacek@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=-13.3 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_LOW,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 9/29/22 18:49, Marek Polacek wrote: > When getting the name of an attribute, we ought to use > get_attribute_name, which handles both [[ ]] and __attribute__(()) > forms. Failure to do so may result in an ICE, like here. > > Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? How do we print the attributes with this patch? Don't we also want to print the namespace, and use [[]] in the output? > PR c++/106937 > > gcc/c-family/ChangeLog: > > * c-pretty-print.cc (pp_c_attributes): Use get_attribute_name. > (pp_c_attributes_display): Likewise. > > gcc/testsuite/ChangeLog: > > * gcc.dg/fcf-protection-1.c: New test. > --- > gcc/c-family/c-pretty-print.cc | 8 ++++---- > gcc/testsuite/gcc.dg/fcf-protection-1.c | 13 +++++++++++++ > 2 files changed, 17 insertions(+), 4 deletions(-) > create mode 100644 gcc/testsuite/gcc.dg/fcf-protection-1.c > > diff --git a/gcc/c-family/c-pretty-print.cc b/gcc/c-family/c-pretty-print.cc > index efa1768f4d6..91f88b830e3 100644 > --- a/gcc/c-family/c-pretty-print.cc > +++ b/gcc/c-family/c-pretty-print.cc > @@ -863,7 +863,7 @@ pp_c_attributes (c_pretty_printer *pp, tree attributes) > pp_c_left_paren (pp); > for (; attributes != NULL_TREE; attributes = TREE_CHAIN (attributes)) > { > - pp_tree_identifier (pp, TREE_PURPOSE (attributes)); > + pp_tree_identifier (pp, get_attribute_name (attributes)); > if (TREE_VALUE (attributes)) > pp_c_call_argument_list (pp, TREE_VALUE (attributes)); > > @@ -875,7 +875,7 @@ pp_c_attributes (c_pretty_printer *pp, tree attributes) > } > > /* Pretty-print ATTRIBUTES using GNU C extension syntax for attributes > - marked to be displayed on disgnostic. */ > + marked to be displayed on diagnostic. */ > > void > pp_c_attributes_display (c_pretty_printer *pp, tree a) > @@ -888,7 +888,7 @@ pp_c_attributes_display (c_pretty_printer *pp, tree a) > for (; a != NULL_TREE; a = TREE_CHAIN (a)) > { > const struct attribute_spec *as; > - as = lookup_attribute_spec (TREE_PURPOSE (a)); > + as = lookup_attribute_spec (get_attribute_name (a)); > if (!as || as->affects_type_identity == false) > continue; > if (c_dialect_cxx () > @@ -906,7 +906,7 @@ pp_c_attributes_display (c_pretty_printer *pp, tree a) > { > pp_separate_with (pp, ','); > } > - pp_tree_identifier (pp, TREE_PURPOSE (a)); > + pp_tree_identifier (pp, get_attribute_name (a)); > if (TREE_VALUE (a)) > pp_c_call_argument_list (pp, TREE_VALUE (a)); > } > diff --git a/gcc/testsuite/gcc.dg/fcf-protection-1.c b/gcc/testsuite/gcc.dg/fcf-protection-1.c > new file mode 100644 > index 00000000000..9d06feadfd1 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/fcf-protection-1.c > @@ -0,0 +1,13 @@ > +/* PR c++/106937 */ > +/* { dg-options "-fcf-protection -w" } */ > + > +[[gnu::nocf_check]] typedef void (*FuncPointerWithNoCfCheck)(void); > +typedef void (*FuncPointer)(void); > +[[gnu::nocf_check]] void testNoCfCheck(); > +void testNoCfCheck(){}; > +int [[gnu::nocf_check]] i; > +void testNoCfCheckImpl(double i [[gnu::nocf_check]]) {} > +void testNoCfCheckMismatch(FuncPointer f) { > + FuncPointerWithNoCfCheck fNoCfCheck = f; > + (*fNoCfCheck)(); > +} > > base-commit: c2ee70f20de8133a88553270073226b0f3f55f62