PR c++/9781, c++/10583, c++/11862
authorlerdsuwa <lerdsuwa@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 20 Oct 2003 12:42:37 +0000 (12:42 +0000)
committerlerdsuwa <lerdsuwa@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 20 Oct 2003 12:42:37 +0000 (12:42 +0000)
* decl.c (cp_finish_decl): Exit immediately if decl is an
error_mark_node.
* pt.c (push_template_decl_real): Return error_mark_node for
invalid template declaration of variable.

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

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

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

index 344083a..ca19a4b 100644 (file)
@@ -1,3 +1,11 @@
+2003-10-20  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
+
+       PR c++/9781, c++/10583, c++/11862
+       * decl.c (cp_finish_decl): Exit immediately if decl is an
+       error_mark_node.
+       * pt.c (push_template_decl_real): Return error_mark_node for
+       invalid template declaration of variable.
+
 2003-10-18  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
 
        PR c++/12495
index 227c773..8ca69d1 100644 (file)
@@ -4658,7 +4658,9 @@ cp_finish_decl (tree decl, tree init, tree asmspec_tree, int flags)
   const char *asmspec = NULL;
   int was_readonly = 0;
 
-  if (! decl)
+  if (decl == error_mark_node)
+    return;
+  else if (! decl)
     {
       if (init)
        error ("assignment (not initialization) in declaration");
index 32b146f..3470193 100644 (file)
@@ -2690,7 +2690,10 @@ push_template_decl_real (tree decl, int is_friend)
               || TREE_CODE (decl) == FUNCTION_DECL)
        /* OK */;
       else
-       error ("template declaration of `%#D'", decl);
+       {
+         error ("template declaration of `%#D'", decl);
+         return error_mark_node;
+       }
     }
 
   /* Check to see that the rules regarding the use of default
index 533e98b..9617fc2 100644 (file)
@@ -1,3 +1,8 @@
+2003-10-20  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
+
+       PR c++/9781, c++/10583, c++/11862
+       * g++.dg/parse/crash13.C: New test.
+
 2003-10-20  Zdenek Dvorak  <rakdver@atrey.karlin.mff.cuni.cz>
 
        * gcc.dg/old-style-asm-1.c: Count jump_insns instead of labels.
diff --git a/gcc/testsuite/g++.dg/parse/crash13.C b/gcc/testsuite/g++.dg/parse/crash13.C
new file mode 100644 (file)
index 0000000..d81b6a5
--- /dev/null
@@ -0,0 +1,22 @@
+// { dg-do compile }
+
+// Origin: Giovanni Bajo <giovannibajo@libero.it>
+
+// PR c++/10583: ICE using template function with invalid signature.
+
+template <typename> 
+struct A 
+{
+    struct B 
+    {};
+};
+
+template <typename T> 
+void func(A<T>::B* )   // { dg-error "variable|template|expression" }
+{                      // { dg-error ";" }
+}
+
+int main() 
+{
+  func<void>(0);       // { dg-error "undeclared|expression|;" }
+}