summaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/dfp/operator-assignment.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/c-c++-common/dfp/operator-assignment.c
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.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/c-c++-common/dfp/operator-assignment.c')
-rw-r--r--gcc/testsuite/c-c++-common/dfp/operator-assignment.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/gcc/testsuite/c-c++-common/dfp/operator-assignment.c b/gcc/testsuite/c-c++-common/dfp/operator-assignment.c
new file mode 100644
index 000000000..faadf1e86
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/dfp/operator-assignment.c
@@ -0,0 +1,56 @@
+/* C99 6.5.16 Assignment operators.
+ Verify the compound assignment operator for decimal float types,
+ using it with other decimal float types, integers, and other binary
+ float types cast to decimal float types. */
+
+#include "dfp-dbg.h"
+
+#define OPERATE(OPRD1,OPRT,OPRD2,RLT) \
+ if (( OPRD1 OPRT OPRD2 )!= RLT) \
+ FAILURE
+
+#define DECIMAL_COMPOUND_ASSIGNMENT(TYPE, OPRD) \
+{ \
+ _Decimal##TYPE d = OPRD; \
+ OPERATE(d,+=,1,(OPRD + 1)); \
+ d = OPRD; \
+ OPERATE(d,+=,0,OPRD); \
+ d = OPRD; \
+ OPERATE(d,+=,(-1),(OPRD - 1)); \
+ d = OPRD; \
+ OPERATE(d,+=,d32a,(OPRD + d32a)); \
+ d = OPRD; \
+ OPERATE(d,+=,d64a,(OPRD + d64a)); \
+ d = OPRD; \
+ OPERATE(d,+=,d128a,(OPRD + d128a)); \
+ d = OPRD; \
+ OPERATE(d,+=,(_Decimal##TYPE)1.1,(OPRD + (_Decimal##TYPE)1.1)); \
+ d = OPRD; \
+ OPERATE(d,+=,(_Decimal##TYPE)2.2f,(OPRD + (_Decimal##TYPE)2.2f)); \
+ d = OPRD; \
+ OPERATE(d,-=,1,(OPRD - 1)); \
+ d = OPRD; \
+ OPERATE(d,-=,0,OPRD); \
+ d = OPRD; \
+ OPERATE(d,-=,(-1),(OPRD + 1)); \
+ d = OPRD; \
+ OPERATE(d,-=,d32a,OPRD-d32a); \
+ d = OPRD; \
+ OPERATE(d,-=,d64a,OPRD-d64a); \
+ d = OPRD; \
+ OPERATE(d,-=,d128a,OPRD-d128a); \
+}
+
+int
+main ()
+{
+ _Decimal32 d32 = 1.23456df, d32a = 1.2df;
+ _Decimal64 d64 = 23.456789dd, d64a = 2.8dd;
+ _Decimal128 d128 = 345.67890123456789dl, d128a = 4.7dl;
+
+ DECIMAL_COMPOUND_ASSIGNMENT(32, d32);
+ DECIMAL_COMPOUND_ASSIGNMENT(64, d64);
+ DECIMAL_COMPOUND_ASSIGNMENT(128, d128);
+
+ FINISH
+}