PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / 20040409-3w.c
blob3a1883d51d59a322e3441b7ea38dae8319e816ce
1 /* { dg-additional-options "-fwrapv" } */
3 #include <limits.h>
5 extern void abort ();
7 int test2(int x)
9 return ~(x + INT_MIN);
12 int test3(int x)
14 return ~(x - INT_MIN);
17 int test5(int x)
19 int y = INT_MIN;
20 return ~(x + y);
23 int test6(int x)
25 int y = INT_MIN;
26 return ~(x - y);
30 void test(int a, int b)
32 if (test2(a) != b)
33 abort();
34 if (test3(a) != b)
35 abort();
36 if (test5(a) != b)
37 abort();
38 if (test6(a) != b)
39 abort();
43 int main()
45 #if INT_MAX == 2147483647
46 test(0x00000000,0x7fffffff);
47 test(0x80000000,0xffffffff);
48 test(0x12345678,0x6dcba987);
49 test(0x92345678,0xedcba987);
50 test(0x7fffffff,0x00000000);
51 test(0xffffffff,0x80000000);
52 #endif
54 #if INT_MAX == 32767
55 test(0x0000,0x7fff);
56 test(0x8000,0xffff);
57 test(0x1234,0x6dcb);
58 test(0x9234,0xedcb);
59 test(0x7fff,0x0000);
60 test(0xffff,0x8000);
61 #endif
63 return 0;