aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/i386/iamcu/test_complex_returning.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2015-07-01 08:37:19 +0000
committerRichard Biener <rguenther@suse.de>2015-07-01 08:37:19 +0000
commitd9ab4649161bc60fc68c9bb36d54b28142a3797a (patch)
treee4a5056a7da5f93f5dbacd47b6f22b61fdf92aad /gcc/testsuite/gcc.target/i386/iamcu/test_complex_returning.c
parente79886b1b133e4fd15f1c5c16d3e5a28c1233c33 (diff)
parent00b24710e5527e8b51904824c6e2a7717455c233 (diff)
2015-07-01 Richard Biener <rguenther@suse.de>match-and-simplify
Merge from trunk r225116 through r225225. * match-bitwise.pd: Removed and merged remains into match.pd. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/match-and-simplify@225229 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.target/i386/iamcu/test_complex_returning.c')
-rw-r--r--gcc/testsuite/gcc.target/i386/iamcu/test_complex_returning.c83
1 files changed, 83 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.target/i386/iamcu/test_complex_returning.c b/gcc/testsuite/gcc.target/i386/iamcu/test_complex_returning.c
new file mode 100644
index 00000000000..9e9678d7b02
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/iamcu/test_complex_returning.c
@@ -0,0 +1,83 @@
+/* This is a small test case for returning a complex number. Written by
+ Andreas Jaeger. */
+
+#include "defines.h"
+
+
+#define BUILD_F_COMPLEX(real, imag) \
+ ({ __complex__ float __retval; \
+ __real__ __retval = (real); \
+ __imag__ __retval = (imag); \
+ __retval; })
+
+#define BUILD_D_COMPLEX(real, imag) \
+ ({ __complex__ double __retval; \
+ __real__ __retval = (real); \
+ __imag__ __retval = (imag); \
+ __retval; })
+
+#define BUILD_LD_COMPLEX(real, imag) \
+ ({ __complex__ long double __retval; \
+ __real__ __retval = (real); \
+ __imag__ __retval = (imag); \
+ __retval; })
+
+__complex__ float
+aj_f_times2 (__complex__ float x)
+{
+ __complex__ float res;
+
+ __real__ res = (2.0 * __real__ x);
+ __imag__ res = (2.0 * __imag__ x);
+
+ return res;
+}
+
+__complex__ double
+aj_d_times2 (__complex__ double x)
+{
+ __complex__ double res;
+
+ __real__ res = (2.0 * __real__ x);
+ __imag__ res = (2.0 * __imag__ x);
+
+ return res;
+}
+
+__complex__ long double
+aj_ld_times2 (__complex__ long double x)
+{
+ __complex__ long double res;
+
+ __real__ res = (2.0 * __real__ x);
+ __imag__ res = (2.0 * __imag__ x);
+
+ return res;
+}
+
+int
+main (void)
+{
+#ifdef CHECK_COMPLEX
+ _Complex float fc, fd;
+ _Complex double dc, dd;
+ _Complex long double ldc, ldd;
+
+ fc = BUILD_LD_COMPLEX (2.0f, 3.0f);
+ fd = aj_f_times2 (fc);
+
+ assert (__real__ fd == 4.0f && __imag__ fd == 6.0f);
+
+ dc = BUILD_LD_COMPLEX (2.0, 3.0);
+ dd = aj_ld_times2 (dc);
+
+ assert (__real__ dd == 4.0 && __imag__ dd == 6.0);
+
+ ldc = BUILD_LD_COMPLEX (2.0L, 3.0L);
+ ldd = aj_ld_times2 (ldc);
+
+ assert (__real__ ldd == 4.0L && __imag__ ldd == 6.0L);
+#endif
+
+ return 0;
+}