From dc3ca06f596b070de7ab337b23d7db22aa25e8fc Mon Sep 17 00:00:00 2001 From: Simon Martin Date: Tue, 25 Sep 2007 18:34:05 +0000 Subject: [PATCH] re PR c++/33207 (ICE redeclaring namespace as struct) gcc/cp/ 2007-09-25 Simon Martin PR c++/33207 * name-lookup.c (pushtag): Do not create an implicit typedef before the associated type declaration is known to be valid. gcc/testsuite/ 2007-09-25 Simon Martin PR c++/33207 * g++.dg/parse/crash38.C: New test. From-SVN: r128769 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/name-lookup.c | 6 +++--- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/parse/crash38.C | 11 +++++++++++ 4 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/parse/crash38.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 991a669d407..b47c802399a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2007-09-25 Simon Martin + + PR c++/33207 + * name-lookup.c (pushtag): Do not create an implicit typedef before + the associated type declaration is known to be valid. + 2007-09-25 Jakub Jelinek * tree.c (cxx_printable_name): Compare FUNCTION_DECL uids diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 5b5e99d76e4..70a395b2f3c 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -4944,9 +4944,6 @@ pushtag (tree name, tree type, tag_scope scope) if (decl == error_mark_node) POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, decl); - if (! in_class) - set_identifier_type_value_with_scope (name, tdef, b); - if (b->kind == sk_class) { if (!PROCESSING_REAL_TEMPLATE_DECL_P ()) @@ -4965,6 +4962,9 @@ pushtag (tree name, tree type, tag_scope scope) POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, decl); } + if (! in_class) + set_identifier_type_value_with_scope (name, tdef, b); + TYPE_CONTEXT (type) = DECL_CONTEXT (decl); /* If this is a local class, keep track of it. We need this diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ed4ce253002..592aba59abf 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-09-25 Simon Martin + + PR c++/33207 + * g++.dg/parse/crash38.C: New test. + 2007-09-25 Michael Meissner PR c/33524 diff --git a/gcc/testsuite/g++.dg/parse/crash38.C b/gcc/testsuite/g++.dg/parse/crash38.C new file mode 100644 index 00000000000..c050b93cc42 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/crash38.C @@ -0,0 +1,11 @@ +/* PR c++/33207 */ + +/* This would not ICE. */ +namespace M { } /* { dg-error "previous declaration" } */ +struct M; /* { dg-error "redeclared as different kind of symbol" } */ +M *p; /* { dg-error "expected constructor" } */ + +/* This would ICE when processing 'p'. */ +namespace N { } /* { dg-error "previous declaration" } */ +struct N; /* { dg-error "redeclared as different kind of symbol" } */ +struct N* p; /* { dg-error "redeclared as different kind of symbol|invalid type" } */ -- 2.30.2