121 lines · c
1// RUN: %clang_cc1 %s -fsyntax-only -verify -verify=c2x -pedantic -Wno-strict-prototypes2 3// PR1892, PR113544void f(double a[restrict][5]) { __typeof(a) x = 10; } // expected-error {{(aka 'double (*restrict)[5]')}}5 6int foo (__const char *__path);7int foo(__const char *__restrict __file);8 9void func(const char*); // expected-note {{previous declaration is here}}10void func(char*); // expected-error{{conflicting types for 'func'}}11 12void g(int (*)(const void **, const void **));13void g(int (*compar)()) {14}15 16void h(); // expected-note {{previous declaration is here}}17void h (const char *fmt, ...) {} // expected-error{{conflicting types for 'h'}}18 19// PR196520int t5(b); // expected-error {{parameter list without types}}21int t6(int x, g); // expected-error {{type specifier missing, defaults to 'int'}}22 23int t7(, ); // expected-error {{expected parameter declarator}} expected-error {{expected parameter declarator}}24int t8(, int a); // expected-error {{expected parameter declarator}}25int t9(int a, ); // expected-error {{expected parameter declarator}}26 27 28// PR204229void t10(){}30void t11(){t10(1);} // expected-warning{{too many arguments}}31 32// PR320833void t12(int) {} // c2x-warning{{omitting the parameter name in a function definition is a C23 extension}}34 35// PR279036void t13() {37 return 0; // expected-error {{void function 't13' should not return a value}}38}39int t14() {40 return; // expected-error {{non-void function 't14' should return a value}}41}42 43y(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'}}45 46 47// PR313748extern int g0_3137(void);49void f0_3137() {50 int g0_3137(void);51}52void f1_3137() {53 int (*fp)(void) = g0_3137;54}55 56void f1static() {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}}59}60 61struct incomplete_test a(void) {} // expected-error{{incomplete result type 'struct incomplete_test' in function definition}} \62 // expected-note{{forward declaration of 'struct incomplete_test'}}63 64 65extern __inline66__attribute__((__gnu_inline__))67void gnu_inline1() {}68 69void70__attribute__((__gnu_inline__)) // expected-warning {{'gnu_inline' attribute requires function to be marked 'inline', attribute ignored}}71gnu_inline2() {}72 73 74inline foo_t invalid_type() { // expected-error {{unknown type name 'foo_t'}}75}76 77typedef void fn_t(void);78fn_t t17;79 80// PR404981unknown_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}}83}84 85unknown_type t19(int* P) { // expected-error {{unknown type name 'unknown_type'}}86 P = P+1; // no warning.87}88 89// missing ',' before '...'90void t20(int i...) { } // expected-error {{requires a comma}}91 92int n;93void t21(int n, int (*array)[n]);94 95int func_e(int x) {96 int func_n(int y) { // expected-error {{function definition is not allowed here}}97 if (y > 22) {98 return y+2;99 } else {100 return y-2;101 }102 }103 return x + 3;104}105 106void decays(int a[3][3]); // expected-note {{passing argument to parameter 'a' here}}107void no_decay(int (*a)[3]); // expected-note {{passing argument to parameter 'a' here}}108 109void t22(int *ptr, int (*array)[3]) {110 decays(ptr); // expected-error {{incompatible pointer types passing 'int *' to parameter of type 'int (*)[3]'}}111 no_decay(ptr); // expected-error {{incompatible pointer types passing 'int *' to parameter of type 'int (*)[3]'}}112 decays(array);113 no_decay(array);114}115 116void const Bar (void); // ok on decl117// PR 20146118void const Bar (void) // expected-warning {{function cannot return qualified void type 'const void'}}119{120}121