struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-20040311-1.c
blobcd724e2ebc4665b8110014b0ae07643486bbcdf1
1 /*
2 20040311-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 /* Copyright (C) 2004 Free Software Foundation.
13 Check that constant folding and RTL simplification of -(x >> y) doesn't
14 break anything and produces the expected results.
16 Written by Roger Sayle, 11th March 2004. */
18 #define INT_BITS (sizeof(int)*8)
20 int ftest1(int x)
22 return -(x >> (INT_BITS-1));
25 int ftest2(unsigned int x)
27 return -((int)(x >> (INT_BITS-1)));
30 int ftest3(int x)
32 int y;
33 y = INT_BITS-1;
34 return -(x >> y);
37 int ftest4(unsigned int x)
39 int y;
40 y = INT_BITS-1;
41 return -((int)(x >> y));
44 void
45 testTortureExecute (void)
47 if (ftest1(0) != 0)
48 ASSERT (0);
49 if (ftest1(1) != 0)
50 ASSERT (0);
51 if (ftest1(-1) != 1)
52 ASSERT (0);
54 if (ftest2(0) != 0)
55 ASSERT (0);
56 if (ftest2(1) != 0)
57 ASSERT (0);
58 if (ftest2((unsigned int)-1) != -1)
59 ASSERT (0);
61 if (ftest3(0) != 0)
62 ASSERT (0);
63 if (ftest3(1) != 0)
64 ASSERT (0);
65 if (ftest3(-1) != 1)
66 ASSERT (0);
68 if (ftest4(0) != 0)
69 ASSERT (0);
70 if (ftest4(1) != 0)
71 ASSERT (0);
72 if (ftest4((unsigned int)-1) != -1)
73 ASSERT (0);
75 return;