re PR c++/14668 (no warning anymore for reevaluation of declaration)
authorMark Mitchell <mark@codesourcery.com>
Fri, 28 May 2004 20:17:18 +0000 (20:17 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Fri, 28 May 2004 20:17:18 +0000 (20:17 +0000)
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

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/lookup/redecl1.C [new file with mode: 0644]
gcc/testsuite/g++.old-deja/g++.benjamin/tem04.C

index 5395c85..5ba4800 100644 (file)
@@ -1,3 +1,9 @@
+2004-05-28  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/14668
+       * parser.c (cp_parser_simple_type_specifier): Call
+       maybe_note_name_used_in_class.
+
 2004-05-28  Tom Marshall  <tmarshall@real.com>
 
        PR c++/15214
index 44c820a..9ea37ef 100644 (file)
@@ -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))
index c966980..22afe94 100644 (file)
@@ -1,3 +1,9 @@
+2004-05-28  Mark Mitchell  <mark@codesourcery.com>
+
+       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  <bonzini@gnu.org>
 
        * 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 (file)
index 0000000..436316c
--- /dev/null
@@ -0,0 +1,7 @@
+// PR c++/14668
+
+class A {}; // { dg-error "" }
+class B { 
+  static A *A; // { dg-error "" }
+}; 
+A *B::A = 0;
index 7dd7462..d486efb 100644 (file)
@@ -91,7 +91,7 @@ public:
 template <typename T14, template <typename T15> class C12>// { dg-error "" } .*
 class Xeighteen {
 protected:
-  C12<T14> value;
+  C12<T14> value; // { dg-error "" }
   int C12; // { dg-error "" } .*
 };