re PR c++/37087 (Segfault on compiling template defined in wrong namespace.)
authorPaolo Carlini <paolo.carlini@oracle.com>
Tue, 12 Aug 2008 19:38:02 +0000 (19:38 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Tue, 12 Aug 2008 19:38:02 +0000 (19:38 +0000)
/cp
2008-08-12  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/37087
* parser.c (cp_parser_class_head): Early return error_mark_node in
case of global qualification of class name or qualified name that
does not name a class.

/testsuite
2008-08-12  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/37087
* g++.dg/template/crash80.C: New.
* g++.old-deja/g++.other/decl5.C: Adjust.

From-SVN: r139034

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/crash80.C [new file with mode: 0644]
gcc/testsuite/g++.old-deja/g++.other/decl5.C

index 5763e3f3b482552d06fb16223218f6eb3cd93e75..00b3613802d29ff469a3ebb01524a11c8983f94e 100644 (file)
@@ -1,3 +1,10 @@
+2008-08-12  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/37087
+       * parser.c (cp_parser_class_head): Early return error_mark_node in
+       case of global qualification of class name or qualified name that
+       does not name a class.
+
 2008-08-09  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>
 
        PR c++/12242
index 1bb52e5e01c4c81950cf31f786a0530589fd921a..fd4e1bbbe7b7d5a1888943feaa7f082f696d1f4b 100644 (file)
@@ -14981,11 +14981,17 @@ cp_parser_class_head (cp_parser* parser,
   cp_parser_commit_to_tentative_parse (parser);
   /* Issue the error about the overly-qualified name now.  */
   if (qualified_p)
-    cp_parser_error (parser,
-                    "global qualification of class name is invalid");
+    {
+      cp_parser_error (parser,
+                      "global qualification of class name is invalid");
+      return error_mark_node;
+    }
   else if (invalid_nested_name_p)
-    cp_parser_error (parser,
-                    "qualified name does not name a class");
+    {
+      cp_parser_error (parser,
+                      "qualified name does not name a class");
+      return error_mark_node;
+    }
   else if (nested_name_specifier)
     {
       tree scope;
index f30067d9a67647f0f98d62c7c067c5ebd67a1265..8399de6d97909341b3205bf8120883503531e598 100644 (file)
@@ -1,3 +1,9 @@
+2008-08-12  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/37087
+       * g++.dg/template/crash80.C: New.
+       * g++.old-deja/g++.other/decl5.C: Adjust.
+
 2008-08-12  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/37014
diff --git a/gcc/testsuite/g++.dg/template/crash80.C b/gcc/testsuite/g++.dg/template/crash80.C
new file mode 100644 (file)
index 0000000..ed462ac
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/37087
+
+namespace a {
+  template <typename T> class Foo;
+}
+
+namespace b {
+  template <> class ::a::Foo<double> {}; // { dg-error "error: global qualification of class name is invalid" }
+}
index f8c447c01d3b768ad5451d820b8ba4ef70082503..62a18e5822f7f374fd7aa51fe07b08a09b251d08 100644 (file)
@@ -16,7 +16,7 @@ struct A {
   int m;
   };
   struct Z;
-  expand me;
+  expand me;          // { dg-error "" } not name a type
   void foo(struct A::e);
   void foo(struct A::z);  // { dg-warning "" } extra qualification
 };
@@ -71,7 +71,7 @@ namespace NMS
   };
 }
 
-NMS::D thing;
+NMS::D thing;         // { dg-error "" } not name a type
 void NMS::fn()
 {
   i = 3;