xref: /minix3/external/bsd/llvm/dist/clang/test/Sema/declspec.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -verify -fsyntax-only
2*f4a2713aSLionel Sambuc typedef char T[4];
3*f4a2713aSLionel Sambuc 
foo(int n,int m)4*f4a2713aSLionel Sambuc T foo(int n, int m) {  }  // expected-error {{cannot return array type}}
5*f4a2713aSLionel Sambuc 
6*f4a2713aSLionel Sambuc void foof(const char *, ...) __attribute__((__format__(__printf__, 1, 2))), barf (void);
7*f4a2713aSLionel Sambuc 
8*f4a2713aSLionel Sambuc int typedef validTypeDecl() { } // expected-error {{function definition declared 'typedef'}}
9*f4a2713aSLionel Sambuc 
10*f4a2713aSLionel Sambuc struct _zend_module_entry { }    // expected-error {{expected ';' after struct}}
11*f4a2713aSLionel Sambuc int gv1;
12*f4a2713aSLionel Sambuc typedef struct _zend_function_entry { } // expected-error {{expected ';' after struct}} \
13*f4a2713aSLionel Sambuc                                         // expected-warning {{typedef requires a name}}
14*f4a2713aSLionel Sambuc int gv2;
15*f4a2713aSLionel Sambuc 
buggy(int * x)16*f4a2713aSLionel Sambuc static void buggy(int *x) { }
17*f4a2713aSLionel Sambuc 
18*f4a2713aSLionel Sambuc // Type qualifiers.
19*f4a2713aSLionel Sambuc typedef int f(void);
20*f4a2713aSLionel Sambuc typedef f* fptr;
21*f4a2713aSLionel Sambuc const f* v1;         // expected-warning {{qualifier on function type 'f' (aka 'int (void)') has unspecified behavior}}
22*f4a2713aSLionel Sambuc __restrict__ f* v2;  // expected-error {{restrict requires a pointer or reference ('f' (aka 'int (void)') is invalid)}}
23*f4a2713aSLionel Sambuc __restrict__ fptr v3; // expected-error {{pointer to function type 'f' (aka 'int (void)') may not be 'restrict' qualified}}
24*f4a2713aSLionel Sambuc f *__restrict__ v4;   // expected-error {{pointer to function type 'f' (aka 'int (void)') may not be 'restrict' qualified}}
25*f4a2713aSLionel Sambuc 
26*f4a2713aSLionel Sambuc restrict struct hallo; // expected-error {{restrict requires a pointer or reference}}
27*f4a2713aSLionel Sambuc 
28*f4a2713aSLionel Sambuc // PR6180
29*f4a2713aSLionel Sambuc struct test1 {
30*f4a2713aSLionel Sambuc } // expected-error {{expected ';' after struct}}
31*f4a2713aSLionel Sambuc 
test2()32*f4a2713aSLionel Sambuc void test2() {}
33*f4a2713aSLionel Sambuc 
34*f4a2713aSLionel Sambuc 
35*f4a2713aSLionel Sambuc // PR6423
36*f4a2713aSLionel Sambuc struct test3s {
37*f4a2713aSLionel Sambuc } // expected-error {{expected ';' after struct}}
38*f4a2713aSLionel Sambuc typedef int test3g;
39*f4a2713aSLionel Sambuc 
40*f4a2713aSLionel Sambuc // PR8264
41*f4a2713aSLionel Sambuc const const int pr8264_1 = 0;  // expected-warning {{duplicate 'const' declaration specifier}}
42*f4a2713aSLionel Sambuc volatile volatile int pr8264_2;  // expected-warning {{duplicate 'volatile' declaration specifier}}
43*f4a2713aSLionel Sambuc char * restrict restrict pr8264_3;  // expected-warning {{duplicate 'restrict' declaration specifier}}
44*f4a2713aSLionel Sambuc 
45*f4a2713aSLionel Sambuc extern extern int pr8264_4;  // expected-warning {{duplicate 'extern' declaration specifier}}
pr8264_5()46*f4a2713aSLionel Sambuc void pr8264_5() {
47*f4a2713aSLionel Sambuc   register register int x;  // expected-warning {{duplicate 'register' declaration specifier}}
48*f4a2713aSLionel Sambuc }
49*f4a2713aSLionel Sambuc 
pr8264_6()50*f4a2713aSLionel Sambuc inline inline void pr8264_6() {}  // expected-warning {{duplicate 'inline' declaration specifier}}
51*f4a2713aSLionel Sambuc _Noreturn _Noreturn void pr8264_7();  // expected-warning {{duplicate '_Noreturn' declaration specifier}}
52