From: Mark Mitchell Date: Fri, 28 May 2004 20:17:18 +0000 (+0000) Subject: re PR c++/14668 (no warning anymore for reevaluation of declaration) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0c1a1ecd8062d98df568b076d71868cb022ccc50;p=gcc.git re PR c++/14668 (no warning anymore for reevaluation of declaration) PR c++/14668 * parser.c (cp_parser_simple_type_specifier): Call maybe_note_name_used_in_class. PR c++/14668 * g++.dg/lookup/redecl1.C: New test. * g++.old-deja/g++.benjamin/tem04.C: Add error marker. From-SVN: r82375 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5395c8544cc..5ba48002055 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2004-05-28 Mark Mitchell + + PR c++/14668 + * parser.c (cp_parser_simple_type_specifier): Call + maybe_note_name_used_in_class. + 2004-05-28 Tom Marshall PR c++/15214 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 44c820a2868..9ea37ef85a4 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -8944,6 +8944,8 @@ cp_parser_simple_type_specifier (cp_parser* parser, cp_parser_flags flags, /* The type-specifier must be a user-defined type. */ if (!(flags & CP_PARSER_FLAGS_NO_USER_DEFINED_TYPES)) { + bool qualified_p; + /* Don't gobble tokens or issue error messages if this is an optional type-specifier. */ if (flags & CP_PARSER_FLAGS_OPTIONAL) @@ -8953,11 +8955,12 @@ cp_parser_simple_type_specifier (cp_parser* parser, cp_parser_flags flags, cp_parser_global_scope_opt (parser, /*current_scope_valid_p=*/false); /* Look for the nested-name specifier. */ - cp_parser_nested_name_specifier_opt (parser, - /*typename_keyword_p=*/false, - /*check_dependency_p=*/true, - /*type_p=*/false, - /*is_declaration=*/false); + qualified_p + = (cp_parser_nested_name_specifier_opt (parser, + /*typename_keyword_p=*/false, + /*check_dependency_p=*/true, + /*type_p=*/false, + /*is_declaration=*/false)); /* If we have seen a nested-name-specifier, and the next token is `template', then we are using the template-id production. */ if (parser->scope @@ -8979,6 +8982,12 @@ cp_parser_simple_type_specifier (cp_parser* parser, cp_parser_flags flags, /* Otherwise, look for a type-name. */ else type = cp_parser_type_name (parser); + /* Keep track of all name-lookups performed in class scopes. */ + if (type + && !qualified_p + && TREE_CODE (type) == TYPE_DECL + && TREE_CODE (DECL_NAME (type)) == IDENTIFIER_NODE) + maybe_note_name_used_in_class (DECL_NAME (type), type); /* If it didn't work out, we don't have a TYPE. */ if ((flags & CP_PARSER_FLAGS_OPTIONAL) && !cp_parser_parse_definitely (parser)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c9669809406..22afe941604 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2004-05-28 Mark Mitchell + + PR c++/14668 + * g++.dg/lookup/redecl1.C: New test. + * g++.old-deja/g++.benjamin/tem04.C: Add error marker. + 2004-05-28 Paolo Bonzini * gcc.c-torture/compare-fp-1.c, gcc.c-torture/compare-fp-2.c, diff --git a/gcc/testsuite/g++.dg/lookup/redecl1.C b/gcc/testsuite/g++.dg/lookup/redecl1.C new file mode 100644 index 00000000000..436316ca070 --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/redecl1.C @@ -0,0 +1,7 @@ +// PR c++/14668 + +class A {}; // { dg-error "" } +class B { + static A *A; // { dg-error "" } +}; +A *B::A = 0; diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/tem04.C b/gcc/testsuite/g++.old-deja/g++.benjamin/tem04.C index 7dd7462c334..d486efbbaef 100644 --- a/gcc/testsuite/g++.old-deja/g++.benjamin/tem04.C +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/tem04.C @@ -91,7 +91,7 @@ public: template class C12>// { dg-error "" } .* class Xeighteen { protected: - C12 value; + C12 value; // { dg-error "" } int C12; // { dg-error "" } .* };