From patchwork Thu Dec 16 22:35:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 49028 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DA9BD3858D28 for ; Thu, 16 Dec 2021 22:36:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DA9BD3858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1639694216; bh=BEI50G8dWHNW/M9YmyWpVrwDoAkuVKZyHbVXnq1pSqc=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=TCxcvp6kOw7baVpZW2W/DNjd1tOZDRAf6JXP2Bn3pq/K6HHi0y/LY6VqiPB5443CQ TMLG10LhkwRHw5S8EnOvEGHdpzv2rGxD39R7BN8oGE0eTaVj91iqzgEzGxbd1z5zAg p6qE2n/WsEFiLI5tEkmmkAE7OL27CrygO/lKLnio= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 4492E3858414 for ; Thu, 16 Dec 2021 22:36:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4492E3858414 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-342-u02H5pzENDa_9nwSnlErJg-1; Thu, 16 Dec 2021 17:36:10 -0500 X-MC-Unique: u02H5pzENDa_9nwSnlErJg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 73CCE10168C7; Thu, 16 Dec 2021 22:36:09 +0000 (UTC) Received: from pdp-11.redhat.com (unknown [10.22.18.74]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4D7AA70D30; Thu, 16 Dec 2021 22:36:05 +0000 (UTC) To: GCC Patches , Jakub Jelinek , Jason Merrill , Joseph Myers Subject: [PATCH] attribs: Fix wrong error with -Wno-attribute=A::b [PR103649] Date: Thu, 16 Dec 2021 17:35:55 -0500 Message-Id: <20211216223555.820800-1-polacek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-14.2 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-Patchwork-Original-From: Marek Polacek via Gcc-patches From: Marek Polacek Reply-To: Marek Polacek Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" 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. --- gcc/attribs.c | 2 +- gcc/testsuite/c-c++-common/Wno-attributes-6.c | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/c-c++-common/Wno-attributes-6.c base-commit: f91814c22595e1db642140efe030caf2c092ab6f diff --git a/gcc/attribs.c b/gcc/attribs.c index 29703e75fba..4933f020f1a 100644 --- 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();