Hackfix and re-enable strtoull and wcstoull, see bug #3798.
[sdcc.git] / sdcc / support / regression / tcc / 60_errors_and_warnings.c
blob8a91512a830cae07cb106e8cb764e44527c38b1f
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_enum_compat_2
122 enum e6 { E1 = -1, E0 };
123 void f3(enum e6);
124 void f3(int); // should work as int and e6 are compatible
125 void f4(enum e6 e);
126 void f4(unsigned e); // should error as unsigned and e6 are incompatible
128 #elif defined test_ptr_to_str
129 void f() { _Generic((int const *[]){0}, int:0); }
130 #elif defined test_fnptr_to_str
131 void f() { _Generic((int (*(*)(float,char))(double,int)){0}, int:0); }
132 #elif defined test_array_to_str
133 void f() { _Generic((int(*)[3]){0}, int:0); }
134 #elif defined test_duplicate_def_1
135 static enum myenum { L = -1 } L;
136 #elif defined test_duplicate_def_2
137 void foo(void) {
138 static enum myenum { L = -1 } L;
140 #elif defined test_abstract_decls
141 int bar(const char *()); // abstract declarator here is okay
142 int bar (const char *(*g)()) // should match this 'g' argument
144 g();
145 return 42;
147 int foo(int ()) // abstract decl is wrong in definitions
149 return 0;
150 #elif defined test_invalid_1
151 void f(char*);
152 void g(void) {
153 f((char[]){1, ,});
155 #elif defined test_invalid_2
156 int ga = 0.42 { 2 };
157 #elif defined test_invalid_3
158 struct S { int a, b; };
159 struct T { struct S x; };
160 struct T gt = { 42 a: 1, 43 };
161 #elif defined test_invalid_4
162 enum E {
163 x = 1 / 0
165 #elif defined test_conflicting_types
166 int i;
167 void foo(void) {
168 int i;
170 extern double i;
171 i = 42.2;
174 #elif defined test_nested_types
175 union u {
176 union u {
177 int i;
178 } m;
180 #elif defined test_vla_1
181 int X=1;
183 int main(void) {
184 int t[][][X];
186 #elif defined test_invalid_alignas
187 /* _Alignas is no type qualifier */
188 void * _Alignas(16) p1;
190 #elif defined test_static_assert
192 #define ONE 0
193 _Static_assert(ONE == 0, "don't show me this");
194 _Static_assert(ONE == 1, "ONE is not 1");
196 #elif defined test_static_assert_2
197 _Static_assert(1, "1"" is 1");
198 _Static_assert(0, "0"" is 0");
200 #elif defined test_static_assert_c2x
201 _Static_assert(1);
202 _Static_assert(0);
204 #elif defined test_void_array
205 void t[3];
207 #elif defined test_incomplete_enum_array
208 enum e t[3];
210 #elif defined test_incomplete_struct_array
211 struct s t[3];
213 #elif defined test_const_fun_array
214 typedef void f(void);
215 const f t[3];
217 #elif defined test_incomplete_array_array
218 int t[][3]; // gr: not an error, see below
220 /******************************************************************/
221 #elif defined test_extern_array
222 int iii[] = { 1,2,3 };
223 extern int iii[];
224 int x[];
225 int x[2];
226 int x[];
227 int x[2];
228 int x[];
229 extern int x[2];
230 extern int x[];
231 int x[3];
233 /******************************************************************/
234 #elif defined test_func_1 \
235 || defined test_func_2 \
236 || defined test_func_3 \
237 || defined test_func_4 \
238 || defined test_func_5 \
239 || defined test_func_6
240 #if defined test_func_1
241 int hello(int);
242 #elif defined test_func_4
243 static int hello(int);
244 #endif
245 int main () {
246 #if defined test_func_6
247 static
248 #endif
249 int hello(int);
250 hello(123);
251 return 0;
253 int printf(const char*, ...);
254 #if defined test_func_3
255 static int hello(int a)
256 #elif defined test_func_5
257 int hello(int a, int b)
258 #else
259 int hello(int a)
260 #endif
261 { printf("%s: a = %d\n", __FUNCTION__, a); return 0; }
263 /******************************************************************/
264 #elif defined test_var_1 \
265 || defined test_var_2 \
266 || defined test_var_3
267 #define P(n,v) printf("%-5s: %d ; %d\n", __FUNCTION__, n, v)
268 #if defined test_var_1
269 int xxx[];
270 #endif
271 int bar();
272 int printf(const char*, ...);
273 int main ()
275 #if !defined test_var_3
276 int xxx = 2;
277 #endif
279 extern int xxx[
280 #if defined test_var_3
282 #endif
284 P(1, xxx[0]);
285 xxx[0] += 2;
287 #if !defined test_var_3
288 P(2, xxx);
289 #endif
290 bar(123);
291 return 0;
293 int xxx[1] = {1};
294 int bar() { P(3, xxx[0]); return 0; }
296 #elif defined test_var_4
297 struct yyy { int y; };
298 struct zzz;
299 void f1() {
300 extern char *x;
301 extern char **xx;
302 extern struct yyy y;
303 extern struct yyy *yy;
304 extern struct zzz z;
305 extern struct zzz *zz;
307 void f2() {
308 extern char *x;
309 extern char **xx;
310 extern struct yyy y;
311 extern struct yyy *yy;
312 extern struct zzz z;
313 extern struct zzz *zz;
315 struct yyy y, *yy;
316 struct zzz { int z; } z, *zz;
318 /******************************************************************/
319 #elif defined test_long_double_type_for_win32
321 int main()
323 double *a = 0;
324 long double *b = a;
325 int n = _Generic(*a, double:0, long double:1);
328 #elif defined test_stray_backslash
329 #define x \a
332 #elif defined test_stray_backslash2
333 int printf(const char*, ...);
334 int main()
336 #define _S(x) #x
337 #define S(x) _S(x)
338 printf("%sn\n", S(\\));
341 /******************************************************************/
342 #elif defined test_var_array
344 static struct var_len { int i; const char str[]; } var_array[] =
345 { { 1, "abcdefghijklmnopqrstuvwxyz" },
346 { 2, "longlonglonglonglong" },
347 { 3, "tst3" } };
349 #elif defined test_var_array2
351 struct c1 { int a; int b[]; };
352 struct c1 c1 = { 1, { 2, 3, 4 } };
354 struct c2 { int c; struct c1 c1; };
355 struct c2 c2 = { 1, { 2, { 3, 4, 5 }}};
357 #elif defined test_var_array3
358 /* similar to test_var_array2 but with string initializers */
359 struct A { int a; char b[]; };
360 struct A a = { 1, "1" };
361 struct B { struct A a; };
362 struct B b = { { 1, "1" } };
363 /******************************************************************/
364 #elif defined test_default_int_type
365 n; // warn
366 f(); // don't warn
368 #elif defined test_invalid_global_stmtexpr
369 n[sizeof({3;})]; // crashed in block() due to missing local scope
371 #elif defined test_invalid_tokckill
372 f(){"12"3;} // second const token killed the value of the first
374 /******************************************************************/
375 #elif defined test_duplicate_member
376 struct S {
377 int a, a;
379 #elif defined test_duplicate_member_anon
380 struct S1 {
381 int b;
382 struct {
383 int b;
384 } c;
386 struct S2 {
387 int d;
388 struct {
389 int d;
393 /******************************************************************/
394 #elif defined test_conflicting_array_definition
395 extern int array[2];
396 int array[] = { 1, 2, 3 };
398 #elif defined test_cast_from_void
399 void v() {}
400 int f() { return v(); }
402 #elif defined test_switch_W1 || defined test_switch_W2 \
403 || defined test_switch_W3 || defined test_switch_W4
404 #if defined test_switch_W1
405 #pragma comment(option, "-Wall")
406 #elif defined test_switch_W2
407 #pragma comment(option, "-Wunsupported -Wno-implicit-function-declaration -Wstuff")
408 #elif defined test_switch_W3
409 #pragma comment(option, "-Wwrite-strings -Werror=discarded-qualifiers")
410 #elif defined test_switch_W4
411 #pragma comment(option, "-Wunsupported -Wno-error=implicit-function-declaration -Werror")
412 #endif
413 void func()
415 char *ccp = "123";
416 fink();
418 __attribute__((stuff)) int fink() {return 0;}
419 #endif