public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] c++: Fix up ICE when cplus_decl_attributes is called with error_mark_node attributes [PR104668]
@ 2022-03-25 16:34 Jakub Jelinek
  2022-03-25 18:08 ` Jason Merrill
  0 siblings, 1 reply; 7+ messages in thread
From: Jakub Jelinek @ 2022-03-25 16:34 UTC (permalink / raw)
  To: Jason Merrill; +Cc: gcc-patches

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  <jakub@redhat.com>

	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 <class... Ts>
+void sink(Ts...);
+template <class... Ts>
+void f(Ts...) {
+  sink([] { struct alignas:Ts) S {}; }...); }
+}
+int main() {
+  f(0);
+}

	Jakub


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-04-06 15:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-25 16:34 [PATCH] c++: Fix up ICE when cplus_decl_attributes is called with error_mark_node attributes [PR104668] Jakub Jelinek
2022-03-25 18:08 ` Jason Merrill
     [not found]   ` <Yj4Oe1CHMe1y7wZf@tucnak>
2022-03-25 18:55     ` Jakub Jelinek
2022-04-06 14:43       ` Ping " Jakub Jelinek
2022-04-06 15:18   ` Jason Merrill
2022-04-06 15:26     ` Jakub Jelinek
2022-04-06 15:47       ` Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).