]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/38174 (Missing some built-in candidates for operator overloading)
authorPaolo Carlini <paolo.carlini@oracle.com>
Fri, 14 Oct 2011 14:43:03 +0000 (14:43 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Fri, 14 Oct 2011 14:43:03 +0000 (14:43 +0000)
/cp
2011-10-14  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/38174
* call.c (add_builtin_candidate): If two pointers have a composite
pointer type, generate a single candidate with that type.

/testsuite
2011-10-14  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/38174
* g++.dg/overload/operator4.C: New.

From-SVN: r179984

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

index 9a214b57bd9a940a3f9a60aedf9ffc4967a8a8df..aac66d540b418f61a3a073544b0293620bc56206 100644 (file)
@@ -1,3 +1,9 @@
+2011-10-14  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/38174
+       * call.c (add_builtin_candidate): If two pointers have a composite
+       pointer type, generate a single candidate with that type.
+
 2011-10-13  Jason Merrill  <jason@redhat.com>
 
        PR c++/50614
index 7219afe8f59e41ce43bf7ba0451ea1f8f787d5d9..7e87bdfea02689b1400075a5a61a861e7b197151 100644 (file)
@@ -2582,6 +2582,21 @@ add_builtin_candidate (struct z_candidate **candidates, enum tree_code code,
          || MAYBE_CLASS_TYPE_P (type1)
          || TREE_CODE (type1) == ENUMERAL_TYPE))
     {
+      if (TYPE_PTR_P (type1) || TYPE_PTR_TO_MEMBER_P (type1))
+       {
+         tree cptype = composite_pointer_type (type1, type2,
+                                               error_mark_node,
+                                               error_mark_node,
+                                               CPO_CONVERSION,
+                                               tf_none);
+         if (cptype != error_mark_node)
+           {
+             build_builtin_candidate
+               (candidates, fnname, cptype, cptype, args, argtypes, flags);
+             return;
+           }
+       }
+
       build_builtin_candidate
        (candidates, fnname, type1, type1, args, argtypes, flags);
       build_builtin_candidate
index 2a475abc0e8fab40cc9e814d46b01294022d412a..e04f5277d0273e0a4a3f3e7d7b4d9f405c21bd4d 100644 (file)
@@ -1,3 +1,8 @@
+2011-10-14  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/38174
+       * g++.dg/overload/operator4.C: New.
+
 2011-10-14  David Alan Gilbert  <david.gilbert@linaro.org>
 
        * gcc.dg/di-longlong64-sync-1.c: New test.
diff --git a/gcc/testsuite/g++.dg/overload/operator4.C b/gcc/testsuite/g++.dg/overload/operator4.C
new file mode 100644 (file)
index 0000000..3ec1eb4
--- /dev/null
@@ -0,0 +1,14 @@
+// PR c++/38174
+
+struct VolatileIntPtr {
+  operator int volatile *();
+};
+
+struct ConstIntPtr {
+  operator int const *();
+};
+
+void test_with_ptrs(VolatileIntPtr vip, ConstIntPtr cip) {
+  bool b1 = (vip == cip);
+  long p1 = vip - cip;
+}