Two smallish patches in one. Happy to split into two (for review and/or commit) if that's preferred.
In C, we allow (as an extension) incompatible pointer conversions, like so:
int foo(int *); int (*p)(void *) = foo; // Compiles; warns if -Wincompatible-pointer-types is specified
So, we should provide primitive support for this with overloadable functions. Specifically, this patch is trying to fix cases like this:
int foo(void *) __attribute__((overloadable)); int foo(double *d) __attribute__((overloadable, enable_if(d != nullptr, ""))); int (*p)(int *) = foo; // Before patch, error because we couldn't match the function type exactly. After patch, we see that 'int foo(void *)' is the only option, and choose it. A warning is emitted if -Wincompatible-pointer-types is given
Which means that explicit casts are necessary if there's more than one overload that isn't disabled by enable_if attrs. The updated docs have an example of this, but here's another:
int foo(void *) __attribute__((overloadable)); int foo(double *d) __attribute__((overloadable)); int (*p)(int *) = foo; // 0 candidates before patch, 2 after. Won't compile either way. int (*p2)(int *) = (int (*)(void *))foo; // OK. Issues warning if -Wincompatible-pointer-types is given