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 5395c8544cc0608d83c0194d9a75b8db3bda7cd3..5ba480020551ea284cf971083fcce73cc57b6218 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 44c820a2868fec65e9cc273fff127c366e4164c5..9ea37ef85a481779f2eab4035c25504d86ac24ed 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 c966980940600c342272dc477bd4a45e12ec76cd..22afe9416049125b9b02a385d1b369c47303a089 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 7dd7462c334be46c5d23c9c38a31962af8ad09af..d486efbbaefed3b1c9fc8db4cfb8b59220cb30b8 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 "" } .*
 };