1 // RUN: %clang_cc1 -triple i386-unknown-unknown -fsyntax-only -fno-spell-checking -verify %s
2 
invalid_uses()3 void invalid_uses() {
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   void (*badfunc3)(const char *, ...);
12   int (*badfunc4)(char *, ...);
13   int (*badfunc5)(void);
14 
15   __builtin_dump_struct();             // expected-error {{too few arguments to function call, expected 2, have 0}}
16   __builtin_dump_struct(1);            // expected-error {{too few arguments to function call, expected 2, have 1}}
17   __builtin_dump_struct(1, 2);         // expected-error {{passing 'int' to parameter of incompatible type structure pointer: type mismatch at 1st parameter ('int' vs structure pointer)}}
18   __builtin_dump_struct(&a, 2);        // expected-error {{passing 'int' to parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 2nd parameter ('int' vs 'int (*)(const char *, ...)')}}
19   __builtin_dump_struct(b, goodfunc); // expected-error {{passing 'void *' to parameter of incompatible type structure pointer: type mismatch at 1st parameter ('void *' vs structure pointer)}}
20   __builtin_dump_struct(&a, badfunc1); // expected-error {{passing 'int (*)(const char *)' to parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 2nd parameter ('int (*)(const char *)' vs 'int (*)(const char *, ...)')}}
21   __builtin_dump_struct(&a, badfunc2); // expected-error {{passing 'int (*)(int, ...)' to parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 2nd parameter ('int (*)(int, ...)' vs 'int (*)(const char *, ...)')}}
22   __builtin_dump_struct(&a, badfunc3); // expected-error {{passing 'void (*)(const char *, ...)' to parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 2nd parameter ('void (*)(const char *, ...)' vs 'int (*)(const char *, ...)')}}
23   __builtin_dump_struct(&a, badfunc4); // expected-error {{passing 'int (*)(char *, ...)' to parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 2nd parameter ('int (*)(char *, ...)' vs 'int (*)(const char *, ...)')}}
24   __builtin_dump_struct(&a, badfunc5); // expected-error {{passing 'int (*)(void)' to parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 2nd parameter ('int (*)(void)' vs 'int (*)(const char *, ...)')}}
25   __builtin_dump_struct(a, goodfunc);  // expected-error {{passing 'struct A' to parameter of incompatible type structure pointer: type mismatch at 1st parameter ('struct A' vs structure pointer)}}
26 }
27 
valid_uses()28 void valid_uses() {
29   struct A {
30   };
31   union B {
32   };
33 
34   int (*goodfunc)(const char *, ...);
35   int (*goodfunc2)();
36   struct A a;
37   union B b;
38 
39   __builtin_dump_struct(&a, goodfunc);
40   __builtin_dump_struct(&b, goodfunc);
41   __builtin_dump_struct(&a, goodfunc2);
42 }
43