aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2010-06-07 16:43:01 -0400
committerJason Merrill <jason@gcc.gnu.org>2010-06-07 16:43:01 -0400
commitb0a421e8c1edf21466756f1354a481273c2cb362 (patch)
treedf8ee9a847339e3a9f935f8ffacc112f1a1d8f9b /gcc
parent01628e543b8867e4c4ca5724d4982caae7f0bc1a (diff)
downloadgcc-b0a421e8c1edf21466756f1354a481273c2cb362.zip
gcc-b0a421e8c1edf21466756f1354a481273c2cb362.tar.gz
gcc-b0a421e8c1edf21466756f1354a481273c2cb362.tar.bz2
re PR c++/44401 (Doesn't correctly hide injected class name)
PR c++/44401 * parser.c (cp_parser_lookup_name): Fix naming the constructor. From-SVN: r160399
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog3
-rw-r--r--gcc/cp/parser.c24
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/tc1/dr147.C10
4 files changed, 31 insertions, 11 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 3220230..5f74ab9 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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.
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index eb347e2..92f7786 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -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
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index fd6994a..50afa0d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
diff --git a/gcc/testsuite/g++.dg/tc1/dr147.C b/gcc/testsuite/g++.dg/tc1/dr147.C
index a29986b..6799b7d 100644
--- a/gcc/testsuite/g++.dg/tc1/dr147.C
+++ b/gcc/testsuite/g++.dg/tc1/dr147.C
@@ -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;