From: Kriang Lerdsuwanakij Date: Mon, 20 Oct 2003 12:42:37 +0000 (+0000) Subject: PR c++/9781, c++/10583, c++/11862 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=11325dcdbdad0d7744dd92d65174777555e8531e;p=gcc.git PR c++/9781, c++/10583, c++/11862 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. * g++.dg/parse/crash13.C: New test. From-SVN: r72701 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 344083acb49..ca19a4b17b1 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2003-10-20 Kriang Lerdsuwanakij + + 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 PR c++/12495 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 227c773e1b3..8ca69d13989 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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"); diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 32b146f5294..3470193d189 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 533e98b95e2..9617fc22c72 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2003-10-20 Kriang Lerdsuwanakij + + PR c++/9781, c++/10583, c++/11862 + * g++.dg/parse/crash13.C: New test. + 2003-10-20 Zdenek Dvorak * 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 index 00000000000..d81b6a55e7a --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/crash13.C @@ -0,0 +1,22 @@ +// { dg-do compile } + +// Origin: Giovanni Bajo + +// PR c++/10583: ICE using template function with invalid signature. + +template +struct A +{ + struct B + {}; +}; + +template +void func(A::B* ) // { dg-error "variable|template|expression" } +{ // { dg-error ";" } +} + +int main() +{ + func(0); // { dg-error "undeclared|expression|;" } +}