[PATCH] D13704: [Fix] Allow implicit conversions of the address of overloadable functions in C + docs update

George Burgess IV via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 22 19:39:04 PDT 2016


george.burgess.iv marked 3 inline comments as done.

================
Comment at: lib/Sema/SemaOverload.cpp:10419
@@ -10418,3 +10429,1 @@
-                                 ResultTy) ||
-          (!S.getLangOpts().CPlusPlus && TargetType->isVoidPointerType())) {
         Matches.push_back(std::make_pair(
----------------
rsmith wrote:
> george.burgess.iv wrote:
> > rsmith wrote:
> > > Why is the `void*` check removed from this case? Note that clang and GCC intentionally treat these two cases differently today:
> > > 
> > >     int f();
> > >     void *p = f; // ok (warning under -pedantic)
> > >     int *q = f; // warning: incompatible pointer types
> > > 
> > > (That is: the first is a silent-by-default extension and the second is a warn-by-default extension.)
> > Because this is overload resolution logic, so we shouldn't care about what warnings we will emit :)
> > 
> > This is how we act prior to applying this patch:
> > 
> > ```
> > void f(int) __attribute__((overloadable));
> > void f(double) __attribute__((overloadable, enable_if(0, "")));
> > 
> > void *fp = f; // OK. This is C and the target is void*.
> > void (*fp)(void) = f; // Error. This is C, but the target isn't void*.
> > ```
> > 
> > I'm simply removing the "the target must be a `void*`" restriction; the user should still get warnings in the latter case (the tests changed in test/Sema/pass-object-size.c make sure of this).
> OK, this seems fine so long as we somewhere choose exact matches over inexact ones:
> 
>     void f(int) __attribute__((overloadable));
>     void f(int, int) __attribute__((overloadable));
>     void g(void (*)(int));
>     void h() { g(f); } // should pick f(int)
We do; the tests in test/CodeGen/overloadable.c make sure of this -- thanks for the review! :)


http://reviews.llvm.org/D13704





More information about the cfe-commits mailing list