summaryrefslogtreecommitdiff
path: root/gcc/cp/name-lookup.c
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2010-06-02 19:19:05 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2010-06-02 19:19:05 +0000
commit64b38a2dbbd15dd0045feef5b9c3aaec891bf89c (patch)
treeb24cda1627e0891a6edcb0d288406810ab3fdbdb /gcc/cp/name-lookup.c
parentc8d16950a40ed367dcb96c728279f28ef23045c2 (diff)
downloadgcc-64b38a2dbbd15dd0045feef5b9c3aaec891bf89c.tar.gz
PR c++/44333
* name-lookup.c (same_entity_p): New. (ambiguous_decl): Multiple declarations of the same entity are not ambiguous. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160183 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/name-lookup.c')
-rw-r--r--gcc/cp/name-lookup.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 051d3c5416a..936c25638e0 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -3698,6 +3698,31 @@ merge_functions (tree s1, tree s2)
return s1;
}
+/* Returns TRUE iff OLD and NEW are the same entity.
+
+ 3 [basic]/3: An entity is a value, object, reference, function,
+ enumerator, type, class member, template, template specialization,
+ namespace, parameter pack, or this.
+
+ 7.3.4 [namespace.udir]/4: If name lookup finds a declaration for a name
+ in two different namespaces, and the declarations do not declare the
+ same entity and do not declare functions, the use of the name is
+ ill-formed. */
+
+static bool
+same_entity_p (tree one, tree two)
+{
+ if (one == two)
+ return true;
+ if (!one || !two)
+ return false;
+ if (TREE_CODE (one) == TYPE_DECL
+ && TREE_CODE (two) == TYPE_DECL
+ && same_type_p (TREE_TYPE (one), TREE_TYPE (two)))
+ return true;
+ return false;
+}
+
/* This should return an error not all definitions define functions.
It is not an error if we find two functions with exactly the
same signature, only if these are selected in overload resolution.
@@ -3763,7 +3788,7 @@ ambiguous_decl (struct scope_binding *old, cxx_binding *new_binding, int flags)
if (!old->value)
old->value = val;
- else if (val && val != old->value)
+ else if (val && !same_entity_p (val, old->value))
{
if (is_overloaded_fn (old->value) && is_overloaded_fn (val))
old->value = merge_functions (old->value, val);