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-991016-1.c
blob55ea07a186319aba9873e34fdcd2208a8073ed1f
1 /*
2 991016-1.c from the execute part of the gcc torture tests.
3 */
5 #include <testfwk.h>
7 #ifdef __SDCC
8 #pragma std_c99
9 #endif
11 /* Two of these types will, on current gcc targets, have the same
12 mode but have different alias sets. DOIT tries to get gcse to
13 invalidly hoist one of the values out of the loop. */
15 #if !defined(__SDCC_pic14) && !defined(__SDCC_pic16) && !defined(__SDCC_pdk14)
16 typedef int T0;
17 typedef long T1;
18 typedef long long T2;
20 int
21 doit(int sel, int n, void *p)
23 T0 * const p0 = p;
24 T1 * const p1 = p;
25 T2 * const p2 = p;
27 switch (sel)
29 case 0:
30 do
31 *p0 += *p0;
32 while (--n);
33 return *p0 == 0;
35 case 1:
36 do
37 *p1 += *p1;
38 while (--n);
39 return *p1 == 0;
41 case 2:
42 do
43 *p2 += *p2;
44 while (--n);
45 return *p2 == 0;
47 default:
48 ASSERT (0);
51 #endif
53 void
54 testTortureExecute (void)
56 #if !defined(__SDCC_pic14) && !defined(__SDCC_pic16) && !defined(__SDCC_pdk14)
57 T0 v0; T1 v1; T2 v2;
59 v0 = 1; doit(0, 5, &v0);
60 v1 = 1; doit(1, 5, &v1);
61 v2 = 1; doit(2, 5, &v2);
63 if (v0 != 32) ASSERT (0);
64 if (v1 != 32) ASSERT (0);
65 if (v2 != 32) ASSERT (0);
67 return;
68 #endif