]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c++/44333
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 2 Jun 2010 19:19:05 +0000 (19:19 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 2 Jun 2010 19:19:05 +0000 (19:19 +0000)
* 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

gcc/cp/ChangeLog
gcc/cp/name-lookup.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/tc1/dr101.C

index f17c735d55d05a3185f5f6382c9b79f8e098c506..8b883e7656e772fc92ac98abd154053bf6ff5c84 100644 (file)
@@ -1,3 +1,12 @@
+2010-06-02  Jason Merrill  <jason@redhat.com>
+
+       PR c++/9726
+       PR c++/23594
+       PR c++/44333
+       * name-lookup.c (same_entity_p): New.
+       (ambiguous_decl): Multiple declarations of the same entity
+       are not ambiguous.
+
 2010-06-01  Jason Merrill  <jason@redhat.com>
 
        DR 990
index 051d3c5416adf6de5df798aafeb50ae8b56a1696..936c25638e0bba3141d5adcb3d2cfe77611d8f18 100644 (file)
@@ -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);
index 21ab458f643f9189fdb05f7c1ef11dcbff4a8e58..dba6f87bb4a1c878f4fef0f6a05601b2d9a73da8 100644 (file)
@@ -1,3 +1,10 @@
+2010-06-02  Jason Merrill  <jason@redhat.com>
+
+       PR c++/9726
+       PR c++/23594
+       PR c++/44333
+       * g++.dg/tc1/dr101.C: Remove xfails.
+
 2010-06-02  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR middle-end/44372
index c5b34a472a98611ab26dacb9d3f28d21e586ceb8..0316aaaa77d30107d6d02e657660dcfb65f56ac1 100644 (file)
@@ -17,15 +17,14 @@ namespace Test1 {
 
 namespace Test2 {
 
-  typedef unsigned int X;   // { dg-bogus "X" "" { xfail *-*-* } }
+  typedef unsigned int X;   // { dg-bogus "X" "" }
   extern "C" int f2();
   namespace N {
-    typedef unsigned int X; // { dg-bogus "X" "" { xfail *-*-* } }
+    typedef unsigned int X; // { dg-bogus "X" "" }
     extern "C" int f2();
   }
   using namespace N;
   int i = f2(); // { dg-bogus "" "redeclaration through 'using' should not be ambiguous" }
-  X x;          // { dg-bogus "" "redeclaration through 'using' should not be ambiguous" { xfail *-*-* } }
+  X x;          // { dg-bogus "" "redeclaration through 'using' should not be ambiguous" }
 
 }
-