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]

[patch, c++] Patch for PR c++/29388 - 4.2/4.3/4.4 regression


Here is a patch for the regression PR c++/29388, an ICE on invalid
code bug.  I am not completely happy with it because MAYBE_CLASS_TYPE_P
could, presumbably, still return TRUE for something that is not a class
or namespace and in that case we might still have the ICE.  But the patch
does fix the specific case in the PR and does not cause any regressions
so I would like to check it in.

Tested on IA64 HP-UX and Linux with no regressions.

OK for checkin?

Steve Ellcey
sje@cup.hp.com



2008-12-10  Steve Ellcey  <sje@cup.hp.com>

	* decl.c (grokdeclarator): Check if type is class or namespace.


2008-12-10  Steve Ellcey  <sje@cup.hp.com>

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



Index: decl.c
===================================================================
--- decl.c	(revision 142545)
+++ decl.c	(working copy)
@@ -8586,6 +8586,15 @@ grokdeclarator (const cp_declarator *dec
 	{
 	  tree sname = declarator->u.id.unqualified_name;
 
+          if (ctype && !MAYBE_CLASS_TYPE_P (ctype))
+	    {
+	      if (TYPE_P (ctype))
+		error ("%qT is not a class or namespace", ctype);
+	      else
+		error ("%qD is not a class or namespace", ctype);
+	      return error_mark_node;
+	    }
+
 	  if (current_class_type
 	      && (!friendp || funcdef_flag))
 	    {




Index: g++.dg/template/crash86.C
===================================================================
--- g++.dg/template/crash86.C	(revision 0)
+++ g++.dg/template/crash86.C	(revision 0)
@@ -0,0 +1,10 @@
+// Origin: PR c++/29388
+// { dg-do compile }
+
+template<int> struct A
+{
+  typedef int T;
+  void foo();
+};
+
+template<int N> void A<N>::T::foo() {} // { dg-error "not a class" }


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