]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/26558 (segfault on syntax error)
authorVolker Reichelt <reichelt@igpm.rwth-aachen.de>
Wed, 19 Apr 2006 22:10:10 +0000 (22:10 +0000)
committerVolker Reichelt <reichelt@gcc.gnu.org>
Wed, 19 Apr 2006 22:10:10 +0000 (22:10 +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: r113098

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

index ba1093c8cb75307d26665ae521d063a0cf7a8a9b..74fce51c3158bd9a28a0a56dbbf597b77712e933 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++/26036
        * typeck.c (convert_arguments): Return error_mark_node instead of
        error_mark_list.
index cdd75ed007582d765a83e25c695d3a185f9781de..7035645c3594a7e3edff587bf5e47062b1e24a86 100644 (file)
@@ -12542,15 +12542,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 fc58314304447c7434bd29ed689e3aafee59006c..c5ff475ffb5d09f351de6e35e879ebdac8df9af0 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++/26036
        * g++.dg/expr/call3.C: New test.
 
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" }
+  }
+};