summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.c-torture/execute/int-compare.c
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/gcc.c-torture/execute/int-compare.c
downloadcbb-gcc-4.6.4-upstream.tar.bz2
cbb-gcc-4.6.4-upstream.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/gcc.c-torture/execute/int-compare.c')
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/int-compare.c108
1 files changed, 108 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.c-torture/execute/int-compare.c b/gcc/testsuite/gcc.c-torture/execute/int-compare.c
new file mode 100644
index 000000000..017a8cc3f
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/int-compare.c
@@ -0,0 +1,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);
+}