Pick three bugfixes from next branch to trunk for inclusion in 4.5.0 RC2, as discusse...
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-20010409-1.c
blob11cb48b3ee8758a76b3c0a97b86105af3c518c35
1 /*
2 20010409-1.c from the execute part of the gcc torture tests.
3 */
5 #include <testfwk.h>
7 #ifdef __SDCC
8 #pragma std_c99
9 #pragma disable_warning 85
10 #endif
12 #if !defined(__SDCC_pic14) // Unimplemented setjmp
13 #include <string.h>
14 #include <setjmp.h>
16 #ifndef __SDCC_pdk14 // Lack of memory
17 jmp_buf try;
19 typedef struct A {
20 int a, b;
21 } A;
23 typedef struct B {
24 struct A **a;
25 int b;
26 } B;
28 A *a;
29 int b = 1, c;
30 B d[1];
32 void foo (A *x, const char *y, int z)
34 c = y[4] + z * 25;
37 A *bar (const char *v, int w, int x, const char *y, int z)
39 if (w)
40 ASSERT (0);
41 longjmp(try, 1);
44 void test (const char *x, int *y)
46 foo (d->a[d->b], "test", 200);
47 d->a[d->b] = bar (x, b ? 0 : 65536, strlen (x), "test", 201);
48 d->a[d->b]->a++;
49 if (y)
50 d->a[d->b]->b = *y;
52 #endif
53 #endif
55 void
56 testTortureExecute (void)
58 #ifndef __SDCC_pdk14 // Lack of memory
59 #if !defined(__SDCC_pic14) // Unimplemented setjmp
60 if (setjmp(try) == 0)
62 d->b = 0;
63 d->a = &a;
64 test ("", 0);
66 #endif
67 #endif