[PATCH] D24113: Allow implicit conversions between incompatible pointer types in overload resolution in C.

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 2 14:56:30 PDT 2016


rsmith accepted this revision.
This revision is now accepted and ready to land.

================
Comment at: lib/Sema/SemaOverload.cpp:1813-1815
@@ -1795,5 +1812,5 @@
   // and we don't know what conversions it may overlap with.
-  SCS.First = ICK_C_Only_Conversion;
-  SCS.Second = ICK_C_Only_Conversion;
-  SCS.Third = ICK_C_Only_Conversion;
+  SCS.First = ImplicitConv;
+  SCS.Second = ImplicitConv;
+  SCS.Third = ImplicitConv;
   return true;
----------------
Yuck, this violates our invariants: `First` should only ever be some kind of lvalue conversion (it should in this case be an `ICK_Array_To_Pointer` or `ICK_Function_To_Pointer` if the argument was an array or function, respectively, and otherwise `ICK_Identity`). `Third` should only ever be `ICK_Identity` or `ICK_Qualification`. It seems fine to always set `Third` to `ICK_Identity` and model the qualification change as part of the second "standard" conversion; this should still compare worse than any other sequence by the rank test.

Now I've noticed this, I'd like to see it fixed, but since this is pre-existing I don't mind whether we fix this as part of this change or separately.

================
Comment at: lib/Sema/SemaOverload.cpp:5931
@@ +5930,3 @@
+          (ConversionState.isStandard() &&
+           ConversionState.Standard.First ==
+               ICK_Incompatible_Pointer_Conversion)) {
----------------
You should check `Second` here rather than `First`.


https://reviews.llvm.org/D24113





More information about the cfe-commits mailing list