This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[C++ PATCH] Avoid decl_attributes on error_mark_node (PR c++/34100)


Hi!

On this testcase decl_attributes is called with a TYPE_DECL with
error_mark_node type, which most of the attribute handlers aren't prepared
to handle.  decl_attributes for attributes which require type will use
TREE_TYPE (decl) and all the handle_*_attribute routines expect that if
they require a type they will see a type rather than something else.
I have tried to return error_mark_node from tsubst_decl for TYPE_DECLs
where type == error_mark_node (which it already does for e.g. VAR_DECL
with type == error_mark_node), but that caused a bunch of testsuite
regressions, so I think it is better to leave that as is and catch the
problem either in apply_late_template_attributes, or in that function's
callers.

Regtested on x86_64-linux, ok for trunk?

2007-11-15  Jakub Jelinek  <jakub@redhat.com>

	PR c++/34100
	* pt.c (apply_late_template_attributes): Do nothing if decl's type is
	error_mark_node.

	* g++.dg/template/crash73.C: New test.

--- gcc/cp/pt.c.jj	2007-11-15 09:29:48.000000000 +0100
+++ gcc/cp/pt.c	2007-11-15 09:40:54.000000000 +0100
@@ -6622,7 +6622,11 @@ apply_late_template_attributes (tree *de
       }
 
   if (DECL_P (*decl_p))
-    p = &DECL_ATTRIBUTES (*decl_p);
+    {
+      if (TREE_TYPE (*decl_p) == error_mark_node)
+	return;
+      p = &DECL_ATTRIBUTES (*decl_p);
+    }
   else
     p = &TYPE_ATTRIBUTES (*decl_p);
 
--- gcc/testsuite/g++.dg/template/crash73.C.jj	2007-11-15 11:22:11.000000000 +0100
+++ gcc/testsuite/g++.dg/template/crash73.C	2007-11-15 11:22:02.000000000 +0100
@@ -0,0 +1,9 @@
+// PR c++/34100
+// { dg-do compile }
+
+template<typename T> struct A
+{
+  typedef typename T::X Y __attribute__((vector_size(8)));	// { dg-error "is not a class, struct" }
+};
+
+A<int> a;

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]