FSF GCC merge 02/23/03
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / compare-3.c
blob6549c904b52e1e3beeac2c7c44ef1df65039f227
1 /* Copyright (C) 2002 Free Software Foundation.
3 Test for composite comparison always true/false optimization.
5 Written by Roger Sayle, 7th June 2002. */
7 extern void link_error0 ();
8 extern void link_error1 ();
10 void
11 test1 (int x, int y)
13 if ((x==y) && (x!=y))
14 link_error0();
17 void
18 test2 (int x, int y)
20 if ((x<y) && (x>y))
21 link_error0();
24 void
25 test3 (int x, int y)
27 if ((x<y) && (y<x))
28 link_error0();
31 void
32 test4 (int x, int y)
34 if ((x==y) || (x!=y))
37 else
38 link_error1 ();
41 void
42 test5 (int x, int y)
44 if ((x>=y) || (x<y))
47 else
48 link_error1 ();
51 void
52 test6 (int x, int y)
54 if ((x<=y) || (y<x))
57 else
58 link_error1 ();
61 void
62 all_tests (int x, int y)
64 test1 (x, y);
65 test2 (x, y);
66 test3 (x, y);
67 test4 (x, y);
68 test5 (x, y);
69 test6 (x, y);
72 int
73 main ()
75 all_tests (0, 0);
76 all_tests (1, 2);
77 all_tests (4, 3);
79 return 0;
82 #ifndef __OPTIMIZE__
83 void link_error0() {}
84 void link_error1() {}
85 #endif /* ! __OPTIMIZE__ */