blob: 5118e40ab08a1cb9d0250675d5ee3fe8465c5173 [file] [log] [blame]
Douglas Gregor4fc526d2009-02-12 19:25:19 +00001// RUN: clang -fsyntax-only -verify %s
2
3int var __attribute__((overloadable)); // expected-error{{'overloadable' attribute can only be applied to a function}}
4
5int *f(int) __attribute__((overloadable)); // expected-note{{previous overload of function is here}}
6float *f(float); // expected-error{{overloaded function 'f' must have the 'overloadable' attribute}}
7int *f(int); // expected-note{{previous declaration is here}}
8double *f(double) __attribute__((overloadable)); // okay, new
9
10void 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
16int *accept_funcptr(int (*)()) __attribute__((overloadable)); // \
17 // expected-note{{candidate function}}
18float *accept_funcptr(int (*)(int, double)) __attribute__((overloadable)); // \
19 // expected-note{{candidate function}}
20
21void 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
27struct X { int x; float y; };
28struct Y { int x; float y; };
29int* accept_struct(struct X x) __attribute__((overloadable));
30float* accept_struct(struct Y y) __attribute__((overloadable));
31
32void test_struct(struct X x, struct Y y) {
33 int *ip = accept_struct(x);
34 float *fp = accept_struct(y);
35}
36
37double *f(int) __attribute__((overloadable)); // expected-error{{conflicting types for 'f'}}