1 // RUN: %clang_cc1 %s -fsyntax-only -verify -verify=c2x -pedantic -Wno-strict-prototypes
4 void f(double a
[restrict
][5]) { __typeof(a
) x
= 10; } // expected-error {{(aka 'double (*restrict)[5]')}}
6 int foo (__const
char *__path
);
7 int foo(__const
char *__restrict __file
);
9 void func(const char*); // expected-note {{previous declaration is here}}
10 void func(char*); // expected-error{{conflicting types for 'func'}}
12 void g(int (*)(const void **, const void **));
13 void g(int (*compar
)()) {
16 void h(); // expected-note {{previous declaration is here}}
17 void h (const char *fmt
, ...) {} // expected-error{{conflicting types for 'h'}}
20 int t5(b
); // expected-error {{parameter list without types}}
21 int t6(int x
, g
); // expected-error {{type specifier missing, defaults to 'int'}}
23 int t7(, ); // expected-error {{expected parameter declarator}} expected-error {{expected parameter declarator}}
24 int t8(, int a
); // expected-error {{expected parameter declarator}}
25 int t9(int a
, ); // expected-error {{expected parameter declarator}}
30 void t11(){t10(1);} // expected-warning{{too many arguments}}
33 void t12(int) {} // c2x-warning{{omitting the parameter name in a function definition is a C23 extension}}
37 return 0; // expected-error {{void function 't13' should not return a value}}
40 return; // expected-error {{non-void function 't14' should return a value}}
43 y(y
) { return y
; } // expected-error{{parameter 'y' was not declared, defaults to 'int'; ISO C99 and later do not support implicit int}} \
44 // expected-error{{type specifier missing, defaults to 'int'}}
48 extern int g0_3137(void);
53 int (*fp
)(void) = g0_3137
;
57 static void f2static(int); // expected-error{{function declared in block scope cannot have 'static' storage class}}
58 register void f2register(int); // expected-error{{illegal storage class on function}}
61 struct incomplete_test
a(void) {} // expected-error{{incomplete result type 'struct incomplete_test' in function definition}} \
62 // expected-note{{forward declaration of 'struct incomplete_test'}}
66 __attribute__((__gnu_inline__
))
70 __attribute__((__gnu_inline__
)) // expected-warning {{'gnu_inline' attribute requires function to be marked 'inline', attribute ignored}}
74 inline foo_t
invalid_type() { // expected-error {{unknown type name 'foo_t'}}
77 typedef void fn_t(void);
81 unknown_type
t18(void*) { // expected-error {{unknown type name 'unknown_type'}} \
82 // c2x-warning {{omitting the parameter name in a function definition is a C23 extension}}
85 unknown_type
t19(int* P
) { // expected-error {{unknown type name 'unknown_type'}}
86 P
= P
+1; // no warning.
89 // missing ',' before '...'
90 void t20(int i
...) { } // expected-error {{requires a comma}}
93 void t21(int n
, int (*array
)[n
]);
96 int func_n(int y
) { // expected-error {{function definition is not allowed here}}
106 void decays(int a
[3][3]); // expected-note {{passing argument to parameter 'a' here}}
107 void no_decay(int (*a
)[3]); // expected-note {{passing argument to parameter 'a' here}}
109 void t22(int *ptr
, int (*array
)[3]) {
110 decays(ptr
); // expected-warning {{incompatible pointer types passing 'int *' to parameter of type 'int (*)[3]'}}
111 no_decay(ptr
); // expected-warning {{incompatible pointer types passing 'int *' to parameter of type 'int (*)[3]'}}
116 void const Bar (void); // ok on decl
118 void const Bar (void) // expected-warning {{function cannot return qualified void type 'const void'}}