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 A5F7F38F8611 for ; Tue, 24 May 2022 12:22:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A5F7F38F8611 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-675-vLr_JFRoPy2hYRaORq2nxA-1; Tue, 24 May 2022 08:22:25 -0400 X-MC-Unique: vLr_JFRoPy2hYRaORq2nxA-1 Received: by mail-qv1-f69.google.com with SMTP id fw9-20020a056214238900b0043522aa5b81so13125951qvb.21 for ; Tue, 24 May 2022 05:22:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=v84bGAuURlLgNiTuk0tkvRkgFUuqtJPxAC5HKMaZEmU=; b=MxGq6z4TC6rQ545Ju1i0710jcMuKEiwbhgDeYXkUaMbY0jzyZsyj4yh8vgwsmoZxgM QduvyhsgU1ih3qqJijjiWF+baja4hKn5SobHoSSX9HTHnkV5Lk3ZKILW4SUnmQorcMBm 6MMqDO6nj4gzAKGMKNzHfQBIVooYxP6Y9sXIS86lgqAgWWIFT9x3ZFgToWQKAs63afl/ rTOea5H4awsKdNSmwEMCkakO8P3DJDRLGC4XLMgq1ndGZtT9fr7ObJRbwnpgAzfM1ei/ js4SF4cVXky8bz0GeGtbi004lHnlu47to9LvN8ajgeaAZEdbCDj6b4Nj3o9uROePQ3cI UBhA== X-Gm-Message-State: AOAM5318Uxr+jGzM/MNPE3W6GL9yqxi79l1atyDdDlXHa/f/ij23JFW6 sEjVLcW4HOInSOryA7GOccem36yudKhI5Ury5jUtv7a5w5IozKOnWJml7TlHepTXhKeh0Q5P8Lr jYOIEMXsA9TrWD94YSA== X-Received: by 2002:a05:6214:3003:b0:462:1c15:772c with SMTP id ke3-20020a056214300300b004621c15772cmr13146715qvb.71.1653394944343; Tue, 24 May 2022 05:22:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzsQ5EkwISm5KLn7l9quzZemtEbkE9FdaC+HKg0g7plCI06gwULlVvMectBb22vkyEE54Jc5A== X-Received: by 2002:a05:6214:3003:b0:462:1c15:772c with SMTP id ke3-20020a056214300300b004621c15772cmr13146691qvb.71.1653394944018; Tue, 24 May 2022 05:22:24 -0700 (PDT) Received: from [192.168.1.100] (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 x9-20020ac87ec9000000b002f3bbad9e37sm5991848qtj.91.2022.05.24.05.22.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 24 May 2022 05:22:23 -0700 (PDT) Message-ID: Date: Tue, 24 May 2022 08:22:22 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH] c++: fix ICE on invalid attributes [PR96637] To: Marek Polacek , GCC Patches References: <20220429141233.41897-1-polacek@redhat.com> From: Jason Merrill In-Reply-To: <20220429141233.41897-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=-14.6 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, 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:22:27 -0000 On 4/29/22 10:12, Marek Polacek wrote: > This patch fixes crashes with invalid attributes. Arguably it could > make sense to assert seen_error() too. So in this testcase we have TREE_CHAIN of a TREE_LIST pointing to error_mark_node? Can we avoid that? > 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; > + > 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