modernc.org/ccgo/v3@v3.16.14/lib/testdata/gcc-9.1.0/gcc/testsuite/gcc.c-torture/execute/shiftopt-1.c (about) 1 /* Copyright (C) 2002 Free Software Foundation 2 3 Check that constant folding of shift operations is working. 4 5 Roger Sayle, 10th October 2002. */ 6 7 extern void abort (void); 8 extern void link_error (void); 9 10 void 11 utest (unsigned int x) 12 { 13 if (x >> 0 != x) 14 link_error (); 15 16 if (x << 0 != x) 17 link_error (); 18 19 if (0 << x != 0) 20 link_error (); 21 22 if (0 >> x != 0) 23 link_error (); 24 25 if (-1 >> x != -1) 26 link_error (); 27 28 if (~0 >> x != ~0) 29 link_error (); 30 } 31 32 void 33 stest (int x) 34 { 35 if (x >> 0 != x) 36 link_error (); 37 38 if (x << 0 != x) 39 link_error (); 40 41 if (0 << x != 0) 42 link_error (); 43 44 if (0 >> x != 0) 45 link_error (); 46 } 47 48 int 49 main () 50 { 51 utest(9); 52 utest(0); 53 54 stest(9); 55 stest(0); 56 57 return 0; 58 } 59 60 #ifndef __OPTIMIZE__ 61 void 62 link_error () 63 { 64 abort (); 65 } 66 #endif 67