| 1 |
// RUN: %clang_cc1 -triple i386-unknown-unknown -fsyntax-only -fno-spell-checking -Wno-strict-prototypes -verify %s -fblocks |
| 2 |
|
| 3 |
void invalid_uses(void) { |
| 4 |
struct A { |
| 5 |
}; |
| 6 |
struct A a; |
| 7 |
void *b; |
| 8 |
int (*goodfunc)(const char *, ...); |
| 9 |
int (*badfunc1)(const char *); |
| 10 |
int (*badfunc2)(int, ...); |
| 11 |
int (*badfunc3)(void); |
| 12 |
|
| 13 |
__builtin_dump_struct(); // expected-error {{too few arguments to function call, expected 2, have 0}} |
| 14 |
__builtin_dump_struct(1); // expected-error {{too few arguments to function call, expected 2, have 1}} |
| 15 |
__builtin_dump_struct(1, 2); // expected-error {{expected pointer to struct as 1st argument to '__builtin_dump_struct', found 'int'}} |
| 16 |
__builtin_dump_struct(&a, 2); // expected-error {{expected a callable expression as 2nd argument to '__builtin_dump_struct', found 'int'}} |
| 17 |
__builtin_dump_struct(b, goodfunc); // expected-error {{expected pointer to struct as 1st argument to '__builtin_dump_struct', found 'void *'}} |
| 18 |
__builtin_dump_struct(&a, badfunc1); // expected-error {{too many arguments to function call, expected 1, have 2}} expected-note {{in call to printing function with arguments '("%s", "struct A")'}} |
| 19 |
__builtin_dump_struct(&a, badfunc2); // expected-error-re 1+{{incompatible pointer to integer conversion passing 'char[{{.*}}]' to parameter of type 'int'}} |
| 20 |
// expected-note@-1 1+{{in call to printing function with arguments '("}} |
| 21 |
__builtin_dump_struct(&a, badfunc3); // expected-error {{too many arguments to function call, expected 0, have 2}} expected-note {{in call to printing function with arguments '("%s", "struct A")'}} |
| 22 |
__builtin_dump_struct(a, goodfunc); // expected-error {{expected pointer to struct as 1st argument to '__builtin_dump_struct', found 'struct A'}} |
| 23 |
} |
| 24 |
|
| 25 |
int goodglobalfunc(const char*, ...); |
| 26 |
|
| 27 |
void valid_uses(void) { |
| 28 |
struct A { |
| 29 |
}; |
| 30 |
union B { |
| 31 |
}; |
| 32 |
|
| 33 |
int (*goodfunc)(const char *, ...); |
| 34 |
int (*goodfunc2)(); |
| 35 |
void (*goodfunc3)(const char *, ...); |
| 36 |
int (*goodfunc4)(char *, ...); |
| 37 |
int (^goodblock)(const char*, ...); |
| 38 |
struct A a; |
| 39 |
union B b; |
| 40 |
|
| 41 |
__builtin_dump_struct(&a, goodglobalfunc); |
| 42 |
__builtin_dump_struct(&a, &goodglobalfunc); |
| 43 |
__builtin_dump_struct(&a, goodfunc); |
| 44 |
__builtin_dump_struct(&b, goodfunc); |
| 45 |
__builtin_dump_struct(&a, goodfunc2); |
| 46 |
__builtin_dump_struct(&a, goodfunc3); |
| 47 |
__builtin_dump_struct(&a, goodfunc4); |
| 48 |
__builtin_dump_struct(&a, goodblock); |
| 49 |
} |