Douglas Gregor | 4fc526d | 2009-02-12 19:25:19 +0000 | [diff] [blame^] | 1 | // RUN: clang -fsyntax-only -verify %s |
| 2 | |
| 3 | int var __attribute__((overloadable)); // expected-error{{'overloadable' attribute can only be applied to a function}} |
| 4 | |
| 5 | int *f(int) __attribute__((overloadable)); // expected-note{{previous overload of function is here}} |
| 6 | float *f(float); // expected-error{{overloaded function 'f' must have the 'overloadable' attribute}} |
| 7 | int *f(int); // expected-note{{previous declaration is here}} |
| 8 | double *f(double) __attribute__((overloadable)); // okay, new |
| 9 | |
| 10 | void test_f(int iv, float fv, double dv) { |
| 11 | int *ip = f(iv); |
| 12 | float *fp = f(fv); |
| 13 | double *dp = f(dv); |
| 14 | } |
| 15 | |
| 16 | int *accept_funcptr(int (*)()) __attribute__((overloadable)); // \ |
| 17 | // expected-note{{candidate function}} |
| 18 | float *accept_funcptr(int (*)(int, double)) __attribute__((overloadable)); // \ |
| 19 | // expected-note{{candidate function}} |
| 20 | |
| 21 | void test_funcptr(int (*f1)(int, double), |
| 22 | int (*f2)(int, float)) { |
| 23 | float *fp = accept_funcptr(f1); |
| 24 | accept_funcptr(f2); // expected-error{{no matching function for call to 'accept_funcptr'; candidates are:}} |
| 25 | } |
| 26 | |
| 27 | struct X { int x; float y; }; |
| 28 | struct Y { int x; float y; }; |
| 29 | int* accept_struct(struct X x) __attribute__((overloadable)); |
| 30 | float* accept_struct(struct Y y) __attribute__((overloadable)); |
| 31 | |
| 32 | void test_struct(struct X x, struct Y y) { |
| 33 | int *ip = accept_struct(x); |
| 34 | float *fp = accept_struct(y); |
| 35 | } |
| 36 | |
| 37 | double *f(int) __attribute__((overloadable)); // expected-error{{conflicting types for 'f'}} |