struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-20010915-1.c
blob65eb3515b56081702653e076b7118128fa80fe1c
1 /*
2 20010915-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 #include <string.h>
14 /* Bug in reorg.c, deleting the "++" in the last loop in main.
15 Origin: <hp@axis.com>. */
17 extern void f (void);
18 extern int x (int, const char **);
19 extern int r (const char *);
20 extern char *s (const char *, const char **);
21 extern char *m (const char *);
22 char *u;
23 char *h;
24 int check = 0;
25 int o = 0;
27 void
28 testTortureExecute (void)
30 #ifndef __SDCC_pdk14 // Lack of memory - see RFE #610
31 const char *args[] = {"a", "b", "c", "d", "e"};
32 if (x (5, args) != 0 || check != 2 || o != 5)
33 ASSERT (0);
34 return;
35 #endif
38 #ifndef __SDCC_pdk14 // Lack of memory - see RFE #610
39 int x (int argc, const char **argv)
41 int opt = 0;
42 char *g = 0;
43 const char *p = 0;
45 if (argc > o && argc > 2 && argv[o])
47 g = s (argv[o], &p);
48 if (g)
50 *g++ = '\0';
51 h = s (g, &p);
52 if (g == p)
53 h = m (g);
55 u = s (argv[o], &p);
56 if (argv[o] == p)
57 u = m (argv[o]);
59 else
60 ASSERT (0);
62 while (++o < argc)
63 if (r (argv[o]) == 0)
64 return 1;
66 return 0;
69 char *m (const char *x) { ASSERT (0); return 0;}
70 char *s (const char *v, const char **pp)
72 if (strcmp (v, "a") != 0 || check++ > 1)
73 ASSERT (0);
74 *pp = v+1;
75 return 0;
78 int r (const char *f)
80 static char c[2] = "b";
81 static int cnt = 0;
83 if (*f != *c || f[1] != c[1] || cnt > 3)
84 ASSERT (0);
85 c[0]++;
86 cnt++;
87 return 1;
89 #endif