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-shiftopt-1.c
blob07ec4b0065aeb4b4b22e891aa044621eb72ad88a
1 /*
2 shiftopt-1.c from the execute part of the gcc torture tests.
3 */
5 #include <testfwk.h>
7 #ifdef __SDCC
8 #pragma std_c99
9 #endif
11 /* Copyright (C) 2002 Free Software Foundation
13 Check that constant folding of shift operations is working.
15 Roger Sayle, 10th October 2002. */
17 extern void link_error (void);
19 void
20 utest (unsigned int x)
22 if (x >> 0 != x)
23 link_error ();
25 if (x << 0 != x)
26 link_error ();
28 if (0 << x != 0)
29 link_error ();
31 if (0 >> x != 0)
32 link_error ();
34 if (-1 >> x != -1)
35 link_error ();
37 if (~0 >> x != ~0)
38 link_error ();
41 void
42 stest (int x)
44 if (x >> 0 != x)
45 link_error ();
47 if (x << 0 != x)
48 link_error ();
50 if (0 << x != 0)
51 link_error ();
53 if (0 >> x != 0)
54 link_error ();
57 void
58 testTortureExecute (void)
60 utest(9);
61 utest(0);
63 stest(9);
64 stest(0);
66 return;
69 void
70 link_error ()
72 ASSERT (0);