From b5a029b139da1b89a13f756b3be4640460850495 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 28 Nov 2008 16:23:38 -0500 Subject: [PATCH] re PR c++/38278 (C++ namespace collision) PR c++/38278 * parser.c (cp_parser_class_name): Only call maybe_note_name_used_in_class if we actually found a class name. From-SVN: r142263 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/parser.c | 7 +++---- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/lookup/name-clash8.C | 8 ++++++++ 4 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/lookup/name-clash8.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e128fe1..c9ce9ce 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2008-11-28 Jason Merrill + + PR c++/38278 + * parser.c (cp_parser_class_name): Only call + maybe_note_name_used_in_class if we actually found a class name. + 2008-11-25 Jason Merrill PR c++/28743 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 8fdd58c..6870037 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -14686,6 +14686,7 @@ cp_parser_class_name (cp_parser *parser, tree scope; bool typename_p; cp_token *token; + tree identifier = NULL_TREE; /* All class-names start with an identifier. */ token = cp_lexer_peek_token (parser->lexer); @@ -14711,7 +14712,6 @@ cp_parser_class_name (cp_parser *parser, && !cp_parser_nth_token_starts_template_argument_list_p (parser, 2)) { cp_token *identifier_token; - tree identifier; bool ambiguous_p; /* Look for the identifier. */ @@ -14767,9 +14767,6 @@ cp_parser_class_name (cp_parser *parser, } return error_mark_node; } - else if (decl != error_mark_node - && !parser->scope) - maybe_note_name_used_in_class (identifier, decl); } } else @@ -14819,6 +14816,8 @@ cp_parser_class_name (cp_parser *parser, if (decl == error_mark_node) cp_parser_error (parser, "expected class-name"); + else if (identifier && !parser->scope) + maybe_note_name_used_in_class (identifier, decl); return decl; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 39d4b3a7..30d4445 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-11-28 Jason Merrill + + PR c++/38278 + * g++.dg/lookup/name-clash8.C: New test. + 2008-11-28 H.J. Lu PR middle-end/37843 diff --git a/gcc/testsuite/g++.dg/lookup/name-clash8.C b/gcc/testsuite/g++.dg/lookup/name-clash8.C new file mode 100644 index 0000000..40c487d --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/name-clash8.C @@ -0,0 +1,8 @@ +// PR c++/38278 + +struct foo { }; +void bar(); + +struct baz { + static foo (bar)(); +}; -- 2.7.4