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 DDAB63858410 for ; Thu, 16 Dec 2021 22:54:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DDAB63858410 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-326-6PxdFBTfPraQEHp76T7BLA-1; Thu, 16 Dec 2021 17:54:15 -0500 X-MC-Unique: 6PxdFBTfPraQEHp76T7BLA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 966AA81CCB8; Thu, 16 Dec 2021 22:54:14 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.2.16.169]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BF9277D533; Thu, 16 Dec 2021 22:53:49 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 1BGMrlPR2646190 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 16 Dec 2021 23:53:47 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 1BGMrkAV2646189; Thu, 16 Dec 2021 23:53:46 +0100 Date: Thu, 16 Dec 2021 23:53:46 +0100 From: Jakub Jelinek To: Marek Polacek Cc: GCC Patches , Jason Merrill , Joseph Myers Subject: Re: [PATCH] attribs: Fix wrong error with -Wno-attribute=A::b [PR103649] Message-ID: <20211216225346.GA2646553@tucnak> Reply-To: Jakub Jelinek References: <20211216223555.820800-1-polacek@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211216223555.820800-1-polacek@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: , X-List-Received-Date: Thu, 16 Dec 2021 22:54:20 -0000 On Thu, Dec 16, 2021 at 05:35:55PM -0500, Marek Polacek wrote: > My patch to implement -Wno-attribute=A::b caused a bogus error when > parsing > > [[foo::bar(1, 2)]]; > > when -Wno-attributes=foo::bar was specified on the command line, because > when we create a fake foo::bar attribute and insert it into our attribute > table, it is created with max_length == 0 which doesn't allow any args. > That is wrong -- we know nothing about the attribute, so we shouldn't > require any specific number of arguments. > > Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? > > PR c/103649 > > gcc/ChangeLog: > > * attribs.c (handle_ignored_attributes_option): Create the fake > attribute with max_length == -1. > > gcc/testsuite/ChangeLog: > > * c-c++-common/Wno-attributes-6.c: New test. I'm afraid this still changes behavior. 0, -1 range attribute arguments are parsed normally, while unknown attributes have the balanced token sequence skipped. E.g. the omp::{directive,sequence} attribute arguments are much more complex than what the normal parsing can handle. Can you make max -2 instead and special case it in the C and C++ FE attribute handling and in a testcase try something that is a balanced token sequence but not really valid when parsed as ordinary attributes' arguments? > --- a/gcc/attribs.c > +++ b/gcc/attribs.c > @@ -304,7 +304,7 @@ handle_ignored_attributes_option (vec *v) > We can't free it here, so squirrel away the pointers. */ > attribute_spec *table = new attribute_spec[2]; > ignored_attributes_table.safe_push (table); > - table[0] = { attr, 0, 0, false, false, false, false, nullptr, nullptr }; > + table[0] = { attr, 0, -1, false, false, false, false, nullptr, nullptr }; > table[1] = { nullptr, 0, 0, false, false, false, false, nullptr, > nullptr }; > register_scoped_attributes (table, IDENTIFIER_POINTER (vendor_id), !attr); > diff --git a/gcc/testsuite/c-c++-common/Wno-attributes-6.c b/gcc/testsuite/c-c++-common/Wno-attributes-6.c > new file mode 100644 > index 00000000000..02cdaaa1e89 > --- /dev/null > +++ b/gcc/testsuite/c-c++-common/Wno-attributes-6.c > @@ -0,0 +1,9 @@ > +/* PR c/103649 */ > +/* { dg-do compile { target { c || c++11 } } } */ > +/* { dg-additional-options "-Wno-attributes=foo::bar" } */ > +/* { dg-additional-options "-Wno-attributes=baz::" } */ > + > +[[foo::bar(1, 2)]]; /* { dg-warning "attribute ignored" } */ > +[[baz::bar(1, 2)]]; /* { dg-warning "attribute ignored" } */ > +[[foo::bar(1, 2)]] void f1(); > +[[baz::bar(1, 2)]] void f2(); > > base-commit: f91814c22595e1db642140efe030caf2c092ab6f > -- > 2.33.1 Jakub