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 6699F385E44F for ; Fri, 25 Mar 2022 16:36:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6699F385E44F Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-639-Lc87Ij0FOg6vOThmhVzEGQ-1; Fri, 25 Mar 2022 12:34:47 -0400 X-MC-Unique: Lc87Ij0FOg6vOThmhVzEGQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6768D969A62 for ; Fri, 25 Mar 2022 16:34:46 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.15]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 295291457F12; Fri, 25 Mar 2022 16:34:45 +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 22PGYgex1801372 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 25 Mar 2022 17:34:43 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 22PGYgtQ1801371; Fri, 25 Mar 2022 17:34:42 +0100 Date: Fri, 25 Mar 2022 17:34:42 +0100 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] c++: Fix up ICE when cplus_decl_attributes is called with error_mark_node attributes [PR104668] Message-ID: Reply-To: Jakub Jelinek MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 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=-4.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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: Fri, 25 Mar 2022 16:36:19 -0000 Hi! cplus_decl_attributes can be called with attributes equal to error_mark_node, there are some spots in the function that test it or decl_attributes it calls starts with: if (TREE_TYPE (*node) == error_mark_node || attributes == error_mark_node) return NULL_TREE; But the recent PR104245 change broke this when processing_template_decl is true. This fixes it and also fixes an OpenMP problem with such attributes. Ok for trunk if it passes bootstrap/regtest? 2022-03-25 Jakub Jelinek PR c++/104668 * decl2.cc (splice_template_attributes): Return NULL if *p is error_mark_node. (cplus_decl_attributes): Don't chain on OpenMP attributes if attributes is error_mark_node. * g++.dg/cpp0x/pr104668.C: New test. --- gcc/cp/decl2.cc.jj 2022-03-09 09:09:55.415843331 +0100 +++ gcc/cp/decl2.cc 2022-03-25 17:17:27.769036749 +0100 @@ -1336,7 +1336,7 @@ splice_template_attributes (tree *attr_p tree late_attrs = NULL_TREE; tree *q = &late_attrs; - if (!p) + if (!p || *p == error_mark_node) return NULL_TREE; for (; *p; ) @@ -1644,6 +1644,8 @@ cplus_decl_attributes (tree *decl, tree && DECL_CLASS_SCOPE_P (*decl)) error ("%q+D static data member inside of declare target directive", *decl); + else if (attributes == error_mark_node) + ; else if (VAR_P (*decl) && (processing_template_decl || !cp_omp_mappable_type (TREE_TYPE (*decl)))) --- gcc/testsuite/g++.dg/cpp0x/pr104668.C.jj 2022-03-25 17:25:42.280068058 +0100 +++ gcc/testsuite/g++.dg/cpp0x/pr104668.C 2022-03-25 17:24:44.862881444 +0100 @@ -0,0 +1,13 @@ +// PR c++/104668 +// { dg-do compile { target c++11 } } +// { dg-excess-errors "" } + +template +void sink(Ts...); +template +void f(Ts...) { + sink([] { struct alignas:Ts) S {}; }...); } +} +int main() { + f(0); +} Jakub