re PR c++/32756 (wrong ambiguous overload error?)
authorNathan Sidwell <nathan@codesourcery.com>
Sun, 16 Sep 2007 17:26:42 +0000 (17:26 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Sun, 16 Sep 2007 17:26:42 +0000 (17:26 +0000)
cp/
PR c++/32756
* call.c (maybe_handle_implicit_object): Set this_p, clear
rvaluedness_matches_p.
(compare_ics): Do not compare rvaluedness matching when one of the
operands is an implicit object.

testsuite/
PR c++/32756
* g++.dg/overload/operator3.C: New.

From-SVN: r128528

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/overload/operator3.C [new file with mode: 0644]

index 26028a520c120943cfd98995e464a734c47b3ad2..6e8a8b9e5b910836ad1571283ae65e432ff9f35a 100644 (file)
@@ -1,3 +1,16 @@
+2007-09-16  Nathan Sidwell  <nathan@codesourcery.com>
+
+       cp/
+       PR c++/32756
+       * call.c (maybe_handle_implicit_object): Set this_p, clear
+       rvaluedness_matches_p.
+       (compare_ics): Do not compare rvaluedness matching when one of the
+       operands is an implicit object.
+
+       testsuite/
+       PR c++/32756
+       * g++.dg/overload/operator3.C: New.
+
 2007-09-14  Jason Merrill  <jason@redhat.com>
 
        PR c++/17743, c++/19163
index dd41b9d8168fb91bacbc5b3dba5f165cea8f3655..dc90d1952e10d94e3d183fb4d1c5301b7fc97ce9 100644 (file)
@@ -5767,7 +5767,8 @@ maybe_handle_implicit_object (conversion **ics)
        t = t->u.next;
       t = build_identity_conv (TREE_TYPE (t->type), NULL_TREE);
       t = direct_reference_binding (reference_type, t);
-      t->rvaluedness_matches_p = 1;
+      t->this_p = 1;
+      t->rvaluedness_matches_p = 0;
       *ics = t;
     }
 }
@@ -6126,18 +6127,21 @@ compare_ics (conversion *ics1, conversion *ics2)
      initialized by S2 refers is more cv-qualified than the type to
      which the reference initialized by S1 refers */
 
-  if (ref_conv1 && ref_conv2
-      && same_type_ignoring_top_level_qualifiers_p (to_type1, to_type2))
+  if (ref_conv1 && ref_conv2)
     {
-      if (ref_conv1->rvaluedness_matches_p
-         && !ref_conv2->rvaluedness_matches_p)
-       return 1;
-      else if (!ref_conv1->rvaluedness_matches_p
-         && ref_conv2->rvaluedness_matches_p)
-       return -1;
+      if (!ref_conv1->this_p && !ref_conv2->this_p
+         && (TYPE_REF_IS_RVALUE (ref_conv1->type)
+             != TYPE_REF_IS_RVALUE (ref_conv2->type)))
+       {
+         if (ref_conv1->rvaluedness_matches_p)
+           return 1;
+         if (ref_conv2->rvaluedness_matches_p)
+           return -1;
+       }
 
-      return comp_cv_qualification (TREE_TYPE (ref_conv2->type),
-                                   TREE_TYPE (ref_conv1->type));
+      if (same_type_ignoring_top_level_qualifiers_p (to_type1, to_type2))
+       return comp_cv_qualification (TREE_TYPE (ref_conv2->type),
+                                     TREE_TYPE (ref_conv1->type));
     }
 
   /* Neither conversion sequence is better than the other.  */
index 0721c01858e6b1b023fea696bcdf76800f5cadbc..d99cdad19416c098f14444226c4a2bfd50631f64 100644 (file)
@@ -1,3 +1,8 @@
+2007-09-16  Nathan Sidwell  <nathan@codesourcery.com>
+
+       PR c++/32756
+       * g++.dg/overload/operator3.C: New.
+
 2007-09-16  Richard Sandiford  <rsandifo@nildram.co.uk>
 
        * gcc.target/mips/truncate-1.c: New test.
diff --git a/gcc/testsuite/g++.dg/overload/operator3.C b/gcc/testsuite/g++.dg/overload/operator3.C
new file mode 100644 (file)
index 0000000..ff56967
--- /dev/null
@@ -0,0 +1,31 @@
+// PR c++/32756
+// { dg-do compile }
+
+// bogus overload warning
+
+class QString;
+
+struct QByteArray
+{
+  QByteArray ();
+  bool operator!= (const QString & s2) const;
+};
+
+bool operator!= (const QByteArray & a1, const QByteArray & a2);
+
+struct QString
+{
+  QString ();
+  QString (const QByteArray & a);
+};
+
+QByteArray abbreviation ();
+
+void
+fromString ()
+{
+  QByteArray zoneAbbrev;
+  if (abbreviation () != zoneAbbrev)
+    {
+    }
+}