]> gcc.gnu.org Git - gcc.git/commitdiff
re PR c++/26558 (segfault on syntax error)
authorVolker Reichelt <reichelt@igpm.rwth-aachen.de>
Wed, 19 Apr 2006 22:03:24 +0000 (22:03 +0000)
committerVolker Reichelt <reichelt@gcc.gnu.org>
Wed, 19 Apr 2006 22:03:24 +0000 (22:03 +0000)
PR c++/26558
* parser.c (cp_parser_class_name): Check for invalid typenames.
Rearrange code.

* g++.dg/parse/template19.C: New test.

From-SVN: r113096

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/template19.C [new file with mode: 0644]

index c3df66dcb3298bac84f35cb782ad85cf07ce6a2a..7c1311d27a2f3c93320ed4c06dd1e6c2329fffb0 100644 (file)
@@ -1,5 +1,9 @@
 2006-04-19  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
+       PR c++/26558
+       * parser.c (cp_parser_class_name): Check for invalid typenames.
+       Rearrange code.
+
        PR c++/26739
        * pt.c (tsubst_friend_function): Return early if
        pushdecl_namespace_level fails.
index 13c73627e1c3baead7e37162bf89a5d3eb3c4c27..f673c16bacf46c198b8e14416cb4fe7c08564b3e 100644 (file)
@@ -12830,15 +12830,18 @@ cp_parser_class_name (cp_parser *parser,
        standard does not seem to be definitive, but there is no other
        valid interpretation of the following `::'.  Therefore, those
        names are considered class-names.  */
-    decl = TYPE_NAME (make_typename_type (scope, decl, tag_type, tf_error));
-  else if (decl == error_mark_node
-          || TREE_CODE (decl) != TYPE_DECL
-          || TREE_TYPE (decl) == error_mark_node
-          || !IS_AGGR_TYPE (TREE_TYPE (decl)))
     {
-      cp_parser_error (parser, "expected class-name");
-      return error_mark_node;
+      decl = make_typename_type (scope, decl, tag_type, tf_error);
+      if (decl != error_mark_node)
+       decl = TYPE_NAME (decl);
     }
+  else if (TREE_CODE (decl) != TYPE_DECL
+          || TREE_TYPE (decl) == error_mark_node
+          || !IS_AGGR_TYPE (TREE_TYPE (decl)))
+    decl = error_mark_node;
+
+  if (decl == error_mark_node)
+    cp_parser_error (parser, "expected class-name");
 
   return decl;
 }
index 381ed85732b9251fb4eba83d40f5e3e5a2423c85..e55cee818b254ec5097db48a8310e8a03818fc27 100644 (file)
@@ -1,5 +1,8 @@
 2006-04-19  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
+       PR c++/26558
+       * g++.dg/parse/template19.C: New test.
+
        PR c++/26739
        * g++.old-deja/g++.pt/friend36.C: Adjust error markers.
 
diff --git a/gcc/testsuite/g++.dg/parse/template19.C b/gcc/testsuite/g++.dg/parse/template19.C
new file mode 100644 (file)
index 0000000..dc1a673
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/26558
+// Origin: Jan Gorski <slimak@yk74.internetdsl.tpnet.pl>
+// { dg-do compile }
+
+template<int> struct A
+{
+  template<int> void foo()
+  {
+    foo<0>::; // { dg-error "before" }
+  }
+};
This page took 0.123525 seconds and 5 git commands to generate.