From 72b75d0333b5b00c02a1b3f87641269e6cd629d7 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Fri, 10 Apr 2009 11:56:07 -0700 Subject: [PATCH] re PR c++/28301 (ICE with broken specialization) gcc/cp/ 2009-04-10 Jason Merrill PR c++/28301 * parser.c (cp_parser_skip_to_end_of_block_or_statement): Return if we see a close brace without an open brace. gcc/testsuite/ 2009-04-10 H.J. Lu PR c++/28301 * g++.dg/cpp0x/enum2.C: Updated. * g++.dg/debug/pr22514.C: Likewise. * g++.dg/parse/enum2.C: Likewise. * g++.dg/parse/enum3.C: Likewise. * g++.dg/template/crash79.C: Likewise. * g++.old-deja/g++.jason/cond.C: Likewise. * g++.dg/template/pr28301.C: New. From-SVN: r145936 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/parser.c | 2 ++ gcc/testsuite/ChangeLog | 10 ++++++++++ gcc/testsuite/g++.dg/cpp0x/enum2.C | 2 +- gcc/testsuite/g++.dg/debug/pr22514.C | 2 +- gcc/testsuite/g++.dg/parse/enum2.C | 2 +- gcc/testsuite/g++.dg/parse/enum3.C | 4 ++-- gcc/testsuite/g++.dg/template/crash79.C | 6 +++--- gcc/testsuite/g++.dg/template/pr28301.C | 18 ++++++++++++++++++ gcc/testsuite/g++.old-deja/g++.jason/cond.C | 2 +- 10 files changed, 45 insertions(+), 9 deletions(-) create mode 100644 gcc/testsuite/g++.dg/template/pr28301.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c70eed6f691..0a3af2ac508 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2009-04-10 Jason Merrill + + PR c++/28301 + * parser.c (cp_parser_skip_to_end_of_block_or_statement): Return + if we see a close brace without an open brace. + 2008-04-10 H.J. Lu * parser.c (cp_parser_class_specifier): Remove the unused diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index e942635680d..4dec792e577 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -2623,6 +2623,8 @@ cp_parser_skip_to_end_of_block_or_statement (cp_parser* parser) /* Stop if this is an unnested '}', or closes the outermost nesting level. */ nesting_depth--; + if (nesting_depth < 0) + return; if (!nesting_depth) nesting_depth = -1; break; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c7ddb9f3cea..da40b35470f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,13 @@ +2009-04-10 H.J. Lu + + PR c++/28301 + * g++.dg/cpp0x/enum2.C: Updated. + * g++.dg/debug/pr22514.C: Likewise. + * g++.dg/parse/enum2.C: Likewise. + * g++.dg/parse/enum3.C: Likewise. + * g++.dg/template/crash79.C: Likewise. + * g++.old-deja/g++.jason/cond.C: Likewise. + 2009-04-10 Chao-ying Fu * gcc.target/mips/interrupt_handler.c: Change from compile to diff --git a/gcc/testsuite/g++.dg/cpp0x/enum2.C b/gcc/testsuite/g++.dg/cpp0x/enum2.C index 2353f1d47e6..21c265a923c 100644 --- a/gcc/testsuite/g++.dg/cpp0x/enum2.C +++ b/gcc/testsuite/g++.dg/cpp0x/enum2.C @@ -2,4 +2,4 @@ // { dg-do compile } // { dg-options "-std=c++0x" } -template enum E : int { e }; // { dg-error "template declaration of" } +template enum E : int { e }; // { dg-error "declaration|expected" } diff --git a/gcc/testsuite/g++.dg/debug/pr22514.C b/gcc/testsuite/g++.dg/debug/pr22514.C index 23dc9b2b061..3df9e230ecb 100644 --- a/gcc/testsuite/g++.dg/debug/pr22514.C +++ b/gcc/testsuite/g++.dg/debug/pr22514.C @@ -10,4 +10,4 @@ namespace s using _List_base::_M_impl; } } /* { dg-error "expected unqualified-id before '\}'" } */ -s::list<1> OutputModuleListType; /* { dg-error "expected" } */ +s::list<1> OutputModuleListType; diff --git a/gcc/testsuite/g++.dg/parse/enum2.C b/gcc/testsuite/g++.dg/parse/enum2.C index f29d3b569d5..f77f91701d9 100644 --- a/gcc/testsuite/g++.dg/parse/enum2.C +++ b/gcc/testsuite/g++.dg/parse/enum2.C @@ -4,4 +4,4 @@ // PR c++/18123: ICE pushing tag from invalid template. -template enum E { e }; // { dg-error "template declaration" } +template enum E { e }; // { dg-error "declaration|expected" } diff --git a/gcc/testsuite/g++.dg/parse/enum3.C b/gcc/testsuite/g++.dg/parse/enum3.C index 11c532c6e91..508e4b94de7 100644 --- a/gcc/testsuite/g++.dg/parse/enum3.C +++ b/gcc/testsuite/g++.dg/parse/enum3.C @@ -1,5 +1,5 @@ // PR c++/28261 -struct A {}; // { dg-error "A" } +struct A {}; -A::A (enum { e }) {} // { dg-error "defined|match" } +A::A (enum { e }) {} // { dg-error "defined|token" } diff --git a/gcc/testsuite/g++.dg/template/crash79.C b/gcc/testsuite/g++.dg/template/crash79.C index be71848fe83..700fd293d73 100644 --- a/gcc/testsuite/g++.dg/template/crash79.C +++ b/gcc/testsuite/g++.dg/template/crash79.C @@ -3,7 +3,7 @@ struct A { A(int); - template enum { e }; // { dg-error "template" } -}; + template enum { e }; // { dg-error "template|expected" } +}; // { dg-error "expected" } -A a(A::e); // { dg-error "not a member" } +A a(A::e); diff --git a/gcc/testsuite/g++.dg/template/pr28301.C b/gcc/testsuite/g++.dg/template/pr28301.C new file mode 100644 index 00000000000..a7a00847880 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/pr28301.C @@ -0,0 +1,18 @@ +// PR c++/28301 +// { dg-do compile } + +template struct A +{ + template void foo() +}; // { dg-error "initializer" } + +template<> struct A +{ + template void foo(); +}; + +void bar() +{ + A a; + a.foo<0>(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/cond.C b/gcc/testsuite/g++.old-deja/g++.jason/cond.C index eaddcd68a0a..1c9e8068f58 100644 --- a/gcc/testsuite/g++.old-deja/g++.jason/cond.C +++ b/gcc/testsuite/g++.old-deja/g++.jason/cond.C @@ -40,7 +40,7 @@ int main() // { dg-error "expected" "exp" { target *-*-* } 39 } if (enum A { one, two, three } foo = one) // { dg-error "defined" "def" } - // { dg-error "declared" "decl" { target *-*-* } 42 } + // { dg-error "expected" "expected" { target *-*-* } 42 } ; struct B { operator int () { return 2; } };