OSDN Git Service

PR c++/44401
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 7 Jun 2010 20:43:01 +0000 (20:43 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 7 Jun 2010 20:43:01 +0000 (20:43 +0000)
* parser.c (cp_parser_lookup_name): Fix naming the constructor.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160399 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/tc1/dr147.C

index 3220230..5f74ab9 100644 (file)
@@ -1,5 +1,8 @@
 2010-06-07  Jason Merrill  <jason@redhat.com>
 
+       PR c++/44401
+       * parser.c (cp_parser_lookup_name): Fix naming the constructor.
+
        * cp-tree.h (COMPLETE_OR_OPEN_TYPE_P): New macro.
        * init.c (build_offset_ref): Use it.
        * pt.c (maybe_process_partial_specialization): Use it.
index eb347e2..92f7786 100644 (file)
@@ -18365,6 +18365,14 @@ cp_parser_lookup_name (cp_parser *parser, tree name,
          if (dependent_p)
            pushed_scope = push_scope (parser->scope);
 
+         /* If the PARSER->SCOPE is a template specialization, it
+            may be instantiated during name lookup.  In that case,
+            errors may be issued.  Even if we rollback the current
+            tentative parse, those errors are valid.  */
+         decl = lookup_qualified_name (parser->scope, name,
+                                       tag_type != none_type,
+                                       /*complain=*/true);
+
          /* 3.4.3.1: In a lookup in which the constructor is an acceptable
             lookup result and the nested-name-specifier nominates a class C:
               * if the name specified after the nested-name-specifier, when
@@ -18380,17 +18388,11 @@ cp_parser_lookup_name (cp_parser *parser, tree name,
             shall be used only in the declarator-id of a declaration that
             names a constructor or in a using-declaration.  */
          if (tag_type == none_type
-             && CLASS_TYPE_P (parser->scope)
-             && constructor_name_p (name, parser->scope))
-           name = ctor_identifier;
-
-         /* If the PARSER->SCOPE is a template specialization, it
-            may be instantiated during name lookup.  In that case,
-            errors may be issued.  Even if we rollback the current
-            tentative parse, those errors are valid.  */
-         decl = lookup_qualified_name (parser->scope, name,
-                                       tag_type != none_type,
-                                       /*complain=*/true);
+             && DECL_SELF_REFERENCE_P (decl)
+             && same_type_p (DECL_CONTEXT (decl), parser->scope))
+           decl = lookup_qualified_name (parser->scope, ctor_identifier,
+                                         tag_type != none_type,
+                                         /*complain=*/true);
 
          /* If we have a single function from a using decl, pull it out.  */
          if (TREE_CODE (decl) == OVERLOAD
index fd6994a..50afa0d 100644 (file)
@@ -1,3 +1,8 @@
+2010-06-07  Jason Merrill  <jason@redhat.com>
+
+       PR c++/44401
+       * g++.dg/tc1/dr147.C: Test case of member with same name as class.
+
 2010-06-07  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/44444
index a29986b..6799b7d 100644 (file)
@@ -54,3 +54,13 @@ struct D: C::C
 {
   D(): C::C() { }
 };
+
+// And if lookup doesn't find the injected-class-name, we aren't naming the
+// constructor (c++/44401).
+
+struct E
+{
+  int E;
+};
+
+int E::*p = &E::E;