struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-20020226-1.c
blob0a371c8f6633f9a5e03910f42a555320dda4c096
1 /*
2 20020226-1.c from the execute part of the gcc torture suite.
3 */
5 #include <testfwk.h>
7 #ifdef __SDCC
8 #pragma std_c99
9 #endif
11 /* This tests the rotate patterns that some machines support. */
13 #include <limits.h>
15 #ifndef CHAR_BIT
16 #define CHAR_BIT 8
17 #endif
19 #define ROR(a,b) (((a) >> (b)) | ((a) << ((sizeof (a) * CHAR_BIT) - (b))))
20 #define ROL(a,b) (((a) << (b)) | ((a) >> ((sizeof (a) * CHAR_BIT) - (b))))
22 #define CHAR_VALUE ((unsigned char)0x1234U)
23 #define SHORT_VALUE ((unsigned short)0x1234U)
24 #define INT_VALUE 0x1234U
25 #define LONG_VALUE 0x12345678LU
26 #define LL_VALUE 0x12345678abcdef0LLU
28 #define SHIFT1 4
29 #define SHIFT2 ((sizeof (long long) * CHAR_BIT) - SHIFT1)
31 unsigned char uc = CHAR_VALUE;
32 unsigned short us = SHORT_VALUE;
33 unsigned int ui = INT_VALUE;
34 unsigned long ul = LONG_VALUE;
35 unsigned long long ull = LL_VALUE;
36 int shift1 = SHIFT1;
37 int shift2 = SHIFT2;
39 void
40 testTortureExecute (void)
42 if (ROR (uc, shift1) != ROR (CHAR_VALUE, SHIFT1))
43 ASSERT (0);
45 if (ROR (uc, SHIFT1) != ROR (CHAR_VALUE, SHIFT1))
46 ASSERT (0);
48 if (ROR (us, shift1) != ROR (SHORT_VALUE, SHIFT1))
49 ASSERT (0);
51 if (ROR (us, SHIFT1) != ROR (SHORT_VALUE, SHIFT1))
52 ASSERT (0);
53 #ifndef __SDCC_pdk14 // Lack of memory
54 if (ROR (ui, shift1) != ROR (INT_VALUE, SHIFT1))
55 ASSERT (0);
57 if (ROR (ui, SHIFT1) != ROR (INT_VALUE, SHIFT1))
58 ASSERT (0);
60 if (ROR (ul, shift1) != ROR (LONG_VALUE, SHIFT1))
61 ASSERT (0);
63 if (ROR (ul, SHIFT1) != ROR (LONG_VALUE, SHIFT1))
64 ASSERT (0);
66 if (ROR (ull, shift1) != ROR (LL_VALUE, SHIFT1))
67 ASSERT (0);
69 if (ROR (ull, SHIFT1) != ROR (LL_VALUE, SHIFT1))
70 ASSERT (0);
71 #ifndef __SDCC_pdk15 // Lack of memory
72 if (ROR (ull, shift2) != ROR (LL_VALUE, SHIFT2))
73 ASSERT (0);
75 if (ROR (ull, SHIFT2) != ROR (LL_VALUE, SHIFT2))
76 ASSERT (0);
78 if (ROL (uc, shift1) != ROL (CHAR_VALUE, SHIFT1))
79 ASSERT (0);
81 if (ROL (uc, SHIFT1) != ROL (CHAR_VALUE, SHIFT1))
82 ASSERT (0);
84 if (ROL (us, shift1) != ROL (SHORT_VALUE, SHIFT1))
85 ASSERT (0);
87 if (ROL (us, SHIFT1) != ROL (SHORT_VALUE, SHIFT1))
88 ASSERT (0);
90 if (ROL (ui, shift1) != ROL (INT_VALUE, SHIFT1))
91 ASSERT (0);
93 if (ROL (ui, SHIFT1) != ROL (INT_VALUE, SHIFT1))
94 ASSERT (0);
96 if (ROL (ul, shift1) != ROL (LONG_VALUE, SHIFT1))
97 ASSERT (0);
99 if (ROL (ul, SHIFT1) != ROL (LONG_VALUE, SHIFT1))
100 ASSERT (0);
102 if (ROL (ull, shift1) != ROL (LL_VALUE, SHIFT1))
103 ASSERT (0);
105 if (ROL (ull, SHIFT1) != ROL (LL_VALUE, SHIFT1))
106 ASSERT (0);
108 if (ROL (ull, shift2) != ROL (LL_VALUE, SHIFT2))
109 ASSERT (0);
111 if (ROL (ull, SHIFT2) != ROL (LL_VALUE, SHIFT2))
112 ASSERT (0);
113 #endif
114 #endif
115 return;