2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / shiftopt-1.c
blobfa9517a73dbb2a6b7671a81aba92c63952777c77
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 ();
47 if (-1 >> x != -1)
48 link_error ();
50 if (~0 >> x != ~0)
51 link_error ();
54 int
55 main ()
57 utest(9);
58 utest(0);
60 stest(9);
61 stest(0);
63 return 0;
66 #ifndef __OPTIMIZE__
67 void
68 link_error ()
70 abort ();
72 #endif