1 // RUN: %clang_cc1 -triple i386-unknown-unknown -fsyntax-only -fno-spell-checking -Wno-strict-prototypes -verify %s -fblocks
3 void invalid_uses(void) {
8 int (*goodfunc
)(const char *, ...);
9 int (*badfunc1
)(const char *);
10 int (*badfunc2
)(int, ...);
11 int (*badfunc3
)(void);
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'}}
25 int goodglobalfunc(const char*, ...);
27 void valid_uses(void) {
33 int (*goodfunc
)(const char *, ...);
35 void (*goodfunc3
)(const char *, ...);
36 int (*goodfunc4
)(char *, ...);
37 int (^goodblock
)(const char*, ...);
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
);