From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by sourceware.org (Postfix) with ESMTPS id 53E19382A6E5 for ; Tue, 24 May 2022 12:00:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 53E19382A6E5 Received: by mail-ej1-x62d.google.com with SMTP id m20so34818103ejj.10 for ; Tue, 24 May 2022 05:00:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=aUUTKzAJHZ6R0wrv49pLh6LdkTlpS28FXEX3hdP/Vvw=; b=H1SdZAMQnmXz4tHigVZX3NCYI+4VtqVC6yDQATGMeY5dbCQYYlifjac0DLukogCvNG taD8YqRLeLSVKCs12O/7KRcI9qh2cs4xzjtx3nbytyEc0iUuoIZLl83dc39p4xN1E0Ap OAjIOg0pJQssHGPqQnm1evqrra9zHvmfGzL6BlEOfxBRBLXKTagq4aGbkxgZ4r2TwWf9 Uku1QEwLeeT7vB3VGxxkfYjNlJg6GSSPKrj69tlXPlE1UYLLt3zdy7qOnPSEn/SIADDI kS66h6qfThHCs5jDVk9t7T5x1CV4K4oNokjv/l3hc+BQeZveuUHkmD1BpJqORzmpSGSj eK7Q== X-Gm-Message-State: AOAM532u9bv9dFcoSZII/7vYpALUoY//jzNRxuYzt0xdwjZg4Ii7d1EM 10x6qDKGbfWcT37485dPH+eyyuLQluir/hA3Q09mMQ== X-Google-Smtp-Source: ABdhPJwFJh0wes1UMg2HoDQ+7w1WXReM4YYx23J9mBiQ+x7RG0pNtK7ajfPZZwjkMLl1ohBVg6K5C5VAJZ24BJbsnt4= X-Received: by 2002:a17:907:6d05:b0:6fe:c506:9239 with SMTP id sa5-20020a1709076d0500b006fec5069239mr12045983ejc.539.1653393632588; Tue, 24 May 2022 05:00:32 -0700 (PDT) MIME-Version: 1.0 References: <20220429141233.41897-1-polacek@redhat.com> In-Reply-To: <20220429141233.41897-1-polacek@redhat.com> From: Prathamesh Kulkarni Date: Tue, 24 May 2022 17:29:56 +0530 Message-ID: Subject: Re: [PATCH] c++: fix ICE on invalid attributes [PR96637] To: Marek Polacek Cc: GCC Patches , Jason Merrill Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Tue, 24 May 2022 12:00:40 -0000 On Fri, 29 Apr 2022 at 19:44, Marek Polacek via Gcc-patches wrote: > > This patch fixes crashes with invalid attributes. Arguably it could > make sense to assert seen_error() too. > > Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk = GCC 13? > > PR c++/96637 > > gcc/ChangeLog: > > * attribs.cc (decl_attributes): Check error_mark_node. > > gcc/cp/ChangeLog: > > * decl2.cc (cp_check_const_attributes): Check error_mark_node. > > gcc/testsuite/ChangeLog: > > * g++.dg/parse/error64.C: New test. > --- > gcc/attribs.cc | 3 +++ > gcc/cp/decl2.cc | 2 ++ > gcc/testsuite/g++.dg/parse/error64.C | 4 ++++ > 3 files changed, 9 insertions(+) > create mode 100644 gcc/testsuite/g++.dg/parse/error64.C > > diff --git a/gcc/attribs.cc b/gcc/attribs.cc > index b219f878042..ff157dcf81c 100644 > --- a/gcc/attribs.cc > +++ b/gcc/attribs.cc > @@ -700,6 +700,9 @@ decl_attributes (tree *node, tree attributes, int flags, > in the same order as in the source. */ > for (tree attr = attributes; attr; attr = TREE_CHAIN (attr)) > { > + if (attr == error_mark_node) > + continue; Not a comment on the patch specifically, but just wondering if it'd be better to use error_operand_p, than testing against error_mark_node explicitly ? Thanks, Prathamesh > + > tree ns = get_attribute_namespace (attr); > tree name = get_attribute_name (attr); > tree args = TREE_VALUE (attr); > diff --git a/gcc/cp/decl2.cc b/gcc/cp/decl2.cc > index d2b29208ed5..c3ff1962a75 100644 > --- a/gcc/cp/decl2.cc > +++ b/gcc/cp/decl2.cc > @@ -1537,6 +1537,8 @@ cp_check_const_attributes (tree attributes) > /* As we implement alignas using gnu::aligned attribute and > alignas argument is a constant expression, force manifestly > constant evaluation of aligned attribute argument. */ > + if (attr == error_mark_node) > + continue; > bool manifestly_const_eval > = is_attribute_p ("aligned", get_attribute_name (attr)); > for (arg = TREE_VALUE (attr); arg && TREE_CODE (arg) == TREE_LIST; > diff --git a/gcc/testsuite/g++.dg/parse/error64.C b/gcc/testsuite/g++.dg/parse/error64.C > new file mode 100644 > index 00000000000..87848a58c27 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/parse/error64.C > @@ -0,0 +1,4 @@ > +// PR c++/96637 > +// { dg-do compile } > + > +void foo(int[] alignas[1] alignas(1)){} // { dg-error "" } > > base-commit: 9ae8b993cd362e8aea4f65580aaf1453120207f2 > -- > 2.35.1 >