re PR c++/18731 (ICE on invalid template declaration)

PR c++/18731
	* parser.c (cp_parser_class_head): Reject typedef-name in class head.

	* g++.dg/parser/struct-1.C: New test.
	* g++.dg/parser/struct-2.C: New test.
	* g++.dg/parser/struct-3.C: New test.

From-SVN: r91993
This commit is contained in:
Volker Reichelt 2004-12-10 16:04:22 +00:00 committed by Volker Reichelt
parent 417c735c22
commit 9bf0e5888c
6 changed files with 42 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2004-12-10 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/18731
* parser.c (cp_parser_class_head): Reject typedef-name in class head.
2004-12-09 Matt Austern <austern@apple.com>
PR c++/18514

View File

@ -12620,6 +12620,15 @@ cp_parser_class_head (cp_parser* parser,
else if (nested_name_specifier)
{
tree scope;
/* Reject typedef-names in class heads. */
if (!DECL_IMPLICIT_TYPEDEF_P (type))
{
error ("invalid class name in declaration of %qD", type);
type = NULL_TREE;
goto done;
}
/* Figure out in what scope the declaration is being placed. */
scope = current_scope ();
/* If that scope does not contain the scope in which the

View File

@ -1,3 +1,10 @@
2004-12-10 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/18731
* g++.dg/parser/struct-1.C: New test.
* g++.dg/parser/struct-2.C: New test.
* g++.dg/parser/struct-3.C: New test.
2004-12-09 Richard Henderson <rth@redhat.com>
* gcc.dg/loop-3.c: Don't use i386 tuning for amd64.

View File

@ -0,0 +1,4 @@
// Origin: Volker Reichelt <reichelt@igpm.rwth-aachen.de>
// PR c++/18731
template<typename T> struct T::A {}; // { dg-error "invalid class name" }

View File

@ -0,0 +1,7 @@
// Origin: Volker Reichelt <reichelt@igpm.rwth-aachen.de>
// PR c++/18731
template<typename T> struct A
{
struct T::B {}; // { dg-error "invalid class name" }
};

View File

@ -0,0 +1,10 @@
// Origin: Volker Reichelt <reichelt@igpm.rwth-aachen.de>
// PR c++/18731
struct A
{
struct B;
typedef B C;
};
struct A::C {}; // { dg-error "invalid class name" }