Create embedded-5_0-branch branch for development on ARM embedded cores.
[official-gcc.git] / embedded-5_0-branch / gcc / testsuite / gcc.c-torture / execute / shiftopt-1.c
blob8c855b88895bbe211a683c34a984ed14176db6dc
1 /* Copyright (C) 2002 Free Software Foundation
3 Check that constant folding of shift operations is working.
5 Roger Sayle, 10th October 2002. */
7 extern void abort (void);
8 extern void link_error (void);
10 void
11 utest (unsigned int x)
13 if (x >> 0 != x)
14 link_error ();
16 if (x << 0 != x)
17 link_error ();
19 if (0 << x != 0)
20 link_error ();
22 if (0 >> x != 0)
23 link_error ();
25 if (-1 >> x != -1)
26 link_error ();
28 if (~0 >> x != ~0)
29 link_error ();
32 void
33 stest (int x)
35 if (x >> 0 != x)
36 link_error ();
38 if (x << 0 != x)
39 link_error ();
41 if (0 << x != 0)
42 link_error ();
44 if (0 >> x != 0)
45 link_error ();
48 int
49 main ()
51 utest(9);
52 utest(0);
54 stest(9);
55 stest(0);
57 return 0;
60 #ifndef __OPTIMIZE__
61 void
62 link_error ()
64 abort ();
66 #endif