PR middle-end/77357 - strlen of constant strings not folded
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / 20040409-2w.c
blobf6c5f2c45d95a4ee82ebd7e05cefd4f0c1ea7ba9
1 /* { dg-additional-options "-fwrapv" } */
3 #include <limits.h>
5 extern void abort ();
7 int test3(int x)
9 return (x + INT_MIN) ^ 0x1234;
12 int test4(int x)
14 return (x ^ 0x1234) + INT_MIN;
17 int test5(int x)
19 return (x - INT_MIN) ^ 0x1234;
22 int test6(int x)
24 return (x ^ 0x1234) - INT_MIN;
27 int test9(int x)
29 int y = INT_MIN;
30 int z = 0x1234;
31 return (x + y) ^ z;
34 int test10(int x)
36 int y = 0x1234;
37 int z = INT_MIN;
38 return (x ^ y) + z;
41 int test11(int x)
43 int y = INT_MIN;
44 int z = 0x1234;
45 return (x - y) ^ z;
48 int test12(int x)
50 int y = 0x1234;
51 int z = INT_MIN;
52 return (x ^ y) - z;
56 void test(int a, int b)
58 if (test3(a) != b)
59 abort();
60 if (test4(a) != b)
61 abort();
62 if (test5(a) != b)
63 abort();
64 if (test6(a) != b)
65 abort();
66 if (test9(a) != b)
67 abort();
68 if (test10(a) != b)
69 abort();
70 if (test11(a) != b)
71 abort();
72 if (test12(a) != b)
73 abort();
77 int main()
79 #if INT_MAX == 2147483647
80 test(0x00000000,0x80001234);
81 test(0x00001234,0x80000000);
82 test(0x80000000,0x00001234);
83 test(0x80001234,0x00000000);
84 test(0x7fffffff,0xffffedcb);
85 test(0xffffffff,0x7fffedcb);
86 #endif
88 #if INT_MAX == 32767
89 test(0x0000,0x9234);
90 test(0x1234,0x8000);
91 test(0x8000,0x1234);
92 test(0x9234,0x0000);
93 test(0x7fff,0xedcb);
94 test(0xffff,0x6dcb);
95 #endif
97 return 0;