struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-pr85582-3.c
blobb9957dd956e4991a9de1f9d20362ab3f695c432e
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 (U x, int y)
17 return x << (y & -2);
21 f2 (S x, int y)
23 return x >> (y & -2);
27 f3 (U x, int y)
29 return x >> (y & -2);
32 void
33 testTortureExecute (void)
35 #if !defined(__SDCC_pdk13) && !defined(__SDCC_pdk14) // Lack of data memory
36 U a = (U) 1 << (sizeof (U) * CHAR_BIT - 7);
37 if (f1 (a, 5) != ((U) 1 << (sizeof (S) * CHAR_BIT - 3)))
38 ASSERT (0);
39 S b = (U) 0x101 << (sizeof (S) * CHAR_BIT / 2 - 7);
40 if (f1 (b, sizeof (S) * CHAR_BIT / 2) != (U) 0x101 << (sizeof (S) * CHAR_BIT - 7))
41 ASSERT (0);
42 if (f1 (b, sizeof (S) * CHAR_BIT / 2 + 2) != (U) 0x101 << (sizeof (S) * CHAR_BIT - 5))
43 ASSERT (0);
44 S c = (U) 1 << (sizeof (S) * CHAR_BIT - 1);
45 if ((U) f2 (c, 5) != ((U) 0x1f << (sizeof (S) * CHAR_BIT - 5)))
46 ASSERT (0);
47 if ((U) f2 (c, sizeof (S) * CHAR_BIT / 2) != ((U) -1 << (sizeof (S) * CHAR_BIT / 2 - 1)))
48 ASSERT (0);
49 if ((U) f2 (c, sizeof (S) * CHAR_BIT / 2 + 2) != ((U) -1 << (sizeof (S) * CHAR_BIT / 2 - 3)))
50 ASSERT (0);
51 U d = (U) 1 << (sizeof (S) * CHAR_BIT - 1);
52 if (f3 (c, 5) != ((U) 0x1 << (sizeof (S) * CHAR_BIT - 5)))
53 ASSERT (0);
54 if (f3 (c, sizeof (S) * CHAR_BIT / 2) != ((U) 1 << (sizeof (S) * CHAR_BIT / 2 - 1)))
55 ASSERT (0);
56 if (f3 (c, sizeof (S) * CHAR_BIT / 2 + 2) != ((U) 1 << (sizeof (S) * CHAR_BIT / 2 - 3)))
57 ASSERT (0);
58 return;
59 #endif