struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-pr85582-2.c
blobe5b5f0bf63d03fc9b760fa7977b432fcdfdfe25b
1 /*
2 pr85582-2.c from the execute part of the gcc torture tests.
3 */
5 #include <testfwk.h>
7 #include <limits.h>
9 /* PR target/85582 */
11 typedef long long S;
12 typedef unsigned long long U;
15 f1 (S x, int y)
17 x = x << (y & 5);
18 x += y;
19 return x;
23 f2 (S x, int y)
25 x = x >> (y & 5);
26 x += y;
27 return x;
31 f3 (U x, int y)
33 x = x >> (y & 5);
34 x += y;
35 return x;
38 void
39 testTortureExecute (void)
41 #if !defined(__SDCC_pdk13) && !defined(__SDCC_pdk14) // Lack of data memory
42 S a = (S) 1 << (sizeof (S) * CHAR_BIT - 7);
43 S b = f1 (a, 12);
44 if (b != ((S) 1 << (sizeof (S) * CHAR_BIT - 3)) + 12)
45 ASSERT (0);
46 S c = (U) 1 << (sizeof (S) * CHAR_BIT - 1);
47 S d = f2 (c, 12);
48 if ((U) d != ((U) 0x1f << (sizeof (S) * CHAR_BIT - 5)) + 12)
49 ASSERT (0);
50 U e = (U) 1 << (sizeof (U) * CHAR_BIT - 1);
51 U f = f3 (c, 12);
52 if (f != ((U) 1 << (sizeof (U) * CHAR_BIT - 5)) + 12)
53 ASSERT (0);
54 return;
55 #endif