re PR c++/38278 (C++ namespace collision)
authorJason Merrill <jason@redhat.com>
Fri, 28 Nov 2008 21:23:38 +0000 (16:23 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 28 Nov 2008 21:23:38 +0000 (16:23 -0500)
        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
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/lookup/name-clash8.C [new file with mode: 0644]

index e128fe1..c9ce9ce 100644 (file)
@@ -1,3 +1,9 @@
+2008-11-28  Jason Merrill  <jason@redhat.com>
+
+       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  <jason@redhat.com>
 
        PR c++/28743
index 8fdd58c..6870037 100644 (file)
@@ -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;
 }
index 39d4b3a..30d4445 100644 (file)
@@ -1,3 +1,8 @@
+2008-11-28  Jason Merrill  <jason@redhat.com>
+
+       PR c++/38278
+       * g++.dg/lookup/name-clash8.C: New test.
+
 2008-11-28  H.J. Lu  <hongjiu.lu@intel.com>
 
        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 (file)
index 0000000..40c487d
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/38278
+
+struct foo { };
+void bar();
+
+struct baz {
+  static foo (bar)();
+};