* gcc.target/i386/pr70021.c: Add -mtune=skylake.
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / iamcu / test_complex_returning.c
blob9e9678d7b024146323f21f8845aaea2260462ef9
1 /* This is a small test case for returning a complex number. Written by
2 Andreas Jaeger. */
4 #include "defines.h"
7 #define BUILD_F_COMPLEX(real, imag) \
8 ({ __complex__ float __retval; \
9 __real__ __retval = (real); \
10 __imag__ __retval = (imag); \
11 __retval; })
13 #define BUILD_D_COMPLEX(real, imag) \
14 ({ __complex__ double __retval; \
15 __real__ __retval = (real); \
16 __imag__ __retval = (imag); \
17 __retval; })
19 #define BUILD_LD_COMPLEX(real, imag) \
20 ({ __complex__ long double __retval; \
21 __real__ __retval = (real); \
22 __imag__ __retval = (imag); \
23 __retval; })
25 __complex__ float
26 aj_f_times2 (__complex__ float x)
28 __complex__ float res;
30 __real__ res = (2.0 * __real__ x);
31 __imag__ res = (2.0 * __imag__ x);
33 return res;
36 __complex__ double
37 aj_d_times2 (__complex__ double x)
39 __complex__ double res;
41 __real__ res = (2.0 * __real__ x);
42 __imag__ res = (2.0 * __imag__ x);
44 return res;
47 __complex__ long double
48 aj_ld_times2 (__complex__ long double x)
50 __complex__ long double res;
52 __real__ res = (2.0 * __real__ x);
53 __imag__ res = (2.0 * __imag__ x);
55 return res;
58 int
59 main (void)
61 #ifdef CHECK_COMPLEX
62 _Complex float fc, fd;
63 _Complex double dc, dd;
64 _Complex long double ldc, ldd;
66 fc = BUILD_LD_COMPLEX (2.0f, 3.0f);
67 fd = aj_f_times2 (fc);
69 assert (__real__ fd == 4.0f && __imag__ fd == 6.0f);
71 dc = BUILD_LD_COMPLEX (2.0, 3.0);
72 dd = aj_ld_times2 (dc);
74 assert (__real__ dd == 4.0 && __imag__ dd == 6.0);
76 ldc = BUILD_LD_COMPLEX (2.0L, 3.0L);
77 ldd = aj_ld_times2 (ldc);
79 assert (__real__ ldd == 4.0L && __imag__ ldd == 6.0L);
80 #endif
82 return 0;