Commit 9bf0e588 by Volker Reichelt Committed by Volker Reichelt

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
parent 417c735c
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> 2004-12-09 Matt Austern <austern@apple.com>
PR c++/18514 PR c++/18514
......
...@@ -12620,6 +12620,15 @@ cp_parser_class_head (cp_parser* parser, ...@@ -12620,6 +12620,15 @@ cp_parser_class_head (cp_parser* parser,
else if (nested_name_specifier) else if (nested_name_specifier)
{ {
tree scope; 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. */ /* Figure out in what scope the declaration is being placed. */
scope = current_scope (); scope = current_scope ();
/* If that scope does not contain the scope in which the /* If that scope does not contain the scope in which the
......
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> 2004-12-09 Richard Henderson <rth@redhat.com>
* gcc.dg/loop-3.c: Don't use i386 tuning for amd64. * gcc.dg/loop-3.c: Don't use i386 tuning for amd64.
......
// Origin: Volker Reichelt <reichelt@igpm.rwth-aachen.de>
// PR c++/18731
template<typename T> struct T::A {}; // { dg-error "invalid class name" }
// Origin: Volker Reichelt <reichelt@igpm.rwth-aachen.de>
// PR c++/18731
template<typename T> struct A
{
struct T::B {}; // { dg-error "invalid class name" }
};
// 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" }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment