Detect invalid VLA decls
[tinycc.git] / tests / tests2 / 60_errors_and_warnings.c
blob61561b8e985ee8ef3b73ba931e8e419fc83d782f
1 #if defined test_56_btype_excess_1
2 struct A {} int i;
4 #elif defined test_57_btype_excess_2
5 char int i;
7 #elif defined test_58_function_redefinition
8 int f(void) { return 0; }
9 int f(void) { return 1; }
11 #elif defined test_global_redefinition
12 int xxx = 1;
13 int xxx;
14 int xxx = 2;
16 #elif defined test_59_function_array
17 int (*fct)[42](int x);
19 #elif defined test_60_enum_redefinition
20 enum color { RED, GREEN, BLUE };
21 enum color { R, G, B };
22 enum color c;
24 #elif defined test_62_enumerator_redefinition
25 enum color { RED, GREEN, BLUE };
26 enum rgb { RED, G, B};
27 enum color c = RED;
29 #elif defined test_63_local_enumerator_redefinition
30 enum {
31 FOO,
32 BAR
35 int main(void)
37 enum {
38 FOO = 2,
39 BAR
42 return BAR - FOO;
45 #elif defined test_61_undefined_enum
46 enum rgb3 c = 42;
48 #elif defined test_74_non_const_init
49 int i = i++;
51 #elif defined test_pointer_assignment
53 void (*f1)(void);
54 void f2(void) {}
56 struct s1 *ps1;
57 struct s2 *ps2;
59 void *v1, **v2, ***v3;
61 enum e1 { a = 4 } e10, *e11, *e12;
62 enum e2 { b = -4 } e20, *e21;
63 enum e3 { c = 5000000000LL } e30;
65 int *ip;
66 unsigned int *up;
67 long *lp;
68 long long *llp;
70 char **c1;
71 char const **c2;
72 unsigned char **u1;
74 int no_main ()
76 // function
77 f1 = f2;
78 // struct
79 ps1 = ps2;
80 // void*
81 v1 = v3;
82 v2 = v3;
84 // enum
85 e11 = e12;
86 e11 = e21;
87 e11 = &e10;
88 ip = &e10;
89 ip = &e20;
90 up = &e10;
91 up = &e20;
92 up = &e30;
94 lp = ip;
95 lp = llp;
97 // constness
98 c1 = c2;
99 *c1 = *c2;
100 **c1 = **c2;
102 // unsigned = signed
103 u1 = c2;
104 *u1 = *c2;
105 **u1 = **c2;
107 c2 = c1;
108 *c2 = *c1;
109 **c2 = **c1;
111 return 0;
115 #elif defined test_enum_compat
116 enum e4;
117 enum e5;
118 void f3(enum e4 e);
119 void f3(enum e5 e);
121 #elif defined test_ptr_to_str
122 void f() { _Generic((int const *[]){0}, int:0); }
123 #elif defined test_fnptr_to_str
124 void f() { _Generic((int (*(*)(float,char))(double,int)){0}, int:0); }
125 #elif defined test_array_to_str
126 void f() { _Generic((int(*)[3]){0}, int:0); }
127 #elif defined test_duplicate_def_1
128 static enum myenum { L = -1 } L;
129 #elif defined test_duplicate_def_2
130 void foo(void) {
131 static enum myenum { L = -1 } L;
133 #elif defined test_abstract_decls
134 int bar(const char *()); // abstract declarator here is okay
135 int bar (const char *(*g)()) // should match this 'g' argument
137 g();
138 return 42;
140 int foo(int ()) // abstract decl is wrong in definitions
142 return 0;
143 #elif defined test_invalid_1
144 void f(char*);
145 void g(void) {
146 f((char[]){1, ,});
148 #elif defined test_invalid_2
149 int ga = 0.42 { 2 };
150 #elif defined test_invalid_3
151 struct S { int a, b; };
152 struct T { struct S x; };
153 struct T gt = { 42 a: 1, 43 };
154 #elif defined test_conflicting_types
155 int i;
156 void foo(void) {
157 int i;
159 extern double i;
160 i = 42.2;
163 #elif defined test_nested_types
164 union u {
165 union u {
166 int i;
167 } m;
169 #elif defined test_vla_1
170 int X=1;
172 int main(void) {
173 int t[][][X];
175 #endif