diff options
Diffstat (limited to 'test/Sema/overloadable.c')
-rw-r--r-- | test/Sema/overloadable.c | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/test/Sema/overloadable.c b/test/Sema/overloadable.c index 5d95a317fa38..f5e17d211910 100644 --- a/test/Sema/overloadable.c +++ b/test/Sema/overloadable.c @@ -23,7 +23,7 @@ float *accept_funcptr(int (*)(int, double)) __attribute__((overloadable)); // \ void test_funcptr(int (*f1)(int, double), int (*f2)(int, float)) { float *fp = accept_funcptr(f1); - accept_funcptr(f2); // expected-error{{no matching function for call to 'accept_funcptr'}} + accept_funcptr(f2); // expected-error{{call to 'accept_funcptr' is ambiguous}} } struct X { int x; float y; }; @@ -109,7 +109,7 @@ void fn_type_conversions() { void (*ambiguous)(int *) = &foo; // expected-error{{initializing 'void (*)(int *)' with an expression of incompatible type '<overloaded function type>'}} expected-note@105{{candidate function}} expected-note@106{{candidate function}} void *vp_ambiguous = &foo; // expected-error{{initializing 'void *' with an expression of incompatible type '<overloaded function type>'}} expected-note@105{{candidate function}} expected-note@106{{candidate function}} - void (*specific1)(int *) = (void (*)(void *))&foo; // expected-warning{{incompatible pointer types initializing 'void (*)(int *)' with an expression of type 'void (*)(void *)'}} + void (*specific1)(int *) = (void (*)(void *))&foo; // expected-warning{{incompatible function pointer types initializing 'void (*)(int *)' with an expression of type 'void (*)(void *)'}} void *specific2 = (void (*)(void *))&foo; void disabled(void *c) __attribute__((overloadable, enable_if(0, ""))); @@ -122,3 +122,32 @@ void fn_type_conversions() { void *specific_disabled = &disabled; } + +void incompatible_pointer_type_conversions() { + char charbuf[1]; + unsigned char ucharbuf[1]; + int intbuf[1]; + + void foo(char *c) __attribute__((overloadable)); + void foo(short *c) __attribute__((overloadable)); + foo(charbuf); + foo(ucharbuf); // expected-error{{call to 'foo' is ambiguous}} expected-note@131{{candidate function}} expected-note@132{{candidate function}} + foo(intbuf); // expected-error{{call to 'foo' is ambiguous}} expected-note@131{{candidate function}} expected-note@132{{candidate function}} + + void bar(unsigned char *c) __attribute__((overloadable)); + void bar(signed char *c) __attribute__((overloadable)); + bar(charbuf); // expected-error{{call to 'bar' is ambiguous}} expected-note@137{{candidate function}} expected-note@138{{candidate function}} + bar(ucharbuf); + bar(intbuf); // expected-error{{call to 'bar' is ambiguous}} expected-note@137{{candidate function}} expected-note@138{{candidate function}} +} + +void dropping_qualifiers_is_incompatible() { + const char ccharbuf[1]; + volatile char vcharbuf[1]; + + void foo(char *c) __attribute__((overloadable)); + void foo(const volatile unsigned char *c) __attribute__((overloadable)); + + foo(ccharbuf); // expected-error{{call to 'foo' is ambiguous}} expected-note@148{{candidate function}} expected-note@149{{candidate function}} + foo(vcharbuf); // expected-error{{call to 'foo' is ambiguous}} expected-note@148{{candidate function}} expected-note@149{{candidate function}} +} |