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-pure-1.c
blob759cccc7fa6d2186ce9582f68ea2ee11ca570c4c
1 /*
2 restrict-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 /* Origin: Kaveh Ghazi <ghazi@caip.rutgers.edu> 2002-05-27. */
13 extern int i;
15 extern int func0 (int);
16 extern int func1 (int);
18 /* GCC should automatically detect attributes for these functions.
19 At -O3 They'll be inlined, but that's ok. */
20 static int func2 (int a) { return i + a; } /* pure */
21 static int func3 (int a) { return a * 3; } /* const */
22 static int func4 (int a) { return func0(a) + a; } /* pure */
23 static int func5 (int a) { return a + func1(a); } /* const */
24 static int func6 (int a) { return func2(a) + a; } /* pure */
25 static int func7 (int a) { return a + func3(a); } /* const */
27 void
28 testTortureExecute (void)
30 #ifndef __SDCC_pdk14 // Lack of memory
31 int i[10], r;
33 i[0] = 0;
34 r = func0(0);
35 if (i[0])
36 ASSERT (0);
38 i[1] = 0;
39 r = func1(0);
40 if (i[1])
41 ASSERT (0);
43 i[2] = 0;
44 r = func2(0);
45 if (i[2])
46 ASSERT (0);
48 i[3] = 0;
49 r = func3(0);
50 if (i[3])
51 ASSERT (0);
53 i[4] = 0;
54 r = func4(0);
55 if (i[4])
56 ASSERT (0);
58 i[5] = 0;
59 r = func5(0);
60 if (i[5])
61 ASSERT (0);
63 i[6] = 0;
64 r = func6(0);
65 if (i[6])
66 ASSERT (0);
68 i[7] = 0;
69 r = func7(0);
70 if (i[7])
71 ASSERT (0);
73 return;
74 #endif
77 int func0 (int a) { return a - i; } /* pure */
78 int func1 (int a) { return a - a; } /* const */
80 int i = 2;