struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-20050502-1.c
bloba776a11cd08ff3277975bf5741ad65bfe8e3e982
1 /*
2 20050502-1.c from the execute part of the gcc torture suite.
3 */
5 #include <testfwk.h>
7 #ifdef __SDCC
8 #pragma std_c99
9 #endif
11 #include <string.h>
13 /* PR rtl-optimization/21330 */
15 int
16 bar (const char **x)
18 return *(*x)++;
21 int
22 baz (int c)
24 return c != '@';
27 void
28 foo (const char **w, char *x, _Bool y, _Bool z)
30 char c = bar (w);
31 int i = 0;
33 while (1)
35 x[i++] = c;
36 c = bar (w);
37 if (y && c == '\'')
38 break;
39 if (z && c == '\"')
40 break;
41 if (!y && !z && !baz (c))
42 break;
44 x[i] = 0;
47 void
48 testTortureExecute (void)
50 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pic14) // Lack of memory
51 char buf[64];
52 const char *p;
53 p = "abcde'fgh";
54 foo (&p, buf, 1, 0);
55 if (strcmp (p, "fgh") != 0 || strcmp (buf, "abcde") != 0)
56 ASSERT (0);
57 p = "ABCDEFG\"HI";
58 foo (&p, buf, 0, 1);
59 if (strcmp (p, "HI") != 0 || strcmp (buf, "ABCDEFG") != 0)
60 ASSERT (0);
61 p = "abcd\"e'fgh";
62 foo (&p, buf, 1, 1);
63 if (strcmp (p, "e'fgh") != 0 || strcmp (buf, "abcd") != 0)
64 ASSERT (0);
65 p = "ABCDEF'G\"HI";
66 foo (&p, buf, 1, 1);
67 if (strcmp (p, "G\"HI") != 0 || strcmp (buf, "ABCDEF") != 0)
68 ASSERT (0);
69 p = "abcdef@gh";
70 foo (&p, buf, 0, 0);
71 if (strcmp (p, "gh") != 0 || strcmp (buf, "abcdef") != 0)
72 ASSERT (0);
73 return;
74 #endif