summaryrefslogtreecommitdiff
path: root/test/regression
diff options
context:
space:
mode:
authorGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2013-05-06 15:25:26 +0000
committerGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2013-05-06 15:25:26 +0000
commit884756b623fd6031a04102a545d92e4ec905f1cc (patch)
tree9e2804da54087bbcb44df675432dcb133294b8b6 /test/regression
parent76555ffd2403b3ebf1ea353063c16763e6493722 (diff)
Revised semantics and compilation of 2-argument C operators to better match
"the usual binary conversions" and be more robust towards future extensions e.g. with 32-bit float values. git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@2239 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'test/regression')
-rw-r--r--test/regression/Makefile2
-rw-r--r--test/regression/Results/binops98
-rw-r--r--test/regression/binops.c65
3 files changed, 164 insertions, 1 deletions
diff --git a/test/regression/Makefile b/test/regression/Makefile
index 643fba4..0d5e4c4 100644
--- a/test/regression/Makefile
+++ b/test/regression/Makefile
@@ -11,7 +11,7 @@ LIBS=$(LIBMATH)
TESTS=int32 int64 floats floats-basics \
expr1 expr6 funptr2 initializers volatile1 volatile2 volatile3 \
funct3 expr5 struct7 struct8 struct11 casts1 casts2 char1 \
- sizeof1 sizeof2
+ sizeof1 sizeof2 binops
# Can run, but only in compiled mode, and have reference output in Results
diff --git a/test/regression/Results/binops b/test/regression/Results/binops
new file mode 100644
index 0000000..099957d
--- /dev/null
+++ b/test/regression/Results/binops
@@ -0,0 +1,98 @@
+-12 + -12 = -24
+-12 + 32769 = 32757
+-12 + -43 = -55
+-12 + 3735928559 = 3735928547
+-12 + -123456789012 = -123456789024
+-12 + -2401053092593056409 = -2401053092593056421
+-12 + 0x1.921fb5452455p+1 = -0x1.1b7812aeb6eacp+3
+32769 + -12 = 32757
+32769 + 32769 = 65538
+32769 + -43 = 32726
+32769 + 3735928559 = 3735961328
+32769 + -123456789012 = -123456756243
+32769 + -2401053092593056409 = -2401053092593023640
+32769 + 0x1.921fb5452455p+1 = 0x1.0008487ed5149p+15
+-43 + -12 = -55
+-43 + 32769 = 32726
+-43 + -43 = -86
+-43 + 3735928559 = 3735928516
+-43 + -123456789012 = -123456789055
+-43 + -2401053092593056409 = -2401053092593056452
+-43 + 0x1.921fb5452455p+1 = -0x1.3ede04abadbabp+5
+3735928559 + -12 = 3735928547
+3735928559 + 32769 = 3735961328
+3735928559 + -43 = 3735928516
+3735928559 + 3735928559 = 3176889822
+3735928559 + -123456789012 = -119720860453
+3735928559 + -2401053092593056409 = -2401053088857127850
+3735928559 + 0x1.921fb5452455p+1 = 0x1.bd5b7de4487edp+31
+-123456789012 + -12 = -123456789024
+-123456789012 + 32769 = -123456756243
+-123456789012 + -43 = -123456789055
+-123456789012 + 3735928559 = -119720860453
+-123456789012 + -123456789012 = -246913578024
+-123456789012 + -2401053092593056409 = -2401053216049845421
+-123456789012 + 0x1.921fb5452455p+1 = -0x1.cbe991a10dbc1p+36
+-2401053092593056409 + -12 = -2401053092593056421
+-2401053092593056409 + 32769 = -2401053092593023640
+-2401053092593056409 + -43 = -2401053092593056452
+-2401053092593056409 + 3735928559 = -2401053088857127850
+-2401053092593056409 + -123456789012 = -2401053216049845421
+-2401053092593056409 + -2401053092593056409 = -4802106185186112818
+-2401053092593056409 + 0x1.921fb5452455p+1 = 0x1.bd5b7dde02469p+63
+0x1.921fb5452455p+1 + -12 = -0x1.1b7812aeb6eacp+3
+0x1.921fb5452455p+1 + 32769 = 0x1.0008487ed5149p+15
+0x1.921fb5452455p+1 + -43 = -0x1.3ede04abadbabp+5
+0x1.921fb5452455p+1 + 3735928559 = 0x1.bd5b7de4487edp+31
+0x1.921fb5452455p+1 + -123456789012 = -0x1.cbe991a10dbc1p+36
+0x1.921fb5452455p+1 + -2401053092593056409 = 0x1.bd5b7dde02469p+63
+0x1.921fb5452455p+1 + 0x1.5be76c8b43958p+1 = 0x1.770390e833f54p+2
+-12 / -12 = 1
+-12 / 32769 = 0
+-12 / -43 = 0
+-12 / 3735928559 = 1
+-12 / -123456789012 = 0
+-12 / -2401053092593056409 = 1
+-12 / 0x1.921fb5452455p+1 = -0x1.e8ec8a49d89b3p+1
+32769 / -12 = -2730
+32769 / 32769 = 1
+32769 / -43 = -762
+32769 / 3735928559 = 0
+32769 / -123456789012 = 0
+32769 / -2401053092593056409 = 0
+32769 / 0x1.921fb5452455p+1 = 0x1.45f592c1f3749p+13
+-43 / -12 = 3
+-43 / 32769 = 0
+-43 / -43 = 1
+-43 / 3735928559 = 1
+-43 / -123456789012 = 0
+-43 / -2401053092593056409 = 1
+-43 / 0x1.921fb5452455p+1 = -0x1.b5fe91377cb5bp+3
+3735928559 / -12 = 0
+3735928559 / 32769 = 114008
+3735928559 / -43 = 0
+3735928559 / 3735928559 = 1
+3735928559 / -123456789012 = 0
+3735928559 / -2401053092593056409 = 0
+3735928559 / 0x1.921fb5452455p+1 = 0x1.1b85f84900ce9p+30
+-123456789012 / -12 = 10288065751
+-123456789012 / 32769 = -3767487
+-123456789012 / -43 = 2871088116
+-123456789012 / 3735928559 = -33
+-123456789012 / -123456789012 = 1
+-123456789012 / -2401053092593056409 = 1
+-123456789012 / 0x1.921fb5452455p+1 = -0x1.24ca1074bca22p+35
+-2401053092593056409 / -12 = 0
+-2401053092593056409 / 32769 = 489660684827626
+-2401053092593056409 / -43 = 0
+-2401053092593056409 / 3735928559 = 4294967296
+-2401053092593056409 / -123456789012 = 0
+-2401053092593056409 / -2401053092593056409 = 1
+-2401053092593056409 / 0x1.921fb5452455p+1 = 0x1.1b85f84902417p+62
+0x1.921fb5452455p+1 / -12 = -0x1.0c1523836d8ep-2
+0x1.921fb5452455p+1 / 32769 = 0x1.921c910c023dp-14
+0x1.921fb5452455p+1 / -43 = -0x1.2b414569092d6p-4
+0x1.921fb5452455p+1 / 3735928559 = 0x1.ce4c0cc6e1623p-31
+0x1.921fb5452455p+1 / -123456789012 = -0x1.bfaaa712bb416p-36
+0x1.921fb5452455p+1 / -2401053092593056409 = 0x1.ce4c0cc6df058p-63
+0x1.921fb5452455p+1 / 0x1.5be76c8b43958p+1 = 0x1.27e599eaeb137p+0
diff --git a/test/regression/binops.c b/test/regression/binops.c
new file mode 100644
index 0000000..5aa8957
--- /dev/null
+++ b/test/regression/binops.c
@@ -0,0 +1,65 @@
+/* Testing overloading resolution for binary arithmetic */
+
+#include <stdio.h>
+
+signed short ss = -12;
+unsigned short us = 0x8001;
+signed int si = -43;
+unsigned int ui = 0xDEADBEEF;
+signed long long sl = -123456789012LL;
+unsigned long long ul = 0xDEADBEEF01234567ULL;
+double d = 3.141592654;
+double d2 = 2.718;
+
+void print_ii(char * op, long long a1, long long a2, long long res)
+{
+ printf("%lld %s %lld = %lld\n", a1, op, a2, res);
+}
+
+void print_di(char * op, double a1, long long a2, double res)
+{
+ printf("%a %s %lld = %a\n", a1, op, a2, res);
+}
+
+void print_id(char * op, long long a1, double a2, double res)
+{
+ printf("%lld %s %a = %a\n", a1, op, a2, res);
+}
+
+void print_dd(char * op, double a1, double a2, double res)
+{
+ printf("%a %s %a = %a\n", a1, op, a2, res);
+}
+
+#define TEST1(op,a1) \
+ print_ii(#op, a1, ss, a1 op ss); \
+ print_ii(#op, a1, us, a1 op us); \
+ print_ii(#op, a1, si, a1 op si); \
+ print_ii(#op, a1, ui, a1 op ui); \
+ print_ii(#op, a1, sl, a1 op sl); \
+ print_ii(#op, a1, ul, a1 op ul); \
+ print_id(#op, a1, d, a1 op d)
+
+#define TEST2(op) \
+ TEST1(op,ss); \
+ TEST1(op,us); \
+ TEST1(op,si); \
+ TEST1(op,ui); \
+ TEST1(op,sl); \
+ TEST1(op,ul); \
+ print_di(#op, d, ss, d op ss); \
+ print_di(#op, d, us, d op us); \
+ print_di(#op, d, si, d op si); \
+ print_di(#op, d, ui, d op ui); \
+ print_di(#op, d, sl, d op sl); \
+ print_di(#op, d, ul, d op ul); \
+ print_dd(#op, d, d2, d op d2)
+
+int main()
+{
+ TEST2( + );
+ TEST2( / );
+ return 0;
+}
+
+