[Bug c++/38174] Missing some built-in candidates for operator overloading

paolo.carlini at oracle dot com gcc-bugzilla@gcc.gnu.org
Thu Oct 13 09:39:00 GMT 2011


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38174

--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-10-13 09:38:57 UTC ---
Thanks Jason, I thought we had to purely *add* overloads. Therefore we'll have
to refactor the code a bit I guess, to always have a single call at the end of
add_builtin_candidate. For the record, yesterday was playing with things like
the below. I hope the additional code eventually will not be *much* more
complex, maybe I will be able to help...

//////////////

Index: call.c
===================================================================
--- call.c    (revision 179867)
+++ call.c    (working copy)
@@ -2582,6 +2582,28 @@
       || MAYBE_CLASS_TYPE_P (type1)
       || TREE_CODE (type1) == ENUMERAL_TYPE))
     {
+      tree type1_type = TREE_TYPE (type1);
+      tree type2_type = TREE_TYPE (type2);
+      
+      if (TYPE_PTR_P (type1) && TYPE_PTR_P (type2)
+      && same_type_p (TYPE_MAIN_VARIANT (type1_type),
+              TYPE_MAIN_VARIANT (type2_type)))
+    {
+      if ((CP_TYPE_CONST_P (type1_type)
+           && CP_TYPE_VOLATILE_P (type2_type))
+          || (CP_TYPE_VOLATILE_P (type1_type)
+          && CP_TYPE_CONST_P (type2_type)))
+        {
+          tree ctype
+        = build_pointer_type
+        (cp_build_qualified_type (TYPE_MAIN_VARIANT (type1_type),
+                      (TYPE_QUAL_CONST
+                       | TYPE_QUAL_VOLATILE)));
+          build_builtin_candidate
+        (candidates, fnname, ctype, ctype, args, argtypes, flags);
+        }
+    }
+
       build_builtin_candidate
     (candidates, fnname, type1, type1, args, argtypes, flags);
       build_builtin_candidate



More information about the Gcc-bugs mailing list