PR c++/19980
authorreichelt <reichelt@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 22 Mar 2005 15:07:04 +0000 (15:07 +0000)
committerreichelt <reichelt@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 22 Mar 2005 15:07:04 +0000 (15:07 +0000)
* decl.c (start_preparsed_function): Robustify.

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

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@96872 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/redecl3.C [new file with mode: 0644]

index bb0c547..73dd59f 100644 (file)
@@ -1,5 +1,10 @@
 2005-03-22  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
+       PR c++/19980
+       * decl.c (start_preparsed_function): Robustify.
+
+2005-03-22  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
        PR c++/20499
        * parser.c (cp_parser_class_head): Return NULL_TREE when
        encountering a redefinition.
index 4887080..1c4568d 100644 (file)
@@ -10009,7 +10009,12 @@ start_preparsed_function (tree decl1, tree attrs, int flags)
      class scope, current_class_type will be NULL_TREE until set above
      by push_nested_class.)  */
   if (processing_template_decl)
-    decl1 = push_template_decl (decl1);
+    {
+      /* FIXME: Handle error_mark_node more gracefully.  */
+      tree newdecl1 = push_template_decl (decl1);
+      if (newdecl1 != error_mark_node)
+        decl1 = newdecl1;
+    }
 
   /* We are now in the scope of the function being defined.  */
   current_function_decl = decl1;
index 3909d56..51f81b9 100644 (file)
@@ -1,5 +1,10 @@
 2005-03-22  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
+       PR c++/19980
+       * g++.dg/template/redecl3.C: New test.
+
+2005-03-22  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
        PR c++/20499
        * g++.dg/parse/error16.C: Tweak error markers.
 
diff --git a/gcc/testsuite/g++.dg/template/redecl3.C b/gcc/testsuite/g++.dg/template/redecl3.C
new file mode 100644 (file)
index 0000000..029f9e6
--- /dev/null
@@ -0,0 +1,7 @@
+// PR c++/19980
+// Origin: Volker Reichelt <reichelt@igpm.rwth-aachen.de>
+
+// { dg-do compile }
+
+int foo;                    // { dg-error "previous declaration" }
+template<int> void foo() {} // { dg-error "redeclared" }