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-20021118-2.c
blobfa72b9f17431e1da88a191356f47f82523d21dd3
1 /*
2 20021118-2.c from the execute part of the gcc torture suite.
3 */
5 #include <testfwk.h>
7 #ifdef __SDCC
8 #pragma std_c99
9 #pragma disable_warning 93
10 #endif
12 /* Since these tests use function pointers with multiple parameters */
13 /* we can only proceed if we are compiling reentrant functions. */
15 #ifdef __SDCC_STACK_AUTO
17 /* Originally added to test SH constant pool layout. t1() failed for
18 non-PIC and t2() failed for PIC. */
20 int t1 (float *f, int i,
21 void (*f1) (double),
22 void (*f2) (float, float))
24 f1 (3.0);
25 f[i] = f[i + 1];
26 f2 (2.5f, 3.5f);
29 int t2 (float *f, int i,
30 void (*f1) (double),
31 void (*f2) (float, float),
32 void (*f3) (float))
34 f3 (6.0f);
35 f1 (3.0);
36 f[i] = f[i + 1];
37 f2 (2.5f, 3.5f);
40 void f1 (double d)
42 if (d != 3.0)
43 ASSERT (0);
46 void f2 (float f1, float f2)
48 if (f1 != 2.5f || f2 != 3.5f)
49 ASSERT (0);
52 void f3 (float f)
54 if (f != 6.0f)
55 ASSERT (0);
57 #endif
59 void
60 testTortureExecute (void)
62 #if __SDCC_STACK_AUTO
63 float f[3] = { 2.0f, 3.0f, 4.0f };
64 t1 (f, 0, f1, f2);
65 t2 (f, 1, f1, f2, f3);
66 if (f[0] != 3.0f && f[1] != 4.0f)
67 ASSERT (0);
68 return;
69 #endif