re PR c++/37555 (ICE with invalid typedef)

gcc/cp/

2008-09-30  Simon Martin  <simartin@users.sourceforge.net>

	    PR c++/37555
	    PR c++/37556
	    * decl.c (grokdeclarator): Set the type for typedefs to a
	    nested-name-specifier to error_mark_node.

gcc/testsuite/

2008-09-30  Simon Martin  <simartin@users.sourceforge.net>

	    PR c++/37555
	    * g++.dg/parse/error32.C: New test.

	    PR c++/37556
	    * g++.dg/parse/error33.C: New test.

From-SVN: r140794
This commit is contained in:
Simon Martin 2008-09-30 19:25:35 +00:00 committed by Simon Martin
parent 61b70fcb8c
commit dcbdf612f5
5 changed files with 46 additions and 1 deletions

View File

@ -1,3 +1,10 @@
2008-09-30 Simon Martin <simartin@users.sourceforge.net>
PR c++/37555
PR c++/37556
* decl.c (grokdeclarator): Set the type for typedefs to a
nested-name-specifier to error_mark_node.
2008-09-30 Paolo Bonzini <bonzini@gnu.org>
* parser.c (cp_parser_selection_statement): Implement here the

View File

@ -8679,8 +8679,10 @@ grokdeclarator (const cp_declarator *declarator,
decl = build_lang_decl (TYPE_DECL, unqualified_id, type);
else
decl = build_decl (TYPE_DECL, unqualified_id, type);
if (id_declarator && declarator->u.id.qualifying_scope)
if (id_declarator && declarator->u.id.qualifying_scope) {
error ("%Jtypedef name may not be a nested-name-specifier", decl);
TREE_TYPE (decl) = error_mark_node;
}
if (decl_context != FIELD)
{

View File

@ -1,3 +1,11 @@
2008-09-30 Simon Martin <simartin@users.sourceforge.net>
PR c++/37555
* g++.dg/parse/error32.C: New test.
PR c++/37556
* g++.dg/parse/error33.C: New test.
2008-09-30 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/37662

View File

@ -0,0 +1,12 @@
/* PR c++/37555 */
/* { dg-do "compile" } */
struct A {};
typedef void (A::T)(); /* { dg-error "typedef name may not be a nested-name-specifier" } */
void foo()
{
T t;
t; /* { dg-error "was not declared" } */
}

View File

@ -0,0 +1,16 @@
/* PR c++/37556 */
/* { dg-do "compile" } */
struct A
{
void foo();
};
typedef void (A::T)(); /* { dg-error "typedef name may not be a nested" } */
void bar(T); /* { dg-error "too many arguments" } */
void baz()
{
bar(&A::foo); /* { dg-error "at this point" } */
}