diff options
author | George Burgess IV <george.burgess.iv@gmail.com> | 2016-03-23 02:33:58 +0000 |
---|---|---|
committer | George Burgess IV <george.burgess.iv@gmail.com> | 2016-03-23 02:33:58 +0000 |
commit | 6da4c20f7daa6b42205c4642d7672b0c5015ed8f (patch) | |
tree | f1b4a224491b14321d585b9656ed9e23e3187dcd /clang/test/Sema/pass-object-size.c | |
parent | a5b2972977802227e9c3d038819b73dcb011e521 (diff) | |
download | bcm5719-llvm-6da4c20f7daa6b42205c4642d7672b0c5015ed8f.tar.gz bcm5719-llvm-6da4c20f7daa6b42205c4642d7672b0c5015ed8f.zip |
[Sema] Allow implicit conversions of &overloaded_fn in C.
Also includes a minor ``enable_if`` docs update.
Currently, our address-of overload machinery will only allow implicit
conversions of overloaded functions to void* in C. For example:
```
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 (*fp2)(void) = f; // Error. This is C, but the target isn't void*.
```
This patch makes the assignment of `fp2` select the `f(int)` overload,
rather than emitting an error (N.B. you'll still get a warning about the
`fp2` assignment if you use -Wincompatible-pointer-types).
Differential Revision: http://reviews.llvm.org/D13704
llvm-svn: 264132
Diffstat (limited to 'clang/test/Sema/pass-object-size.c')
-rw-r--r-- | clang/test/Sema/pass-object-size.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/clang/test/Sema/pass-object-size.c b/clang/test/Sema/pass-object-size.c index 6f375c0e94d..ddfbbd5fc4e 100644 --- a/clang/test/Sema/pass-object-size.c +++ b/clang/test/Sema/pass-object-size.c @@ -38,8 +38,8 @@ void FunctionPtrs() { void (*p)(void *) = NotOverloaded; //expected-error{{cannot take address of function 'NotOverloaded' because parameter 1 has pass_object_size attribute}} void (*p2)(void *) = &NotOverloaded; //expected-error{{cannot take address of function 'NotOverloaded' because parameter 1 has pass_object_size attribute}} - void (*p3)(void *) = IsOverloaded; //expected-error{{initializing 'void (*)(void *)' with an expression of incompatible type '<overloaded function type>'}} expected-note@-6{{candidate address cannot be taken because parameter 1 has pass_object_size attribute}} expected-note@-5{{type mismatch}} - void (*p4)(void *) = &IsOverloaded; //expected-error{{initializing 'void (*)(void *)' with an expression of incompatible type '<overloaded function type>'}} expected-note@-7{{candidate address cannot be taken because parameter 1 has pass_object_size attribute}} expected-note@-6{{type mismatch}} + void (*p3)(void *) = IsOverloaded; //expected-warning{{incompatible pointer types initializing 'void (*)(void *)' with an expression of type '<overloaded function type>'}} expected-note@-6{{candidate address cannot be taken because parameter 1 has pass_object_size attribute}} expected-note@-5{{type mismatch}} + void (*p4)(void *) = &IsOverloaded; //expected-warning{{incompatible pointer types initializing 'void (*)(void *)' with an expression of type '<overloaded function type>'}} expected-note@-7{{candidate address cannot be taken because parameter 1 has pass_object_size attribute}} expected-note@-6{{type mismatch}} void (*p5)(char *) = IsOverloaded; void (*p6)(char *) = &IsOverloaded; |