diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/gcc.dg/dfp/convert-complex.c | |
download | cbb-gcc-4.6.4-15d2061ac0796199866debe9ac87130894b0cdd3.tar.bz2 cbb-gcc-4.6.4-15d2061ac0796199866debe9ac87130894b0cdd3.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.dg/dfp/convert-complex.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/dfp/convert-complex.c | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/dfp/convert-complex.c b/gcc/testsuite/gcc.dg/dfp/convert-complex.c new file mode 100644 index 000000000..76eef87cb --- /dev/null +++ b/gcc/testsuite/gcc.dg/dfp/convert-complex.c @@ -0,0 +1,118 @@ +/* { dg-options "-O3" } */ + +/* N1150 5.3 Conversions between decimal floating and complex. + C99 6.3.1.7 Conversions, arithmetic operands, real and complex. */ + +#include "dfp-dbg.h" + +int +main () +{ + _Complex float cf; + _Complex double cd; + _Complex long double cld; + + _Decimal32 d32; + _Decimal64 d64; + _Decimal128 d128; + + cf = 2.0f * __extension__ 1i + 3.0f; + cd = 2.0 * __extension__ 1i + 3.0; + cld = 2.0l * __extension__ 1i + 3.0l; + + /* Convert complex to decimal floating. */ + d32 = cf; + d64 = cd; + d128 = cld; + + if (d32 != 3.0DF) + FAILURE + if (d64 != 3.0dd) + FAILURE + if (d128 != 3.0dl) + FAILURE + + /* Convert decimal floating to complex. */ + d32 = 2.5DF; + d64 = 1.5DD; + d128 = 2.5DL; + + cf = d32; + cd = d64; + cld = d128; + + /* N1107 5.3 Conversions between decimal floating and complex. + When a value of decimal floating type converted to a complex + type, the real part of the complex result value is undermined + by the rules of conversions in N1107 5.2 and the imaginary part + of the complex result value is zero. */ + + if (__real__ cf != 2.5f) + FAILURE + if (__real__ cd !=1.5) + FAILURE + if (__real__ cld != 2.5) + FAILURE + if (__imag__ cf != 0.0f) + FAILURE + if (__imag__ cd != 0.0) + FAILURE + if (__imag__ cld != 0.0l) + FAILURE + + /* Verify that the conversions from DFP types to complex is + determined by the rules of conversion to the real part. */ + + /* Convert _Decimal64 to _Complex float. */ + d64 = 0.125dl; + cf = d64; + if (__real__ cf != 0.125f) + FAILURE + /* Convert _Decimal128 to _Complex double. */ + d128 = 1.25E-7dl; + cd = d128; + if (__real__ cd != 1.25E-7) + FAILURE + + /* Verify that conversion from complex to decimal floating types + results in the value of the real part converted to the result + type according to the rules of conversion between those types. */ + + /* Convert _Complex float to decimal float types. */ + cf = 2.0f * __extension__ 1i + 2.25f; + d32 = cf; + d64 = cf; + d128 = cf; + if (d32 != 2.25DF) + FAILURE + if (d64 != 2.25DD) + FAILURE + if (d128 != 2.25DL) + FAILURE + + /* Convert _Complex double to decimal float types. */ + cd = 2.0 * __extension__ 1i + 1.25; + d32 = cd; + d64 = cd; + d128 = cd; + if (d32 != 1.25DF) + FAILURE + if (d64 != 1.25DD) + FAILURE + if (d128 != 1.25DL) + FAILURE + + /* Convert _Complex long double to decimal float types. */ + cld = 2.0l * __extension__ 1i + 0.0625l; + d32 = cld; + d64 = cld; + d128 = cld; + if (d32 != 0.0625DF) + FAILURE + if (d64 != 0.0625DD) + FAILURE + if (d128 != 0.0625DL) + FAILURE + + FINISH +} |