re PR c++/28301 (ICE with broken specialization)

gcc/cp/

2009-04-10  Jason Merrill  <jason@redhat.com>

	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  <hongjiu.lu@intel.com>

	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
This commit is contained in:
H.J. Lu 2009-04-10 11:56:07 -07:00
parent 6e990b5462
commit 72b75d0333
10 changed files with 45 additions and 9 deletions

View File

@ -1,3 +1,9 @@
2009-04-10 Jason Merrill <jason@redhat.com>
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 <hongjiu.lu@intel.com>
* parser.c (cp_parser_class_specifier): Remove the unused

View File

@ -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;

View File

@ -1,3 +1,13 @@
2009-04-10 H.J. Lu <hongjiu.lu@intel.com>
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 <fu@mips.com>
* gcc.target/mips/interrupt_handler.c: Change from compile to

View File

@ -2,4 +2,4 @@
// { dg-do compile }
// { dg-options "-std=c++0x" }
template<int> enum E : int { e }; // { dg-error "template declaration of" }
template<int> enum E : int { e }; // { dg-error "declaration|expected" }

View File

@ -10,4 +10,4 @@ namespace s
using _List_base<i>::_M_impl;
}
} /* { dg-error "expected unqualified-id before '\}'" } */
s::list<1> OutputModuleListType; /* { dg-error "expected" } */
s::list<1> OutputModuleListType;

View File

@ -4,4 +4,4 @@
// PR c++/18123: ICE pushing tag from invalid template.
template<int> enum E { e }; // { dg-error "template declaration" }
template<int> enum E { e }; // { dg-error "declaration|expected" }

View File

@ -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" }

View File

@ -3,7 +3,7 @@
struct A
{
A(int);
template<int> enum { e }; // { dg-error "template" }
};
template<int> enum { e }; // { dg-error "template|expected" }
}; // { dg-error "expected" }
A a(A::e); // { dg-error "not a member" }
A a(A::e);

View File

@ -0,0 +1,18 @@
// PR c++/28301
// { dg-do compile }
template<typename> struct A
{
template<int> void foo()
}; // { dg-error "initializer" }
template<> struct A<void>
{
template<int> void foo();
};
void bar()
{
A<void> a;
a.foo<0>();
}

View File

@ -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; } };