summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.c-torture/execute/int-compare.c
blob: 017a8cc3f15bd71b22343438ff6cef462c31af96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#include <limits.h>

gt (a, b)
{
  return a > b;
}

ge (a, b)
{
  return a >= b;
}

lt (a, b)
{
  return a < b;
}

le (a, b)
{
  return a <= b;
}

void
true (c)
{
  if (!c)
    abort();
}

void
false (c)
{
  if (c)
    abort();
}

f ()
{
  true (gt (2, 1));
  false (gt (1, 2));

  true (gt (INT_MAX, 0));
  false (gt (0, INT_MAX));
  true (gt (INT_MAX, 1));
  false (gt (1, INT_MAX));

  false (gt (INT_MIN, 0));
  true (gt (0, INT_MIN));
  false (gt (INT_MIN, 1));
  true (gt (1, INT_MIN));

  true (gt (INT_MAX, INT_MIN));
  false (gt (INT_MIN, INT_MAX));

  true (ge (2, 1));
  false (ge (1, 2));

  true (ge (INT_MAX, 0));
  false (ge (0, INT_MAX));
  true (ge (INT_MAX, 1));
  false (ge (1, INT_MAX));

  false (ge (INT_MIN, 0));
  true (ge (0, INT_MIN));
  false (ge (INT_MIN, 1));
  true (ge (1, INT_MIN));

  true (ge (INT_MAX, INT_MIN));
  false (ge (INT_MIN, INT_MAX));

  false (lt (2, 1));
  true (lt (1, 2));

  false (lt (INT_MAX, 0));
  true (lt (0, INT_MAX));
  false (lt (INT_MAX, 1));
  true (lt (1, INT_MAX));

  true (lt (INT_MIN, 0));
  false (lt (0, INT_MIN));
  true (lt (INT_MIN, 1));
  false (lt (1, INT_MIN));

  false (lt (INT_MAX, INT_MIN));
  true (lt (INT_MIN, INT_MAX));

  false (le (2, 1));
  true (le (1, 2));

  false (le (INT_MAX, 0));
  true (le (0, INT_MAX));
  false (le (INT_MAX, 1));
  true (le (1, INT_MAX));

  true (le (INT_MIN, 0));
  false (le (0, INT_MIN));
  true (le (INT_MIN, 1));
  false (le (1, INT_MIN));

  false (le (INT_MAX, INT_MIN));
  true (le (INT_MIN, INT_MAX));
}

main ()
{
  f ();
  exit (0);
}