173
|
1 // RUN: %clang_cc1 %s -fsyntax-only -verify -verify=c2x -pedantic
|
|
2 // RUN: %clang_cc1 %s -fsyntax-only -std=c2x -verify -pedantic
|
150
|
3
|
|
4 // PR1892, PR11354
|
|
5 void f(double a[restrict][5]) { __typeof(a) x = 10; } // expected-warning {{(aka 'double (*restrict)[5]')}}
|
|
6
|
|
7 int foo (__const char *__path);
|
|
8 int foo(__const char *__restrict __file);
|
|
9
|
|
10 void func(const char*); // expected-note {{previous declaration is here}}
|
|
11 void func(char*); // expected-error{{conflicting types for 'func'}}
|
|
12
|
|
13 void g(int (*)(const void **, const void **));
|
|
14 void g(int (*compar)()) {
|
|
15 }
|
|
16
|
|
17 void h(); // expected-note {{previous declaration is here}}
|
|
18 void h (const char *fmt, ...) {} // expected-error{{conflicting types for 'h'}}
|
|
19
|
|
20 // PR1965
|
|
21 int t5(b); // expected-error {{parameter list without types}}
|
|
22 int t6(int x, g); // expected-warning {{type specifier missing, defaults to 'int'}}
|
|
23
|
|
24 int t7(, ); // expected-error {{expected parameter declarator}} expected-error {{expected parameter declarator}}
|
|
25 int t8(, int a); // expected-error {{expected parameter declarator}}
|
|
26 int t9(int a, ); // expected-error {{expected parameter declarator}}
|
|
27
|
|
28
|
|
29 // PR2042
|
|
30 void t10(){}
|
|
31 void t11(){t10(1);} // expected-warning{{too many arguments}}
|
|
32
|
|
33 // PR3208
|
173
|
34 void t12(int) {} // c2x-warning{{omitting the parameter name in a function definition is a C2x extension}}
|
150
|
35
|
|
36 // PR2790
|
|
37 void t13() {
|
|
38 return 0; // expected-error {{void function 't13' should not return a value}}
|
|
39 }
|
|
40 int t14() {
|
|
41 return; // expected-error {{non-void function 't14' should return a value}}
|
|
42 }
|
|
43
|
|
44 // <rdar://problem/6097326>
|
|
45 y(y) { return y; } // expected-warning{{parameter 'y' was not declared, defaulting to type 'int'}} \
|
|
46 // expected-warning{{type specifier missing, defaults to 'int'}}
|
|
47
|
|
48
|
|
49 // PR3137, <rdar://problem/6127293>
|
|
50 extern int g0_3137(void);
|
|
51 void f0_3137() {
|
|
52 int g0_3137(void);
|
|
53 }
|
|
54 void f1_3137() {
|
|
55 int (*fp)(void) = g0_3137;
|
|
56 }
|
|
57
|
|
58 void f1static() {
|
|
59 static void f2static(int); // expected-error{{function declared in block scope cannot have 'static' storage class}}
|
|
60 register void f2register(int); // expected-error{{illegal storage class on function}}
|
|
61 }
|
|
62
|
|
63 struct incomplete_test a(void) {} // expected-error{{incomplete result type 'struct incomplete_test' in function definition}} \
|
|
64 // expected-note{{forward declaration of 'struct incomplete_test'}}
|
|
65
|
|
66
|
|
67 extern __inline
|
|
68 __attribute__((__gnu_inline__))
|
|
69 void gnu_inline1() {}
|
|
70
|
|
71 void
|
|
72 __attribute__((__gnu_inline__)) // expected-warning {{'gnu_inline' attribute requires function to be marked 'inline', attribute ignored}}
|
|
73 gnu_inline2() {}
|
|
74
|
|
75
|
|
76 // rdar://6802350
|
|
77 inline foo_t invalid_type() { // expected-error {{unknown type name 'foo_t'}}
|
|
78 }
|
|
79
|
|
80 typedef void fn_t(void);
|
|
81 fn_t t17;
|
|
82
|
|
83 // PR4049
|
173
|
84 unknown_type t18(void*) { // expected-error {{unknown type name 'unknown_type'}} \
|
|
85 // c2x-warning {{omitting the parameter name in a function definition is a C2x extension}}
|
150
|
86 }
|
|
87
|
|
88 unknown_type t19(int* P) { // expected-error {{unknown type name 'unknown_type'}}
|
|
89 P = P+1; // no warning.
|
|
90 }
|
|
91
|
|
92 // missing ',' before '...'
|
|
93 void t20(int i...) { } // expected-error {{requires a comma}}
|
|
94
|
|
95 int n;
|
|
96 void t21(int n, int (*array)[n]);
|
|
97
|
|
98 int func_e(int x) {
|
|
99 int func_n(int y) { // expected-error {{function definition is not allowed here}}
|
|
100 if (y > 22) {
|
|
101 return y+2;
|
|
102 } else {
|
|
103 return y-2;
|
|
104 }
|
|
105 }
|
|
106 return x + 3;
|
|
107 }
|
|
108
|
|
109 void decays(int a[3][3]); // expected-note {{passing argument to parameter 'a' here}}
|
|
110 void no_decay(int (*a)[3]); // expected-note {{passing argument to parameter 'a' here}}
|
|
111
|
|
112 void t22(int *ptr, int (*array)[3]) {
|
|
113 decays(ptr); // expected-warning {{incompatible pointer types passing 'int *' to parameter of type 'int (*)[3]'}}
|
|
114 no_decay(ptr); // expected-warning {{incompatible pointer types passing 'int *' to parameter of type 'int (*)[3]'}}
|
|
115 decays(array);
|
|
116 no_decay(array);
|
|
117 }
|
|
118
|
|
119 void const Bar (void); // ok on decl
|
|
120 // PR 20146
|
|
121 void const Bar (void) // expected-warning {{function cannot return qualified void type 'const void'}}
|
|
122 {
|
|
123 }
|