From: Janis Johnson Date: Fri, 18 Sep 2009 17:40:28 +0000 (+0000) Subject: dfp.exp: Also run tests in c-c++-common/dfp. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5eb8c44fc892725861f2cdce643d7776d6991e4a;p=gcc.git dfp.exp: Also run tests in c-c++-common/dfp. * gcc.dg/dfp/dfp.exp: Also run tests in c-c++-common/dfp. * c-c++-common/dfp: New directory. * c-c++-common/dfp/dfp-dbg.h: New file. * gcc.dg/dfp/call-by-value.c: Move to ... * c-c++-common/call-by-value.c: here. * gcc.dg/dfp/cast.c: Move to ... * c-c++-common/cast.c: here. * gcc.dg/dfp/compare-eq-const.c: Move to ... * c-c++-common/compare-eq-const.c: here. * gcc.dg/dfp/compare-eq-d128.c: Move to ... * c-c++-common/compare-eq-d128.c: here. * gcc.dg/dfp/compare-eq-d32.c: Move to ... * c-c++-common/compare-eq-d32.c: here. * gcc.dg/dfp/compare-eq-d64.c: Move to ... * c-c++-common/compare-eq-d64.c: here. * gcc.dg/dfp/compare-eq-dfp.c: Move to ... * c-c++-common/compare-eq-dfp.c: here. * gcc.dg/dfp/compare-eq.h: Move to ... * c-c++-common/compare-eq.h: here. * gcc.dg/dfp/compare-rel-const.c: Move to ... * c-c++-common/compare-rel-const.c: here. * gcc.dg/dfp/compare-rel-d128.c: Move to ... * c-c++-common/compare-rel-d128.c: here. * gcc.dg/dfp/compare-rel-d32.c: Move to ... * c-c++-common/compare-rel-d32.c: here. * gcc.dg/dfp/compare-rel-d64.c: Move to ... * c-c++-common/compare-rel-d64.c: here. * gcc.dg/dfp/compare-rel-dfp.c: Move to ... * c-c++-common/compare-rel-dfp.c: here. * gcc.dg/dfp/compare-rel.h: Move to ... * c-c++-common/compare-rel.h: here. * gcc.dg/dfp/compare-special-d128.c: Move to ... * c-c++-common/compare-special-d128.c: here. * gcc.dg/dfp/compare-special-d32.c: Move to ... * c-c++-common/compare-special-d32.c: here. * gcc.dg/dfp/compare-special-d64.c: Move to ... * c-c++-common/compare-special-d64.c: here. * gcc.dg/dfp/compare-special.h: Move to ... * c-c++-common/compare-special.h: here. * gcc.dg/dfp/constants-zero.c: Move to ... * c-c++-common/constants-zero.c: here. * gcc.dg/dfp/convert-bfp-10.c: Move to ... * c-c++-common/convert-bfp-10.c: here. * gcc.dg/dfp/convert-bfp-11.c: Move to ... * c-c++-common/convert-bfp-11.c: here. * gcc.dg/dfp/convert-bfp-12.c: Move to ... * c-c++-common/convert-bfp-12.c: here. * gcc.dg/dfp/convert-bfp-13.c: Move to ... * c-c++-common/convert-bfp-13.c: here. * gcc.dg/dfp/convert-bfp-14.c: Move to ... * c-c++-common/convert-bfp-14.c: here. * gcc.dg/dfp/convert-bfp-2.c: Move to ... * c-c++-common/convert-bfp-2.c: here. * gcc.dg/dfp/convert-bfp-3.c: Move to ... * c-c++-common/convert-bfp-3.c: here. * gcc.dg/dfp/convert-bfp-4.c: Move to ... * c-c++-common/convert-bfp-4.c: here. * gcc.dg/dfp/convert-bfp-5.c: Move to ... * c-c++-common/convert-bfp-5.c: here. * gcc.dg/dfp/convert-bfp-6.c: Move to ... * c-c++-common/convert-bfp-6.c: here. * gcc.dg/dfp/convert-bfp-7.c: Move to ... * c-c++-common/convert-bfp-7.c: here. * gcc.dg/dfp/convert-bfp-8.c: Move to ... * c-c++-common/convert-bfp-8.c: here. * gcc.dg/dfp/convert-bfp-9.c: Move to ... * c-c++-common/convert-bfp-9.c: here. * gcc.dg/dfp/convert-bfp.c: Move to ... * c-c++-common/convert-bfp.c: here. * gcc.dg/dfp/convert-bfp-fold.c: Move to ... * c-c++-common/convert-bfp-fold.c: here. * gcc.dg/dfp/convert-dfp.c: Move to ... * c-c++-common/convert-dfp.c: here. * gcc.dg/dfp/convert-dfp-fold-2.c: Move to ... * c-c++-common/convert-dfp-fold-2.c: here. * gcc.dg/dfp/convert-dfp-fold.c: Move to ... * c-c++-common/convert-dfp-fold.c: here. * gcc.dg/dfp/convert.h: Move to ... * c-c++-common/convert.h: here. * gcc.dg/dfp/convert-int.c: Move to ... * c-c++-common/convert-int.c: here. * gcc.dg/dfp/convert-int-fold.c: Move to ... * c-c++-common/convert-int-fold.c: here. * gcc.dg/dfp/convert-int-max.c: Move to ... * c-c++-common/convert-int-max.c: here. * gcc.dg/dfp/convert-int-max-fold.c: Move to ... * c-c++-common/convert-int-max-fold.c: here. * gcc.dg/dfp/convert-int-saturate.c: Move to ... * c-c++-common/convert-int-saturate.c: here. * gcc.dg/dfp/func-array.c: Move to ... * c-c++-common/func-array.c: here. * gcc.dg/dfp/func-deref.c: Move to ... * c-c++-common/func-deref.c: here. * gcc.dg/dfp/func-mixed.c: Move to ... * c-c++-common/func-mixed.c: here. * gcc.dg/dfp/func-pointer.c: Move to ... * c-c++-common/func-pointer.c: here. * gcc.dg/dfp/func-scalar.c: Move to ... * c-c++-common/func-scalar.c: here. * gcc.dg/dfp/func-struct.c: Move to ... * c-c++-common/func-struct.c: here. * gcc.dg/dfp/func-vararg-alternate-d128-2.c: Move to ... * c-c++-common/func-vararg-alternate-d128-2.c: here. * gcc.dg/dfp/func-vararg-alternate-d128.c: Move to ... * c-c++-common/func-vararg-alternate-d128.c: here. * gcc.dg/dfp/func-vararg-alternate-d32.c: Move to ... * c-c++-common/func-vararg-alternate-d32.c: here. * gcc.dg/dfp/func-vararg-alternate-d64.c: Move to ... * c-c++-common/func-vararg-alternate-d64.c: here. * gcc.dg/dfp/func-vararg-alternate.h: Move to ... * c-c++-common/func-vararg-alternate.h: here. * gcc.dg/dfp/func-vararg-dfp.c: Move to ... * c-c++-common/func-vararg-dfp.c: here. * gcc.dg/dfp/func-vararg-mixed-2.c: Move to ... * c-c++-common/func-vararg-mixed-2.c: here. * gcc.dg/dfp/func-vararg-mixed.c: Move to ... * c-c++-common/func-vararg-mixed.c: here. * gcc.dg/dfp/func-vararg-size0.c: Move to ... * c-c++-common/func-vararg-size0.c: here. * gcc.dg/dfp/inf-1.c: Move to ... * c-c++-common/inf-1.c: here. * gcc.dg/dfp/loop-index.c: Move to ... * c-c++-common/loop-index.c: here. * gcc.dg/dfp/modes.c: Move to ... * c-c++-common/modes.c: here. * gcc.dg/dfp/nan-1.c: Move to ... * c-c++-common/nan-1.c: here. * gcc.dg/dfp/nan-2.c: Move to ... * c-c++-common/nan-2.c: here. * gcc.dg/dfp/operator-arith-fold.c: Move to ... * c-c++-common/operator-arith-fold.c: here. * gcc.dg/dfp/operator-assignment.c: Move to ... * c-c++-common/operator-assignment.c: here. * gcc.dg/dfp/operator-comma.c: Move to ... * c-c++-common/operator-comma.c: here. * gcc.dg/dfp/operator-cond.c: Move to ... * c-c++-common/operator-cond.c: here. * gcc.dg/dfp/operator-logical.c: Move to ... * c-c++-common/operator-logical.c: here. * gcc.dg/dfp/operator-unary.c: Move to ... * c-c++-common/operator-unary.c: here. * gcc.dg/dfp/pr31385.c: Move to ... * c-c++-common/pr31385.c: here. * gcc.dg/dfp/pr33466.c: Move to ... * c-c++-common/pr33466.c: here. * gcc.dg/dfp/pr35620.c: Move to ... * c-c++-common/pr35620.c: here. * gcc.dg/dfp/pr36800.c: Move to ... * c-c++-common/pr36800.c: here. * gcc.dg/dfp/pr39034.c: Move to ... * c-c++-common/pr39034.c: here. * gcc.dg/dfp/pr39035.c: Move to ... * c-c++-common/pr39035.c: here. * gcc.dg/dfp/pr39902.c: Move to ... * c-c++-common/pr39902.c: here. * gcc.dg/dfp/pr39986.c: Move to ... * c-c++-common/pr39986.c: here. * gcc.dg/dfp/signbit-1.c: Move to ... * c-c++-common/signbit-1.c: here. * gcc.dg/dfp/signbit-2.c: Move to ... * c-c++-common/signbit-2.c: here. * gcc.dg/dfp/struct-layout-1.c: Move to ... * c-c++-common/struct-layout-1.c: here. * gcc.dg/dfp/usual-arith-conv.c: Move to ... * c-c++-common/usual-arith-conv.c: here. * gcc.dg/dfp/usual-arith-conv-const.c: Move to ... * c-c++-common/usual-arith-conv-const.c: here. From-SVN: r151861 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4c2d36553f7..e4e7a21af78 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,173 @@ +2009-09-18 Janis Johnson + + * gcc.dg/dfp/dfp.exp: Also run tests in c-c++-common/dfp. + * c-c++-common/dfp: New directory. + * c-c++-common/dfp/dfp-dbg.h: New file. + * gcc.dg/dfp/call-by-value.c: Move to ... + * c-c++-common/call-by-value.c: here. + * gcc.dg/dfp/cast.c: Move to ... + * c-c++-common/cast.c: here. + * gcc.dg/dfp/compare-eq-const.c: Move to ... + * c-c++-common/compare-eq-const.c: here. + * gcc.dg/dfp/compare-eq-d128.c: Move to ... + * c-c++-common/compare-eq-d128.c: here. + * gcc.dg/dfp/compare-eq-d32.c: Move to ... + * c-c++-common/compare-eq-d32.c: here. + * gcc.dg/dfp/compare-eq-d64.c: Move to ... + * c-c++-common/compare-eq-d64.c: here. + * gcc.dg/dfp/compare-eq-dfp.c: Move to ... + * c-c++-common/compare-eq-dfp.c: here. + * gcc.dg/dfp/compare-eq.h: Move to ... + * c-c++-common/compare-eq.h: here. + * gcc.dg/dfp/compare-rel-const.c: Move to ... + * c-c++-common/compare-rel-const.c: here. + * gcc.dg/dfp/compare-rel-d128.c: Move to ... + * c-c++-common/compare-rel-d128.c: here. + * gcc.dg/dfp/compare-rel-d32.c: Move to ... + * c-c++-common/compare-rel-d32.c: here. + * gcc.dg/dfp/compare-rel-d64.c: Move to ... + * c-c++-common/compare-rel-d64.c: here. + * gcc.dg/dfp/compare-rel-dfp.c: Move to ... + * c-c++-common/compare-rel-dfp.c: here. + * gcc.dg/dfp/compare-rel.h: Move to ... + * c-c++-common/compare-rel.h: here. + * gcc.dg/dfp/compare-special-d128.c: Move to ... + * c-c++-common/compare-special-d128.c: here. + * gcc.dg/dfp/compare-special-d32.c: Move to ... + * c-c++-common/compare-special-d32.c: here. + * gcc.dg/dfp/compare-special-d64.c: Move to ... + * c-c++-common/compare-special-d64.c: here. + * gcc.dg/dfp/compare-special.h: Move to ... + * c-c++-common/compare-special.h: here. + * gcc.dg/dfp/constants-zero.c: Move to ... + * c-c++-common/constants-zero.c: here. + * gcc.dg/dfp/convert-bfp-10.c: Move to ... + * c-c++-common/convert-bfp-10.c: here. + * gcc.dg/dfp/convert-bfp-11.c: Move to ... + * c-c++-common/convert-bfp-11.c: here. + * gcc.dg/dfp/convert-bfp-12.c: Move to ... + * c-c++-common/convert-bfp-12.c: here. + * gcc.dg/dfp/convert-bfp-13.c: Move to ... + * c-c++-common/convert-bfp-13.c: here. + * gcc.dg/dfp/convert-bfp-14.c: Move to ... + * c-c++-common/convert-bfp-14.c: here. + * gcc.dg/dfp/convert-bfp-2.c: Move to ... + * c-c++-common/convert-bfp-2.c: here. + * gcc.dg/dfp/convert-bfp-3.c: Move to ... + * c-c++-common/convert-bfp-3.c: here. + * gcc.dg/dfp/convert-bfp-4.c: Move to ... + * c-c++-common/convert-bfp-4.c: here. + * gcc.dg/dfp/convert-bfp-5.c: Move to ... + * c-c++-common/convert-bfp-5.c: here. + * gcc.dg/dfp/convert-bfp-6.c: Move to ... + * c-c++-common/convert-bfp-6.c: here. + * gcc.dg/dfp/convert-bfp-7.c: Move to ... + * c-c++-common/convert-bfp-7.c: here. + * gcc.dg/dfp/convert-bfp-8.c: Move to ... + * c-c++-common/convert-bfp-8.c: here. + * gcc.dg/dfp/convert-bfp-9.c: Move to ... + * c-c++-common/convert-bfp-9.c: here. + * gcc.dg/dfp/convert-bfp.c: Move to ... + * c-c++-common/convert-bfp.c: here. + * gcc.dg/dfp/convert-bfp-fold.c: Move to ... + * c-c++-common/convert-bfp-fold.c: here. + * gcc.dg/dfp/convert-dfp.c: Move to ... + * c-c++-common/convert-dfp.c: here. + * gcc.dg/dfp/convert-dfp-fold-2.c: Move to ... + * c-c++-common/convert-dfp-fold-2.c: here. + * gcc.dg/dfp/convert-dfp-fold.c: Move to ... + * c-c++-common/convert-dfp-fold.c: here. + * gcc.dg/dfp/convert.h: Move to ... + * c-c++-common/convert.h: here. + * gcc.dg/dfp/convert-int.c: Move to ... + * c-c++-common/convert-int.c: here. + * gcc.dg/dfp/convert-int-fold.c: Move to ... + * c-c++-common/convert-int-fold.c: here. + * gcc.dg/dfp/convert-int-max.c: Move to ... + * c-c++-common/convert-int-max.c: here. + * gcc.dg/dfp/convert-int-max-fold.c: Move to ... + * c-c++-common/convert-int-max-fold.c: here. + * gcc.dg/dfp/convert-int-saturate.c: Move to ... + * c-c++-common/convert-int-saturate.c: here. + * gcc.dg/dfp/func-array.c: Move to ... + * c-c++-common/func-array.c: here. + * gcc.dg/dfp/func-deref.c: Move to ... + * c-c++-common/func-deref.c: here. + * gcc.dg/dfp/func-mixed.c: Move to ... + * c-c++-common/func-mixed.c: here. + * gcc.dg/dfp/func-pointer.c: Move to ... + * c-c++-common/func-pointer.c: here. + * gcc.dg/dfp/func-scalar.c: Move to ... + * c-c++-common/func-scalar.c: here. + * gcc.dg/dfp/func-struct.c: Move to ... + * c-c++-common/func-struct.c: here. + * gcc.dg/dfp/func-vararg-alternate-d128-2.c: Move to ... + * c-c++-common/func-vararg-alternate-d128-2.c: here. + * gcc.dg/dfp/func-vararg-alternate-d128.c: Move to ... + * c-c++-common/func-vararg-alternate-d128.c: here. + * gcc.dg/dfp/func-vararg-alternate-d32.c: Move to ... + * c-c++-common/func-vararg-alternate-d32.c: here. + * gcc.dg/dfp/func-vararg-alternate-d64.c: Move to ... + * c-c++-common/func-vararg-alternate-d64.c: here. + * gcc.dg/dfp/func-vararg-alternate.h: Move to ... + * c-c++-common/func-vararg-alternate.h: here. + * gcc.dg/dfp/func-vararg-dfp.c: Move to ... + * c-c++-common/func-vararg-dfp.c: here. + * gcc.dg/dfp/func-vararg-mixed-2.c: Move to ... + * c-c++-common/func-vararg-mixed-2.c: here. + * gcc.dg/dfp/func-vararg-mixed.c: Move to ... + * c-c++-common/func-vararg-mixed.c: here. + * gcc.dg/dfp/func-vararg-size0.c: Move to ... + * c-c++-common/func-vararg-size0.c: here. + * gcc.dg/dfp/inf-1.c: Move to ... + * c-c++-common/inf-1.c: here. + * gcc.dg/dfp/loop-index.c: Move to ... + * c-c++-common/loop-index.c: here. + * gcc.dg/dfp/modes.c: Move to ... + * c-c++-common/modes.c: here. + * gcc.dg/dfp/nan-1.c: Move to ... + * c-c++-common/nan-1.c: here. + * gcc.dg/dfp/nan-2.c: Move to ... + * c-c++-common/nan-2.c: here. + * gcc.dg/dfp/operator-arith-fold.c: Move to ... + * c-c++-common/operator-arith-fold.c: here. + * gcc.dg/dfp/operator-assignment.c: Move to ... + * c-c++-common/operator-assignment.c: here. + * gcc.dg/dfp/operator-comma.c: Move to ... + * c-c++-common/operator-comma.c: here. + * gcc.dg/dfp/operator-cond.c: Move to ... + * c-c++-common/operator-cond.c: here. + * gcc.dg/dfp/operator-logical.c: Move to ... + * c-c++-common/operator-logical.c: here. + * gcc.dg/dfp/operator-unary.c: Move to ... + * c-c++-common/operator-unary.c: here. + * gcc.dg/dfp/pr31385.c: Move to ... + * c-c++-common/pr31385.c: here. + * gcc.dg/dfp/pr33466.c: Move to ... + * c-c++-common/pr33466.c: here. + * gcc.dg/dfp/pr35620.c: Move to ... + * c-c++-common/pr35620.c: here. + * gcc.dg/dfp/pr36800.c: Move to ... + * c-c++-common/pr36800.c: here. + * gcc.dg/dfp/pr39034.c: Move to ... + * c-c++-common/pr39034.c: here. + * gcc.dg/dfp/pr39035.c: Move to ... + * c-c++-common/pr39035.c: here. + * gcc.dg/dfp/pr39902.c: Move to ... + * c-c++-common/pr39902.c: here. + * gcc.dg/dfp/pr39986.c: Move to ... + * c-c++-common/pr39986.c: here. + * gcc.dg/dfp/signbit-1.c: Move to ... + * c-c++-common/signbit-1.c: here. + * gcc.dg/dfp/signbit-2.c: Move to ... + * c-c++-common/signbit-2.c: here. + * gcc.dg/dfp/struct-layout-1.c: Move to ... + * c-c++-common/struct-layout-1.c: here. + * gcc.dg/dfp/usual-arith-conv.c: Move to ... + * c-c++-common/usual-arith-conv.c: here. + * gcc.dg/dfp/usual-arith-conv-const.c: Move to ... + * c-c++-common/usual-arith-conv-const.c: here. + 2009-09-18 Jack Howarth PR testsuite/41288 diff --git a/gcc/testsuite/c-c++-common/dfp/call-by-value.c b/gcc/testsuite/c-c++-common/dfp/call-by-value.c new file mode 100644 index 00000000000..74aec53aefb --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/call-by-value.c @@ -0,0 +1,43 @@ +/* C99 6.9.1(9) Function definitions; parameter has automatic storage. + + Test that actual parameters are passed by value and that modifications + made within functions are lost on function return. */ + +#include "dfp-dbg.h" + +int foo32 (_Decimal32 z) +{ + z = z + 1.0df; +} + +int foo64 (_Decimal64 z) +{ + z = z + 1.0dd; +} + +int foo128 (_Decimal128 z) +{ + z = z + 1.0dl; +} + +int +main () +{ + _Decimal32 d32 = 1.1df; + _Decimal64 d64 = 1.2dd; + _Decimal128 d128 = 1.3dl; + + foo32 (d32); + if (d32 != 1.1df) + FAILURE + + foo64 (d64); + if (d64 != 1.2dd) + FAILURE + + foo128 (d128); + if (d128 != 1.3dl) + FAILURE + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/cast.c b/gcc/testsuite/c-c++-common/dfp/cast.c new file mode 100644 index 00000000000..b6585d70c8b --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/cast.c @@ -0,0 +1,75 @@ +/* C99 6.5.4 Cast operators. + Test valid casts involving decimal float. */ + +#include "dfp-dbg.h" + +_Decimal32 d32; +_Decimal64 d64; +_Decimal128 d128; + +static float f = 2.f; +static double d = 2.l; + +int +main (void) +{ + /* Casts between DFP types. */ + d32 = 1.2df; + d64 = 1.2dd; + d128 = 1.2dl; + + if (d32 != (_Decimal32) d64) + FAILURE + if (d32 != (_Decimal32) d128) + FAILURE + + if (d64 != (_Decimal64) d32) + FAILURE + if (d64 != (_Decimal64) d128) + FAILURE + + if (d128 != (_Decimal128) d32) + FAILURE + if (d128 != (_Decimal128) d64) + FAILURE + + /* Casts between generic and decimal floating point types. Use a + value that we can assume can be represented exactly in all + representations. */ + + d32 = 2.0df; + d64 = 2.0dd; + d128 = 2.0dl; + + /* To generic floating types. */ + if ((float) d32 != 2.0f) + FAILURE + if ((double) d32 != 2.0l) + FAILURE + if ((float) d64 != 2.0f) + FAILURE + if ((double) d64 != 2.0l) + FAILURE + if ((float) d128 != 2.0f) + FAILURE + if ((double) d128 != 2.0l) + FAILURE + + /* float to decimal floating types. */ + if (d32 != (_Decimal32) f) + FAILURE + if (d64 != (_Decimal64) f) + FAILURE + if (d128 != (_Decimal128) f) + FAILURE + + /* double to decimal floating types. */ + if (d32 != (_Decimal32) d) + FAILURE + if (d64 != (_Decimal64) d) + FAILURE + if (d128 != (_Decimal128) d) + FAILURE + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/compare-eq-const.c b/gcc/testsuite/c-c++-common/dfp/compare-eq-const.c new file mode 100644 index 00000000000..0c9ff200b28 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/compare-eq-const.c @@ -0,0 +1,28 @@ +/* C99 6.5.9 Equality operators. + Compare decimal float constants against each other. */ + +#include "dfp-dbg.h" + +extern void link_error (void); + +int +main () +{ + /* Compare like-typed positive constants. */ + if (2.0df != 2.0df) + link_error (); + + /* Compare decimal float constants of different types. */ + if (500e-2dl != 0.05e2df) + link_error (); + + /* Binary floating point introduces errors to decimal values. */ + if (1.4 + 1.4 + 1.4 == 4.2) + link_error (); + + /* But, this looks more like what one would expect. */ + if (1.4dd + 1.4dd + 1.4dd != 4.2dd) + link_error (); + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/compare-eq-d128.c b/gcc/testsuite/c-c++-common/dfp/compare-eq-d128.c new file mode 100644 index 00000000000..79fcac3195e --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/compare-eq-d128.c @@ -0,0 +1,14 @@ +/* { dg-options "-O0" } */ + +/* C99 6.5.9 Equality operators. + Compare decimal float values against each other at runtime. */ + +#define WIDTH 128 +#include "compare-eq.h" + +int main () +{ + test_compares (); + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/compare-eq-d32.c b/gcc/testsuite/c-c++-common/dfp/compare-eq-d32.c new file mode 100644 index 00000000000..6b1a4c6d7c4 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/compare-eq-d32.c @@ -0,0 +1,14 @@ +/* { dg-options "-O0" } */ + +/* C99 6.5.9 Equality operators. + Compare decimal float values against each other at runtime. */ + +#define WIDTH 32 +#include "compare-eq.h" + +int main () +{ + test_compares (); + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/compare-eq-d64.c b/gcc/testsuite/c-c++-common/dfp/compare-eq-d64.c new file mode 100644 index 00000000000..f1b463ebe6a --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/compare-eq-d64.c @@ -0,0 +1,14 @@ +/* { dg-options "-O0" } */ + +/* C99 6.5.9 Equality operators. + Compare decimal float values against each other at runtime. */ + +#define WIDTH 64 +#include "compare-eq.h" + +int main () +{ + test_compares (); + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/compare-eq-dfp.c b/gcc/testsuite/c-c++-common/dfp/compare-eq-dfp.c new file mode 100644 index 00000000000..79a5691ebfc --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/compare-eq-dfp.c @@ -0,0 +1,53 @@ +/* { dg-options "-O0" } */ + +/* C99 6.5.9 Equality operators. + Compare decimal float values against variables of different types. */ + +#include "dfp-dbg.h" + +_Decimal32 d32; +_Decimal64 d64; +_Decimal128 d128; + +/* Use some typedefs of decimal float types, too. */ +typedef _Decimal32 SDtype; +typedef _Decimal64 DDtype; +typedef _Decimal128 TDtype; + +SDtype d32b; +DDtype d64b; +TDtype d128b; + +void +inits (void) +{ + d32 = 1.0df; + d64 = 3.0dd; + d128 = 5.0dl; + d32b = -1.0df; + d64b = -4.0dd; + d128b = -6.0dl; +} + +void +compare_dfp (void) +{ + if ((d32 == d64) != 0) FAILURE + if ((d32 != d128b) != 1) FAILURE + + if ((d64 != d32) != 1) FAILURE + if ((d64 == d128) != 0) FAILURE + + if ((d128 != d32) != 1) FAILURE + if ((d128 == d64) != 0) FAILURE +} + +int +main () +{ + inits (); + + compare_dfp (); + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/compare-eq.h b/gcc/testsuite/c-c++-common/dfp/compare-eq.h new file mode 100644 index 00000000000..830b3289bde --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/compare-eq.h @@ -0,0 +1,92 @@ +/* Basic test of runtime equality comparisons using simple values that + are not affected by rounding. */ + +#include +#include "dfp-dbg.h" + +#define PASTE2(A,B) A ## B +#define PASTE(A,B) PASTE2(A,B) + +#undef FAILURE +#ifdef DBG +#define FAILURE(OP,KIND) \ + { printf ("failed at line %d: %s for %s values\n", __LINE__, OP, KIND); \ + failures++; } +#else +#define FAILURE(OP,KIND) __builtin_abort (); +#endif + +#ifndef WIDTH +#error define WIDTH as decimal float size in bytes +#endif + +#if WIDTH == 32 +#define DTYPE _Decimal32 +#define SUFFIX DF +#elif WIDTH == 64 +#define DTYPE _Decimal64 +#define SUFFIX DD +#elif WIDTH == 128 +#define DTYPE _Decimal128 +#define SUFFIX DL +#elif WIDTH == 0 +/* This is for testing the test using a type known to work. */ +#define DTYPE double +#define SUFFIX +#else +#error invalid width for decimal float type +#endif + +DTYPE m_two = PASTE(-2.0, SUFFIX); +DTYPE m_one = PASTE(-1.0, SUFFIX); +DTYPE zero = PASTE(0.0, SUFFIX); +DTYPE one = PASTE(1.0, SUFFIX); +DTYPE two = PASTE(2.0, SUFFIX); + +void +test_compares (void) +{ + DTYPE x = one; + DTYPE y = zero; + DTYPE z = m_one; + + /* Equal to: comparisons against equal values. */ + + if (! (x == one)) FAILURE ("==", "equal") + if (! (y == zero)) FAILURE ("==", "equal") + if (! (z == m_one)) FAILURE ("==", "equal") + + /* Equal to: comparisons against lesser values. */ + + if (x == m_one) FAILURE ("==", "lesser") + if (x == zero) FAILURE ("==", "lesser") + if (y == m_one) FAILURE ("==", "lesser") + if (z == m_two) FAILURE ("==", "lesser") + + /* Equal to: comparisons against greater values. */ + + if (x == two) FAILURE ("==", "greater") + if (y == one) FAILURE ("==", "greater") + if (z == zero) FAILURE ("==", "greater") + if (z == one) FAILURE ("==", "greater") + + /* Not equal to: comparisons against equal values. */ + + if (x != one) FAILURE ("!=", "equal") + if (y != zero) FAILURE ("!=", "equal") + if (z != m_one) FAILURE ("!=", "equal") + + /* Not equal to: comparisons against lesser values. */ + + if (! (x != m_one)) FAILURE ("!=", "lesser") + if (! (x != zero)) FAILURE ("!=", "lesser") + if (! (y != m_one)) FAILURE ("!=", "lesser") + if (! (z != m_two)) FAILURE ("!=", "lesser") + + /* Not equal to: comparisons against greater values. */ + + if (! (x != m_one)) FAILURE ("!=", "greater") + if (! (x != zero)) FAILURE ("!=", "greater") + if (! (y != m_one)) FAILURE ("!=", "greater") + if (! (z != m_two)) FAILURE ("!=", "greater") +} diff --git a/gcc/testsuite/c-c++-common/dfp/compare-rel-const.c b/gcc/testsuite/c-c++-common/dfp/compare-rel-const.c new file mode 100644 index 00000000000..8e99b4466dc --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/compare-rel-const.c @@ -0,0 +1,57 @@ +/* C99 6.5.8 Relational operators. + Compare decimal float constants against each other. */ + +extern void link_error (void); + +int +main () +{ + /* Compare like-typed negative constants. */ + if (-2.0dl < -2.0dl) + link_error (); + + /* Compare like-typed constants. */ + if (-2.0dl >= .01dl) + link_error (); + + /* Compare like-typed constants. */ + if (0.2dd > 0.02e1dd) + link_error (); + + /* Compare decimal float constants of different types. */ + if (-.000005dd >= -.0000049DL) + link_error(); + + /* Test use gcc builtins for comparisons. */ + if (__builtin_isless(-2.0dl,-2.0dl)) + link_error(); + + if (__builtin_isgreaterequal(-2.0dl,.01dl)) + link_error(); + + if (!(__builtin_islessequal(-2.0dl, -2.0dd))) + link_error(); + + if (!(__builtin_isgreater(2.0dl, -2.0dd))) + link_error(); + + if (__builtin_islessequal(2.0df, __builtin_nand64(""))) + link_error(); + + if (__builtin_islessgreater(2.0dd, __builtin_nand64(""))) + link_error(); + + if (!__builtin_islessgreater(2.0dd, -2.0dd)) + link_error(); + + if (!__builtin_islessgreater(-3.0dd, 2.0dd)) + link_error(); + + if (__builtin_isunordered(1.1df, 0.003dd)) + link_error(); + + if (!__builtin_isunordered(-3.1df, __builtin_nand32(""))) + link_error(); + + return 0; +} diff --git a/gcc/testsuite/c-c++-common/dfp/compare-rel-d128.c b/gcc/testsuite/c-c++-common/dfp/compare-rel-d128.c new file mode 100644 index 00000000000..38c931a0207 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/compare-rel-d128.c @@ -0,0 +1,14 @@ +/* { dg-options "-O0" } */ + +/* C99 6.5.8 Relational operators. + Compare decimal float values against each other at runtime. */ + +#define WIDTH 128 +#include "compare-rel.h" + +int +main () +{ + test_compares (); + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/compare-rel-d32.c b/gcc/testsuite/c-c++-common/dfp/compare-rel-d32.c new file mode 100644 index 00000000000..04128aab924 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/compare-rel-d32.c @@ -0,0 +1,14 @@ +/* { dg-options "-O0" } */ + +/* C99 6.5.8 Relational operators. + Compare decimal float values against each other at runtime. */ + +#define WIDTH 32 +#include "compare-rel.h" + +int +main () +{ + test_compares (); + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/compare-rel-d64.c b/gcc/testsuite/c-c++-common/dfp/compare-rel-d64.c new file mode 100644 index 00000000000..92f904a8154 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/compare-rel-d64.c @@ -0,0 +1,14 @@ +/* { dg-options "-O0" } */ + +/* C99 6.5.8 Relational operators. + Compare decimal float values against each other at runtime. */ + +#define WIDTH 64 +#include "compare-rel.h" + +int +main () +{ + test_compares (); + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/compare-rel-dfp.c b/gcc/testsuite/c-c++-common/dfp/compare-rel-dfp.c new file mode 100644 index 00000000000..59cc2035306 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/compare-rel-dfp.c @@ -0,0 +1,53 @@ +/* { dg-options "-O0" } */ + +/* C99 6.5.8 Relational operators. + Compare decimal float values against variables of different types. */ + +#include "dfp-dbg.h" + +_Decimal32 d32; +_Decimal64 d64; +_Decimal128 d128; + +/* Use some typedefs of decimal float types, too. */ +typedef _Decimal32 SDtype; +typedef _Decimal64 DDtype; +typedef _Decimal128 TDtype; + +SDtype d32b; +DDtype d64b; +TDtype d128b; + +void +inits (void) +{ + d32 = 1.0df; + d64 = 3.0dd; + d128 = 5.0dl; + d32b = -1.0df; + d64b = -4.0dd; + d128b = -6.0dl; +} + +void +compare_dfp (void) +{ + if ((d32 > d64) != 0) FAILURE + if ((d32 >= d128b) != 1) FAILURE + + if ((d64 < d32) != 0) FAILURE + if ((d64 <= d128) != 1) FAILURE + + if ((d128 > d32) != 1) FAILURE + if ((d128 >= d64) != 1) FAILURE +} + +int +main () +{ + inits (); + + compare_dfp (); + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/compare-rel.h b/gcc/testsuite/c-c++-common/dfp/compare-rel.h new file mode 100644 index 00000000000..7840108142d --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/compare-rel.h @@ -0,0 +1,132 @@ +/* Basic test of runtime relational comparisons using simple values that + are not affected by rounding. */ + +#include +#include "dfp-dbg.h" + +#undef FAILURE +#ifdef DBG +#define FAILURE(OP,KIND) \ + { printf ("failed at line %d: %s for %s values\n", __LINE__, OP, KIND); \ + failures++; } +#else +#define FAILURE(OP,KIND) __builtin_abort (); +#endif + +#define PASTE2(A,B) A ## B +#define PASTE(A,B) PASTE2(A,B) + +#ifndef WIDTH +#error define WIDTH as decimal float size in bytes +#endif + +#if WIDTH == 32 +#define DTYPE _Decimal32 +#define SUFFIX DF +#elif WIDTH == 64 +#define DTYPE _Decimal64 +#define SUFFIX DD +#elif WIDTH == 128 +#define DTYPE _Decimal128 +#define SUFFIX DL +#elif WIDTH == 0 +/* This is for testing the test using a type known to work. */ +#define DTYPE double +#define SUFFIX +#else +#error invalid width for decimal float type +#endif + +DTYPE m_two = PASTE(-2.0, SUFFIX); +DTYPE m_one = PASTE(-1.0, SUFFIX); +DTYPE zero = PASTE(0.0, SUFFIX); +DTYPE one = PASTE(1.0, SUFFIX); +DTYPE two = PASTE(2.0, SUFFIX); + +void +test_compares (void) +{ + DTYPE x = one; + DTYPE y = zero; + DTYPE z = m_one; + + /* Less than or equal to: comparisons against equal values. */ + + if (! (x <= one)) FAILURE ("<=", "equal") + if (! (y <= zero)) FAILURE ("<=", "equal") + if (! (z <= m_one)) FAILURE ("<=", "equal") + + /* Less than or equal to: comparisons against lesser values. */ + + if (x <= m_one) FAILURE ("<=", "lesser") + if (x <= zero) FAILURE ("<=", "lesser") + if (y <= m_one) FAILURE ("<=", "lesser") + if (z <= m_two) FAILURE ("<=", "lesser") + + /* Less than or equal to: comparisons against greater values. */ + + if (! (x <= two)) FAILURE ("<=", "greater") + if (! (y <= one)) FAILURE ("<=", "greater") + if (! (z <= zero)) FAILURE ("<=", "greater") + if (! (z <= one)) FAILURE ("<=", "greater") + + /* Less than: comparisons against equal values. */ + + if (x < one) FAILURE ("<", "equal") + if (y < zero) FAILURE ("<", "equal") + if (z < m_one) FAILURE ("<", "equal") + + /* Less than: comparisons against lesser values. */ + + if (x < m_one) FAILURE ("<", "lesser") + if (x < zero) FAILURE ("<", "lesser") + if (y < m_one) FAILURE ("<", "lesser") + if (z < m_two) FAILURE ("<", "lesser") + + /* Less than: comparisons against greater values. */ + + if (! (x < two)) FAILURE ("<", "greater") + if (! (y < one)) FAILURE ("<", "greater") + if (! (z < zero)) FAILURE ("<", "greater") + if (! (z < one)) FAILURE ("<", "greater") + + /* Greater than or equal to: comparisons against equal values. */ + + if (! (x >= one)) FAILURE (">=", "equal") + if (! (y >= zero)) FAILURE (">=", "equal") + if (! (z >= m_one)) FAILURE (">=", "equal") + + /* Greater than or equal to: comparisons against lesser values. */ + + if (! (x >= m_one)) FAILURE (">=", "lesser") + if (! (x >= zero)) FAILURE (">=", "lesser") + if (! (y >= m_one)) FAILURE (">=", "lesser") + if (! (z >= m_two)) FAILURE (">=", "lesser") + + /* Greater than or equal to: comparisons against greater values. */ + + if (x >= two) FAILURE (">=", "greater") + if (y >= one) FAILURE (">=", "greater") + if (z >= zero) FAILURE (">=", "greater") + if (z >= one) FAILURE (">=", "greater") + + /* Greater than: comparisons against equal values. */ + + if (x > one) FAILURE (">", "equal") + if (y > zero) FAILURE (">", "equal") + if (z > m_one) FAILURE (">", "equal") + + /* Greater than: comparisons against lesser values. */ + + if (! (x > m_one)) FAILURE (">", "lesser") + if (! (x > zero)) FAILURE (">", "lesser") + if (! (y > m_one)) FAILURE (">", "lesser") + if (! (z > m_two)) FAILURE (">", "lesser") + + /* Greater than: comparisons against greater values. */ + + if (x > two) FAILURE (">", "greater") + if (y > one) FAILURE (">", "greater") + if (z > zero) FAILURE (">", "greater") + if (z > one) FAILURE (">", "greater") +} diff --git a/gcc/testsuite/c-c++-common/dfp/compare-special-d128.c b/gcc/testsuite/c-c++-common/dfp/compare-special-d128.c new file mode 100644 index 00000000000..d1f5bc5edd4 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/compare-special-d128.c @@ -0,0 +1,15 @@ +/* { dg-options "-O0" } */ + +/* C99 6.5.8 Relational operators. + C99 6.5.9 Equality operators. + Compare decimal float special values at runtime. */ + +#define WIDTH 128 +#include "compare-special.h" + +int +main () +{ + test_compares (); + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/compare-special-d32.c b/gcc/testsuite/c-c++-common/dfp/compare-special-d32.c new file mode 100644 index 00000000000..377c65a5bb7 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/compare-special-d32.c @@ -0,0 +1,15 @@ +/* { dg-options "-O0" } */ + +/* C99 6.5.8 Relational operators. + C99 6.5.9 Equality operators. + Compare decimal float special values at runtime. */ + +#define WIDTH 32 +#include "compare-special.h" + +int +main () +{ + test_compares (); + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/compare-special-d64.c b/gcc/testsuite/c-c++-common/dfp/compare-special-d64.c new file mode 100644 index 00000000000..16154eff323 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/compare-special-d64.c @@ -0,0 +1,15 @@ +/* { dg-options "-O0" } */ + +/* C99 6.5.8 Relational operators. + C99 6.5.9 Equality operators. + Compare decimal float special values at runtime. */ + +#define WIDTH 64 +#include "compare-special.h" + +int +main () +{ + test_compares (); + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/compare-special.h b/gcc/testsuite/c-c++-common/dfp/compare-special.h new file mode 100644 index 00000000000..9c27d126c29 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/compare-special.h @@ -0,0 +1,284 @@ +/* Basic test of runtime relational comparisons using NaNs and infinities. */ + +#include +#include "dfp-dbg.h" + +#define PASTE2(A,B) A ## B +#define PASTE(A,B) PASTE2(A,B) + +/* Override FAILURE from dfp-dbg.h with one that provides additional info. */ +#undef FAILURE +#ifdef DBG +#define FAILURE(OP,KIND) \ + { printf ("failed at line %d: %s for %s values\n", __LINE__, OP, KIND); \ + failures++; } +#else +#define FAILURE(OP,KIND) __builtin_abort (); +#endif + +#ifndef WIDTH +#error define WIDTH as decimal float size in bytes +#endif + +#if WIDTH == 32 +#define DTYPE _Decimal32 +#define SUFFIX DF +#define SUFFIX2 d32 +#elif WIDTH == 64 +#define DTYPE _Decimal64 +#define SUFFIX DD +#define SUFFIX2 d64 +#elif WIDTH == 128 +#define DTYPE _Decimal128 +#define SUFFIX DL +#define SUFFIX2 d128 +#elif WIDTH == 0 +/* This is for testing the test using a type known to work. */ +#define DTYPE double +#define SUFFIX +#define SUFFIX2 +#else +#error invalid width for decimal float type +#endif + +DTYPE m_two = PASTE(-2.0, SUFFIX); +DTYPE m_one = PASTE(-1.0, SUFFIX); +DTYPE zero = PASTE(0.0, SUFFIX); +DTYPE one = PASTE(1.0, SUFFIX); +DTYPE two = PASTE(2.0, SUFFIX); + +volatile DTYPE x, y, z, _nan, inf, m_inf; + +void +test_compares (void) +{ + _nan = PASTE(__builtin_nan, SUFFIX2) (""); + inf = PASTE(__builtin_inf, SUFFIX2) (); + m_inf = - PASTE(__builtin_inf, SUFFIX2) (); + + x = PASTE(__builtin_nan, SUFFIX2) (""); + y = PASTE(__builtin_inf, SUFFIX2) (); + z = - PASTE(__builtin_inf, SUFFIX2) (); + + /* Less than or equal to with NaN. */ + + if (x <= two) FAILURE ("<=", "NaN") + if (x <= zero) FAILURE ("<=", "NaN") + if (x <= m_one) FAILURE ("<=", "NaN") + if (x <= _nan) FAILURE ("<=", "NaN") + if (x <= inf) FAILURE ("<=", "NaN") + if (x <= m_inf) FAILURE ("<=", "NaN") + + if (two <= x) FAILURE ("<=", "NaN") + if (zero <= x) FAILURE ("<=", "NaN") + if (m_one <= x) FAILURE ("<=", "NaN") + if (_nan <= x) FAILURE ("<=", "NaN") + if (inf <= x) FAILURE ("<=", "NaN") + if (m_inf <= x) FAILURE ("<=", "NaN") + + /* Less than or equal to with infinities, no NaNs. */ + + if (y <= two) FAILURE ("<=", "inf") + if (y <= zero) FAILURE ("<=", "inf") + if (y <= m_one) FAILURE ("<=", "inf") + if (!(two <= y)) FAILURE ("<=", "inf") + if (!(zero <= y)) FAILURE ("<=", "inf") + if (!(m_one <= y)) FAILURE ("<=", "inf") + + if (!(z <= two)) FAILURE ("<=", "-inf") + if (!(z <= zero)) FAILURE ("<=", "-inf") + if (!(z <= m_one)) FAILURE ("<=", "-inf") + if (two <= z) FAILURE ("<=", "-inf") + if (zero <= z) FAILURE ("<=", "-inf") + if (m_one <= z) FAILURE ("<=", "-inf") + + if (!(y <= inf)) FAILURE ("<=", "inf") + if (y <= m_inf) FAILURE ("<=", "inf") + if (!(z <= inf)) FAILURE ("<=", "inf") + if (!(z <= m_inf)) FAILURE ("<=", "inf") + + /* Less than with NaN. */ + + if (x < two) FAILURE ("<", "NaN") + if (x < zero) FAILURE ("<", "NaN") + if (x < m_one) FAILURE ("<", "NaN") + if (x < _nan) FAILURE ("<", "NaN") + if (x < inf) FAILURE ("<", "NaN") + if (x < m_inf) FAILURE ("<", "NaN") + + if (two < x) FAILURE ("<", "NaN") + if (zero < x) FAILURE ("<", "NaN") + if (m_one < x) FAILURE ("<", "NaN") + if (_nan < x) FAILURE ("<", "NaN") + if (inf < x) FAILURE ("<", "NaN") + if (m_inf < x) FAILURE ("<", "NaN") + + /* Less than with infinities, no NaNs. */ + + if (y < two) FAILURE ("<", "inf") + if (y < zero) FAILURE ("<", "inf") + if (y < m_one) FAILURE ("<", "inf") + if (!(two < y)) FAILURE ("<", "inf") + if (!(zero < y)) FAILURE ("<", "inf") + if (!(m_one < y)) FAILURE ("<", "inf") + + if (!(z < two)) FAILURE ("<", "-inf") + if (!(z < zero)) FAILURE ("<", "-inf") + if (!(z < m_one)) FAILURE ("<", "-inf") + if (two < z) FAILURE ("<", "-inf") + if (zero < z) FAILURE ("<", "-inf") + if (m_one < z) FAILURE ("<", "-inf") + + if (y < inf) FAILURE ("<=", "inf") + if (y < m_inf) FAILURE ("<=", "inf") + if (!(z < inf)) FAILURE ("<=", "inf") + if (z < m_inf) FAILURE ("<=", "inf") + + /* Greater than or equal to with NaN. */ + + if (x >= two) FAILURE (">=", "NaN") + if (x >= zero) FAILURE (">=", "NaN") + if (x >= m_one) FAILURE (">=", "NaN") + if (x >= _nan) FAILURE (">=", "NaN") + if (x >= inf) FAILURE (">=", "NaN") + if (x >= m_inf) FAILURE (">=", "NaN") + + if (two >= x) FAILURE (">=", "NaN") + if (zero >= x) FAILURE (">=", "NaN") + if (m_one >= x) FAILURE (">=", "NaN") + if (_nan >= x) FAILURE (">=", "NaN") + if (inf >= x) FAILURE (">=", "NaN") + if (m_inf >= x) FAILURE (">=", "NaN") + + /* Greater than or equal to with infinities, no NaNs. */ + + if (!(y >= two)) FAILURE (">=", "inf") + if (!(y >= zero)) FAILURE (">=", "inf") + if (!(y >= m_one)) FAILURE (">=", "inf") + if (two >= y) FAILURE (">=", "inf") + if (zero >= y) FAILURE (">=", "inf") + if (m_one >= y) FAILURE (">=", "inf") + + if (z >= two) FAILURE (">=", "-inf") + if (z >= zero) FAILURE (">=", "-inf") + if (z >= m_one) FAILURE (">=", "-inf") + if (!(two >= z)) FAILURE (">=", "-inf") + if (!(zero >= z)) FAILURE (">=", "-inf") + if (!(m_one >= z)) FAILURE (">=", "-inf") + + if (!(y >= inf)) FAILURE ("<=", "inf") + if (!(y >= m_inf)) FAILURE ("<=", "inf") + if (z >= inf) FAILURE ("<=", "inf") + if (!(z >= m_inf)) FAILURE ("<=", "inf") + + /* Greater than with NaN. */ + + if (x > two) FAILURE (">", "NaN") + if (x > zero) FAILURE (">", "NaN") + if (x > m_one) FAILURE (">", "NaN") + if (x > _nan) FAILURE (">", "NaN") + if (x > inf) FAILURE (">", "NaN") + if (x > m_inf) FAILURE (">", "NaN") + + if (two > x) FAILURE (">", "NaN") + if (zero > x) FAILURE (">", "NaN") + if (m_one > x) FAILURE (">", "NaN") + if (_nan > x) FAILURE (">", "NaN") + if (inf > x) FAILURE (">", "NaN") + if (m_inf > x) FAILURE (">", "NaN") + + /* Greater than with infinities, no NaNs. */ + + if (!(y > two)) FAILURE (">", "inf") + if (!(y > zero)) FAILURE (">", "inf") + if (!(y > m_one)) FAILURE (">", "inf") + if (two > y) FAILURE (">", "inf") + if (zero > y) FAILURE (">", "inf") + if (m_one > y) FAILURE (">", "inf") + + if (z > two) FAILURE (">", "-inf") + if (z > zero) FAILURE (">", "-inf") + if (z > m_one) FAILURE (">", "-inf") + if (!(two > z)) FAILURE (">", "-inf") + if (!(zero > z)) FAILURE (">", "-inf") + if (!(m_one > z)) FAILURE (">", "-inf") + + if (y > inf) FAILURE (">", "inf") + if (!(y > m_inf)) FAILURE (">", "inf") + if (z > inf) FAILURE (">", "inf") + if (z > m_inf) FAILURE (">", "inf") + + /* Equal with NaN. */ + + if (x == two) FAILURE ("==", "NaN") + if (x == zero) FAILURE ("==", "NaN") + if (x == m_one) FAILURE ("==", "NaN") + if (x == _nan) FAILURE ("==", "NaN") + if (x == inf) FAILURE ("==", "NaN") + if (x == m_inf) FAILURE ("==", "NaN") + + if (two == x) FAILURE ("==", "NaN") + if (zero == x) FAILURE ("==", "NaN") + if (m_one == x) FAILURE ("==", "NaN") + if (_nan == x) FAILURE ("==", "NaN") + if (inf == x) FAILURE ("==", "NaN") + if (m_inf == x) FAILURE ("==", "NaN") + + /* Equal with infinities, no NaNs. */ + + if (y == two) FAILURE ("==", "inf") + if (y == zero) FAILURE ("==", "inf") + if (y == m_one) FAILURE ("==", "inf") + if (two == y) FAILURE ("==", "inf") + if (zero == y) FAILURE ("==", "inf") + if (m_one == y) FAILURE ("==", "inf") + + if (z == two) FAILURE ("==", "-inf") + if (z == zero) FAILURE ("==", "-inf") + if (z == m_one) FAILURE ("==", "-inf") + if (two == z) FAILURE ("==", "-inf") + if (zero == z) FAILURE ("==", "-inf") + if (m_one == z) FAILURE ("==", "-inf") + + if (!(y == inf)) FAILURE ("==", "inf") + if (y == m_inf) FAILURE ("==", "inf") + if (z == inf) FAILURE ("==", "inf") + if (!(z == m_inf)) FAILURE ("==", "inf") + + /* Not equal with NaN. */ + + if (!(x != two)) FAILURE ("!=", "NaN") + if (!(x != zero)) FAILURE ("!=", "NaN") + if (!(x != m_one)) FAILURE ("!=", "NaN") + if (!(x != _nan)) FAILURE ("!=", "NaN") + if (!(x != inf)) FAILURE ("!=", "NaN") + if (!(x != m_inf)) FAILURE ("!=", "NaN") + + if (!(two != x)) FAILURE ("!=", "NaN") + if (!(zero != x)) FAILURE ("!=", "NaN") + if (!(m_one != x)) FAILURE ("!=", "NaN") + if (!(_nan != x)) FAILURE ("!=", "NaN") + if (!(inf != x)) FAILURE ("!=", "NaN") + if (!(m_inf != x)) FAILURE ("!=", "NaN") + + /* Not equal with infinities, no NaNs. */ + + if (!(y != two)) FAILURE ("!=", "inf") + if (!(y != zero)) FAILURE ("!=", "inf") + if (!(y != m_one)) FAILURE ("!=", "inf") + if (!(two != y)) FAILURE ("!=", "inf") + if (!(zero != y)) FAILURE ("!=", "inf") + if (!(m_one != y)) FAILURE ("!=", "inf") + + if (!(z != two)) FAILURE ("!=", "-inf") + if (!(z != zero)) FAILURE ("!=", "-inf") + if (!(z != m_one)) FAILURE ("!=", "-inf") + if (!(two != z)) FAILURE ("!=", "-inf") + if (!(zero != z)) FAILURE ("!=", "-inf") + if (!(m_one != z)) FAILURE ("!=", "-inf") + + if (y != inf) FAILURE ("!=", "inf") + if (!(y != m_inf)) FAILURE ("!=", "inf") + if (!(z != inf)) FAILURE ("!=", "inf") + if (z != m_inf) FAILURE ("!=", "inf") +} diff --git a/gcc/testsuite/c-c++-common/dfp/constants-zero.c b/gcc/testsuite/c-c++-common/dfp/constants-zero.c new file mode 100644 index 00000000000..64b0054d2d3 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/constants-zero.c @@ -0,0 +1,159 @@ +/* { dg-options "-O0" } */ + +/* Decimal float values can have significant trailing zeroes. This is + true for zero values as well. Check that various representations of + zero are handled correctly when specified as literal constants. */ + +#include "dfp-dbg.h" + +int big_endian; + +typedef union U32 { + unsigned int i; + _Decimal32 d; + unsigned char b[4]; +} u32_t; + +typedef union U64 { + unsigned long long i; + _Decimal64 d; +} u64_t; + +typedef union U128 { + unsigned long long i[2]; + _Decimal128 d; +} u128_t; + +int +compare32 (_Decimal32 d, unsigned int i) +{ + u32_t u; + + u.d = d; + return (u.i == i); +} + +int +compare64 (_Decimal64 d, unsigned long long i) +{ + u64_t u; + + u.d = d; + return (u.i == i); +} + +int +compare128 (_Decimal64 d, unsigned long long i, unsigned long long j) +{ + u128_t u; + + u.d = d; + if (big_endian) + return (u.i[0] == i && u.i[1] == j); + else + return (u.i[1] == i && u.i[0] == j); +} + +void +dpd_tests (void) +{ + if (! compare32 (0.DF, 0x22500000U)) + FAILURE + if (! compare32 (-0.DF, 0xa2500000U)) + FAILURE + if (! compare32 (0.E-4DF, 0x22100000U)) + FAILURE + if (! compare32 (0.E-7DF, 0x21e00000U)) + FAILURE + if (! compare32 (0.E+3DF, 0x22800000U)) + FAILURE + + if (! compare64 (0.DD, 0x2238000000000000ULL)) + FAILURE + if (! compare64 (-0.DD, 0xa238000000000000ULL)) + FAILURE + if (! compare64 (0.E-6DD, 0x2220000000000000ULL)) + FAILURE + if (! compare64 (0.E-7DD, 0x221c000000000000ULL)) + FAILURE + if (! compare64 (0.E+2DD, 0x2240000000000000ULL)) + FAILURE + + if (! compare128 (0.DL, 0x2208000000000000ULL, 0x0000000000000000ULL)) + FAILURE + if (! compare128 (-0.DL, 0xa208000000000000ULL, 0x0000000000000000ULL)) + FAILURE + if (! compare128 (0.E-3DL, 0x2207400000000000ULL, 0x0000000000000000ULL)) + FAILURE + if (! compare128 (0.E-8DL, 0x2206000000000000ULL, 0x0000000000000000ULL)) + FAILURE + if (! compare128 (0.E+2DL, 0x2208800000000000ULL, 0x0000000000000000ULL)) + FAILURE +} + +void +bid_tests (void) +{ + if (! compare32 (0.DF, 0x32800000U)) + FAILURE + if (! compare32 (-0.DF, 0xb2800000U)) + FAILURE + if (! compare32 (0.E-4DF, 0x30800000U)) + FAILURE + if (! compare32 (0.E-7DF, 0x2f000000U)) + FAILURE + if (! compare32 (0.E+3DF, 0x34000000U)) + FAILURE + + if (! compare64 (0.DD, 0x31c0000000000000ULL)) + FAILURE + if (! compare64 (-0.DD, 0xb1c0000000000000ULL)) + FAILURE + if (! compare64 (0.E-6DD, 0x3100000000000000ULL)) + FAILURE + if (! compare64 (0.E-7DD, 0x30e0000000000000ULL)) + FAILURE + if (! compare64 (0.E+2DD, 0x3200000000000000ULL)) + FAILURE + + if (! compare128 (0.DL, 0x3040000000000000ULL, 0x0000000000000000ULL)) + FAILURE + if (! compare128 (-0.DL, 0xb040000000000000ULL, 0x0000000000000000ULL)) + FAILURE + if (! compare128 (0.E-3DL, 0x303a000000000000ULL, 0x0000000000000000ULL)) + FAILURE + if (! compare128 (0.E-8DL, 0x3030000000000000ULL, 0x0000000000000000ULL)) + FAILURE + if (! compare128 (0.E+2DL, 0x3044000000000000ULL, 0x0000000000000000ULL)) + FAILURE +} + +int +main () +{ + u32_t u32; + + /* These sizes are probably always true for targets that support decimal + float types, but check anyway. Abort so we can fix the test. */ + if ((sizeof (_Decimal64) != sizeof (long long)) + || (sizeof (_Decimal128) != 2 * sizeof (long long)) + || (sizeof (_Decimal32) != sizeof (_Decimal32))) + FAILURE + + u32.d = 1.DF; + + if (u32.i == 0x22500001) + { + big_endian = (u32.b[0] == 0x22); + dpd_tests (); + } + else if (u32.i == 0x32800001) + { + big_endian = (u32.b[0] == 0x32); + bid_tests (); + } + else + FAILURE /* unknown format; test problem */ + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/convert-bfp-10.c b/gcc/testsuite/c-c++-common/dfp/convert-bfp-10.c new file mode 100644 index 00000000000..3fef98a3384 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/convert-bfp-10.c @@ -0,0 +1,107 @@ +/* This test assumes IEEE float and double. */ + +#include "convert.h" + +volatile _Decimal32 sd; +volatile _Decimal64 dd; +volatile _Decimal128 td; +volatile float sf; +volatile double df; + +/* Conversions using denormalized float values. */ +CONVERT_VALID (111, sf, sd, 1.2e-38f, 1.2e-38df, 0.df) +CONVERT_VALID (112, sf, sd, 1.1e-38f, 1.1e-38df, 0.df) +CONVERT_VALID (113, sf, sd, 1.1e-40f, 1.1e-40df, 1.1e-45df) + +CONVERT_VALID (121, sd, sf, 1.2e-38df, 1.2e-38f, 0.f) +CONVERT_VALID (122, sd, sf, 1.1e-38df, 1.1e-38f, 0.f) + +CONVERT_VALID (131, sf, sd, -1.2e-38f, -1.2e-38df, 0.df) +CONVERT_VALID (132, sf, sd, -1.1e-38f, -1.1e-38df, 0.df) + +CONVERT_VALID (141, sd, sf, -1.2e-38df, -1.2e-38f, 0.f) +CONVERT_VALID (142, sd, sf, -1.1e-38df, -1.1e-38f, 0.f) + +/* Conversions using denormalized double values. */ +CONVERT_VALID (211, df, sd, 1.2e-38, 1.2e-38df, 0.df) +CONVERT_VALID (212, df, sd, 1.1e-38, 1.1e-38df, 0.df) +CONVERT_VALID (213, df, sd, 1.e-40, 1.e-40df, 0.df) +CONVERT_VALID (214, df, sd, 8.e-44, 8.e-44df, 0.df) +CONVERT_VALID (215, df, sd, 9.e-44, 9.e-44df, 0.df) +CONVERT_VALID (216, df, sd, 8.e-46, 8.e-46df, 0.df) +CONVERT_VALID (217, df, sd, 7.e-46, 7.e-46df, 0.df) + +CONVERT_VALID (221, sd, df, 1.2e-38df, 1.2e-38, 1.e-53) +CONVERT_VALID (222, sd, df, 1.1e-38df, 1.1e-38, 1.e-53) +CONVERT_VALID (223, sd, df, 1.e-40df, 1.e-40, 0.) +CONVERT_VALID (224, sd, df, 8.e-44df, 8.e-44, 0.) +CONVERT_VALID (225, sd, df, 9.e-44df, 9.e-44, 0.) +CONVERT_VALID (226, sd, df, 8.e-46df, 8.e-46, 0.) +CONVERT_VALID (227, sd, df, 7.e-46df, 7.e-46, 0.) + +CONVERT_VALID (231, df, sd, -1.2e-38, -1.2e-38df, 0.df) +CONVERT_VALID (232, df, sd, -1.1e-38f, -1.1e-38df, 0.df) +CONVERT_VALID (233, df, sd, -1.e-40, -1.e-40df, 0.df) +CONVERT_VALID (234, df, sd, -8.e-44, -8.e-44df, 0.df) +CONVERT_VALID (235, df, sd, -9.e-44, -9.e-44df, 0.df) +CONVERT_VALID (236, df, sd, -8.e-46, -8.e-46df, 0.df) +CONVERT_VALID (237, df, sd, -7.e-46, -7.e-46df, 0.df) + +CONVERT_VALID (241, sd, df, -1.2e-38df, -1.2e-38, 1.e-53) +CONVERT_VALID (242, sd, df, -1.1e-38df, -1.1e-38, 1.e-53) +CONVERT_VALID (243, sd, df, -1.e-40df, -1.e-40, 0.) +CONVERT_VALID (244, sd, df, -8.e-44df, -8.e-44, 0.) +CONVERT_VALID (245, sd, df, -9.e-44df, -9.e-44, 0.) +CONVERT_VALID (246, sd, df, -8.e-46df, -8.e-46, 0.) +CONVERT_VALID (247, sd, df, -7.e-46df, -7.e-46, 0.) + +int +main () +{ + convert_111 (); + convert_112 (); + convert_113 (); + + convert_121 (); + convert_122 (); + + convert_131 (); + convert_132 (); + + convert_141 (); + convert_142 (); + + convert_211 (); + convert_212 (); + convert_213 (); + convert_214 (); + convert_215 (); + convert_216 (); + convert_217 (); + + convert_221 (); + convert_222 (); + convert_223 (); + convert_224 (); + convert_225 (); + convert_226 (); + convert_227 (); + + convert_231 (); + convert_232 (); + convert_233 (); + convert_234 (); + convert_235 (); + convert_236 (); + convert_237 (); + + convert_241 (); + convert_242 (); + convert_243 (); + convert_244 (); + convert_245 (); + convert_246 (); + convert_247 (); + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/convert-bfp-11.c b/gcc/testsuite/c-c++-common/dfp/convert-bfp-11.c new file mode 100644 index 00000000000..d16919f81ac --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/convert-bfp-11.c @@ -0,0 +1,58 @@ +/* { dg-skip-if "" { ! "powerpc*-*-linux*" } { "*" } { "" } } */ + +/* Test decimal float conversions to and from IBM 128-bit long double. + Checks are skipped at runtime if long double is not 128 bits. + Don't force 128-bit long doubles because runtime support depends + on glibc. */ + +#include "convert.h" + +volatile _Decimal32 sd; +volatile _Decimal64 dd; +volatile _Decimal128 td; +volatile float sf; +volatile double df; +volatile long double tf; + +/* A value slightly less than DEC32_MAX can be converted in both directions. */ +CONVERT_VALID (101, sd, tf, 9.999998e96df, 9.999998e96L, 1.e+81L) +CONVERT_VALID (102, tf, sd, 9.999998e96L, 9.999998e96df, 0.df) + +/* A value slightly less than DBL_MAX can be converted in both directions. */ +CONVERT_VALID (201, tf, dd, 1.79768e+308l, 1.79768e+308dd, 0.dd) +CONVERT_VALID (202, dd, tf, 1.79768e+308dd, 1.79768e+308l, 2.e292l) +CONVERT_VALID (203, tf, td, 1.79768e+308l, 1.79768e+308dl, 1.e292dl) +CONVERT_VALID (204, td, tf, 1.79768e+308dl, 1.79768e+308l, 2.e292l) + +/* Check values that are too large for the result type. */ +CONVERT_TO_PINF (301, dd, tf, 1.8e+308dd, l) +CONVERT_TO_PINF (302, dd, tf, 9.9e+384dd, l) +CONVERT_TO_PINF (303, td, tf, 1.8e+308dl, l) +CONVERT_TO_PINF (304, td, tf, 9.9e+384dl, l) + +CONVERT_TO_PINF (311, tf, sd, 1.0e+97L, d32) +CONVERT_TO_PINF (312, tf, sd, 1.6e+308L, d32) + +int +main () +{ + if (sizeof (long double) != 16) + return 0; + + convert_101 (); + convert_102 (); + + convert_201 (); + convert_202 (); + convert_203 (); + convert_204 (); + + convert_301 (); + convert_302 (); + convert_303 (); + convert_304 (); + convert_311 (); + convert_312 (); + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/convert-bfp-12.c b/gcc/testsuite/c-c++-common/dfp/convert-bfp-12.c new file mode 100644 index 00000000000..7a909552afc --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/convert-bfp-12.c @@ -0,0 +1,16 @@ +/* Test for bug where fold wrongly removed conversions to double and + replaced them by conversions to float. */ + +#include "dfp-dbg.h" + +volatile float f = __builtin_inff (); +volatile _Decimal32 d32 = 1e40DF; + +int +main (void) +{ + if ((double) f == (double) d32) + FAILURE + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/convert-bfp-13.c b/gcc/testsuite/c-c++-common/dfp/convert-bfp-13.c new file mode 100644 index 00000000000..259cc745ce3 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/convert-bfp-13.c @@ -0,0 +1,18 @@ +/* Test for bug where fold changed binary operation to decimal + depending on typedefs. */ + +#include "dfp-dbg.h" + +volatile double d = 1.2345675; + +typedef const volatile _Decimal32 d32; + +int +main (void) +{ + _Decimal32 a = (d * d); + d32 b = (d * d); + if (a != b) + FAILURE + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/convert-bfp-14.c b/gcc/testsuite/c-c++-common/dfp/convert-bfp-14.c new file mode 100644 index 00000000000..858c92980b5 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/convert-bfp-14.c @@ -0,0 +1,15 @@ +/* Test for bug where fold narrowed decimal floating-point + operations. */ + +#include "dfp-dbg.h" + +volatile _Decimal32 f = 1.23456DF; +volatile _Decimal64 d = 1.23456DD; + +int +main (void) +{ + if ((double)((_Decimal64)f * (_Decimal64)f) != (double)(d * d)) + FAILURE + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/convert-bfp-2.c b/gcc/testsuite/c-c++-common/dfp/convert-bfp-2.c new file mode 100644 index 00000000000..463d27f355f --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/convert-bfp-2.c @@ -0,0 +1,33 @@ +/* This test assumes IEEE float and double. It also tests long double + but makes no assumption about its size or range of values. */ + +#include "convert.h" + +volatile _Decimal32 sd; +volatile _Decimal64 dd; +volatile _Decimal128 td; +volatile float sf; +volatile double df; +volatile long double tf; /* might actually be df or xf, doesn't matter */ + +CONVERT_VALID_ALL (t1, 0.0, 0.) +CONVERT_VALID_ALL (t2, 1.0, 0.) +CONVERT_VALID_ALL (t3, -11.5, 0.) +CONVERT_VALID_ALL (t4, 7.0, 0.1e-14) +CONVERT_VALID_ALL (t5, -7.0, 0.1e-14) +CONVERT_VALID_ALL (t6, 999999., 0.) +CONVERT_VALID_ALL (t7, -999999., 0.) + +int +main () +{ + CALL_VALID_ALL (t1) + CALL_VALID_ALL (t2) + CALL_VALID_ALL (t3) + CALL_VALID_ALL (t4) + CALL_VALID_ALL (t5) + CALL_VALID_ALL (t6) + CALL_VALID_ALL (t7) + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/convert-bfp-3.c b/gcc/testsuite/c-c++-common/dfp/convert-bfp-3.c new file mode 100644 index 00000000000..3e1d9d57a77 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/convert-bfp-3.c @@ -0,0 +1,21 @@ +/* This test assumes IEEE float and double. It also tests long double + but makes no assumption about its size or range of values. */ + +#include "convert.h" + +volatile _Decimal32 sd; +volatile _Decimal64 dd; +volatile _Decimal128 td; +volatile float sf; +volatile double df; +volatile long double tf; /* might actually be df or xf, doesn't matter */ + +CONVERT_ZEROES_ALL (t); + +int +main () +{ + CALL_ZEROES_ALL (t) + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/convert-bfp-4.c b/gcc/testsuite/c-c++-common/dfp/convert-bfp-4.c new file mode 100644 index 00000000000..b97b9c6cb08 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/convert-bfp-4.c @@ -0,0 +1,21 @@ +/* This test assumes IEEE float and double. It also tests long double + but makes no assumption about its size or range of values. */ + +#include "convert.h" + +volatile _Decimal32 sd; +volatile _Decimal64 dd; +volatile _Decimal128 td; +volatile float sf; +volatile double df; +volatile long double tf; /* might actually be df or xf, doesn't matter */ + +CONVERT_INF_ALL (t); + +int +main () +{ + CALL_INF_ALL (t) + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/convert-bfp-5.c b/gcc/testsuite/c-c++-common/dfp/convert-bfp-5.c new file mode 100644 index 00000000000..ada2d352cca --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/convert-bfp-5.c @@ -0,0 +1,21 @@ +/* This test assumes IEEE float and double. It also tests long double + but makes no assumption about its size or range of values. */ + +#include "convert.h" + +volatile _Decimal32 sd; +volatile _Decimal64 dd; +volatile _Decimal128 td; +volatile float sf; +volatile double df; +volatile long double tf; /* might actually be df or xf, doesn't matter */ + +CONVERT_NAN_ALL (t); + +int +main () +{ + CALL_NAN_ALL (t) + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/convert-bfp-6.c b/gcc/testsuite/c-c++-common/dfp/convert-bfp-6.c new file mode 100644 index 00000000000..64198a95f2a --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/convert-bfp-6.c @@ -0,0 +1,178 @@ +/* { dg-xfail-run-if "" { lax_strtofp } "*" "" } */ +/* { dg-options "-w" } */ + +/* This test assumes IEEE float and double. */ + +#define __STDC_WANT_DEC_FP__ +#include + +#include "convert.h" + +volatile _Decimal32 sd; +volatile _Decimal64 dd; +volatile _Decimal128 td; +volatile float sf; +volatile double df; +volatile long double tf; + +CONVERT_VALID (101, td, sf, 0.000488281251dl, 0.00048828125f, 0.f) + +/* 2**(-25) = 0.298023223876953125E-7. */ +CONVERT_VALID (102, td, sf, 2.98023223876953125e-8dl, 2.9802322387695312e-08f, + 01.e-13f) + +/* Fractional part doesn't fit. */ +CONVERT_VALID (103, df, sd, 1.0e-20, 1.0e-20df, 0.df) + +/* Exact power of 2. */ +CONVERT_VALID (104, df, sd, 0.00048828125, 0.00048828125df, 0.df) +CONVERT_VALID (105, df, sd, 1.0e-96, 0.dd, DEC32_MIN) + +/* A value slightly less than FLT_MAX can be converted in both directions. */ +CONVERT_VALID (201, sf, sd, 3.402819e+38f, 3.402819e+38df, 0.df) +CONVERT_VALID (202, sd, sf, 3.402819e+38df, 3.402819e+38f, 0.f) +CONVERT_VALID (203, sf, dd, 3.402819e+38f, 3.402819e+38dd, 1.e+30dd) +CONVERT_VALID (204, dd, sf, 3.402819e+38dd, 3.402819e+38f, 0.f) +CONVERT_VALID (205, sf, td, 3.402819e+38f, 3.402819e+38dl, 1.e+30dl) +CONVERT_VALID (206, td, sf, 3.402819e+38dl, 3.402819e+38f, 0.f) + +/* A value slightly less than DEC32_MAX can be converted in both directions. */ +CONVERT_VALID (211, sd, df, 9.999998e96df, 9.999998e96, 0.) +CONVERT_VALID (212, df, sd, 9.999998e96, 9.999998e96df, 0.df) + +/* A value slightly less than DBL_MAX can be converted in both directions. */ +CONVERT_VALID (221, df, dd, 1.79768e+308, 1.79768e+308dd, 0.dd) +CONVERT_VALID (222, dd, df, 1.79768e+308dd, 1.79768e+308, 0.) +CONVERT_VALID (223, df, td, 1.79768e+308, 1.79768e+308dl, 1.e292dl) +CONVERT_VALID (224, td, df, 1.79768e+308dl, 1.79768e+308, 0.) + +/* An integral value with 6 digits (FLT_DIG) can be converted between float + and _Decimal32 in both directions. */ +CONVERT_VALID (301, sd, sf, 100000.DF, 100000.F, 0.F) +CONVERT_VALID (302, sf, sd, 100000.F, 100000.DF, 0.DF) +CONVERT_VALID (303, sd, sf, 999999.DF, 999999.F, 0.F) +CONVERT_VALID (304, sf, sd, 999999.F, 999999.DF, 0.DF) + +/* An integral value with 7 digits (DEC32_MANT_DIG) can be converted between + _Decimal32 and double in both directions. */ +CONVERT_VALID (311, sd, df, 1000000.DF, 1000000., 0.) +CONVERT_VALID (312, df, sd, 1000000., 1000000.DF, 0.DF) +CONVERT_VALID (313, sd, df, 9999999.DF, 9999999., 0.) +CONVERT_VALID (314, df, sd, 9999999., 9999999.DF, 0.DF) + +/* An integral value with 15 digits (DBL_DIG) can be converted between + double and _Decimal64 in both directions. */ +CONVERT_VALID (321, dd, df, 100000000000000.DD, 100000000000000., 0.) +CONVERT_VALID (322, df, dd, 100000000000000., 100000000000000.DD, 0.DD); +CONVERT_VALID (323, dd, df, 999999999999999.DD, 999999999999999., 0.); +CONVERT_VALID (324, df, dd, 999999999999999., 999999999999999.DD, 0.DD); + +/* If LDBL_DIG is at least 16, an integral value with 16 digits can be + converted between _Decimal64 and long double in both directions. */ +CONVERT_VALID (331, dd, tf, 1000000000000000.DD, 1000000000000000.L, 0.L) +CONVERT_VALID (332, td, dd, 1000000000000000.L, 1000000000000000.DD, 0.DD) +CONVERT_VALID (333, dd, tf, 9999999999999999.DD, 9999999999999999.L, 0.L) +CONVERT_VALID (334, td, dd, 9999999999999999.L, 9999999999999999.DD, 0.DD) + +/* If LDBL_DIG is at least 18, an integral value with 18 digits can be + converted between long double and _Decimal128 in both directions. */ +CONVERT_VALID (341, td, tf, 100000000000000000.DL, 100000000000000000.L, 0.L) +CONVERT_VALID (342, tf, td, 100000000000000000.L, 100000000000000000.DL, 0.DL) +CONVERT_VALID (343, td, tf, 999999999999999999.DL, 999999999999999999.L, 0.L) +CONVERT_VALID (344, tf, td, 999999999999999999.L, 999999999999999999.DL, 0.DL) + +/* If LDBL_DIG is at least 31, an integral value with 31 digits can be + converted between long double and _Decimal128 in both directions. */ +CONVERT_VALID (351, td, tf, 1000000000000000000000000000000.DL, + 1000000000000000000000000000000.L, 0.L) +CONVERT_VALID (352, tf, td, 1000000000000000000000000000000.L, + 1000000000000000000000000000000.DL, 0.DL) +CONVERT_VALID (353, td, tf, 9999999999999999999999999999999.DL, + 9999999999999999999999999999999.L, 0.L) +CONVERT_VALID (354, tf, td, 9999999999999999999999999999999.L, + 9999999999999999999999999999999.DL, 0.DL) + +/* If LDBL_DIG is at least 33, an integral value with 33 digits can be + converted between long double and _Decimal128 in both directions. */ +CONVERT_VALID (361, td, tf, 100000000000000000000000000000000.DL, + 100000000000000000000000000000000.L, 0.L) +CONVERT_VALID (362, tf, td, 100000000000000000000000000000000.L, + 100000000000000000000000000000000.DL, 0.DL) +CONVERT_VALID (363, td, tf, 999999999999999999999999999999999.DL, + 999999999999999999999999999999999.L, 0.L) +CONVERT_VALID (364, tf, td, 999999999999999999999999999999999.L, + 999999999999999999999999999999999.DL, 0.DL) + +int +main () +{ + convert_101 (); + convert_102 (); + convert_103 (); + convert_104 (); + convert_105 (); + + convert_201 (); + convert_202 (); + convert_203 (); + convert_204 (); + convert_205 (); + convert_206 (); + + convert_211 (); + convert_212 (); + + convert_221 (); + convert_222 (); + convert_223 (); + convert_224 (); + + convert_301 (); + convert_302 (); + convert_303 (); + convert_304 (); + + convert_311 (); + convert_312 (); + convert_313 (); + convert_314 (); + + convert_321 (); + convert_322 (); + convert_323 (); + convert_324 (); + + if (LDBL_DIG >= 16) + { + convert_331 (); + convert_332 (); + convert_333 (); + convert_334 (); + } + + if (LDBL_DIG >= 18) + { + convert_341 (); + convert_342 (); + convert_343 (); + convert_344 (); + } + + if (LDBL_DIG >= 31) + { + convert_351 (); + convert_352 (); + convert_353 (); + convert_354 (); + } + + if (LDBL_DIG >= 33) + { + convert_361 (); + convert_362 (); + convert_363 (); + convert_364 (); + } + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/convert-bfp-7.c b/gcc/testsuite/c-c++-common/dfp/convert-bfp-7.c new file mode 100644 index 00000000000..f51d696cee6 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/convert-bfp-7.c @@ -0,0 +1,83 @@ +/* { dg-options "-w" } */ + +/* This test assumes IEEE float and double. */ + +#define __STDC_WANT_DEC_FP__ +#include + +#include "convert.h" + +volatile _Decimal32 sd; +volatile _Decimal64 dd; +volatile _Decimal128 td; +volatile float sf; +volatile double df; + +/* Check values that are too large for the result type. */ +CONVERT_TO_PINF (301, sd, sf, 4.e+38df, f) +CONVERT_TO_PINF (303, dd, sf, 4.e+38dd, f) +CONVERT_TO_PINF (302, sd, sf, 9.9e+384df, f) +CONVERT_TO_PINF (304, dd, sf, 9.9e+384dd, f) +CONVERT_TO_PINF (305, td, sf, 4.e+38dl, f) +CONVERT_TO_PINF (306, td, sf, 1.e+39dl, f) +CONVERT_TO_MINF (311, sd, sf, -4.e+38df, f) +CONVERT_TO_MINF (312, dd, sf, -4.e+38dd, f) +CONVERT_TO_MINF (313, sd, sf, -9.9e+384df, f) +CONVERT_TO_MINF (314, dd, sf, -9.9e+384dd, f) +CONVERT_TO_MINF (315, td, sf, -4.e+38dl, f) +CONVERT_TO_MINF (316, td, sf, -1.e+39dl, f) + +CONVERT_TO_PINF (321, dd, df, 1.8e+308dd,) +CONVERT_TO_PINF (322, dd, df, 9.9e+384dd,) +CONVERT_TO_PINF (323, td, df, 1.8e+308dl,) +CONVERT_TO_PINF (324, td, df, 9.9e+384dl,) +CONVERT_TO_PINF (325, dd, df, 1.e309dd,) +CONVERT_TO_PINF (326, td, df, 1.e309dl,) +CONVERT_TO_MINF (331, dd, df, -1.8e+308dd,) +CONVERT_TO_MINF (332, dd, df, -9.9e+384dd,) +CONVERT_TO_MINF (333, td, df, -1.8e+308dl,) +CONVERT_TO_MINF (334, td, df, -9.9e+384dl,) +CONVERT_TO_MINF (335, dd, df, -1.e309dd,) +CONVERT_TO_MINF (336, td, df, -1.e309dl,) + +CONVERT_TO_PINF (341, df, sd, 1.0e+97, d32) +CONVERT_TO_PINF (342, df, sd, 1.6e+308, d32) +CONVERT_TO_MINF (351, df, sd, -1.0e+97, d32) +CONVERT_TO_MINF (352, df, sd, -1.6e+308, d32) + +int +main () +{ + convert_301 (); + convert_302 (); + convert_303 (); + convert_304 (); + convert_305 (); + convert_306 (); + convert_311 (); + convert_312 (); + convert_313 (); + convert_314 (); + convert_315 (); + convert_316 (); + + convert_321 (); + convert_322 (); + convert_323 (); + convert_324 (); + convert_325 (); + convert_326 (); + convert_331 (); + convert_332 (); + convert_333 (); + convert_334 (); + convert_335 (); + convert_336 (); + + convert_341 (); + convert_342 (); + convert_351 (); + convert_352 (); + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/convert-bfp-8.c b/gcc/testsuite/c-c++-common/dfp/convert-bfp-8.c new file mode 100644 index 00000000000..532bd861314 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/convert-bfp-8.c @@ -0,0 +1,71 @@ +/* { dg-options "-w" } */ + +/* This test assumes IEEE float and double. */ + +#define __STDC_WANT_DEC_FP__ +#include + +#include "convert.h" + +volatile _Decimal32 sd; +volatile _Decimal64 dd; +volatile _Decimal128 td; +volatile float sf; +volatile double df; + +/* Values slightly smaller than minimum (closest to zero) for result type. */ +CONVERT_VALID (401, sd, sf, 1.e-39df, 0.f, FLT_MIN) +CONVERT_VALID (402, sd, sf, -1.e-39df, 0.f, FLT_MIN) +CONVERT_VALID (403, sd, sf, 1.1e-38df, 0.f, FLT_MIN) +CONVERT_VALID (404, sd, sf, -1.1e-38df, 0.f, FLT_MIN) + +CONVERT_VALID (411, dd, sf, 1.e-39dd, 0.f, FLT_MIN) +CONVERT_VALID (412, dd, sf, -1.e-39dd, 0.f, FLT_MIN) +CONVERT_VALID (413, dd, sf, 1.1e-38dd, 0.f, FLT_MIN) +CONVERT_VALID (414, dd, sf, -1.1e-38dd, 0.f, FLT_MIN) + +CONVERT_VALID (421, dd, df, 3.e-309dd, 0., DBL_MIN) +CONVERT_VALID (422, dd, df, -3.e-309dd, 0., DBL_MIN) +CONVERT_VALID (423, dd, df, 2.e-308dd, 0., DBL_MIN) +CONVERT_VALID (424, dd, df, -2.e-308dd, 0., DBL_MIN) + +CONVERT_VALID (431, td, sf, 1.e-39dl, 0.f, FLT_MIN) +CONVERT_VALID (432, td, sf, -1.e-39dl, 0.f, FLT_MIN) +CONVERT_VALID (433, td, sf, 1.1e-38dl, 0.f, FLT_MIN) +CONVERT_VALID (434, td, sf, -1.1e-38dl, 0.f, FLT_MIN) + +CONVERT_VALID (441, td, df, 3.e-309dl, 0., DBL_MIN) +CONVERT_VALID (442, td, df, -3.e-309dl, 0., DBL_MIN) +CONVERT_VALID (443, td, df, 2.e-308dl, 0., DBL_MIN) +CONVERT_VALID (444, td, df, -2.e-308dl, 0., DBL_MIN) + +int +main () +{ + convert_401 (); + convert_402 (); + convert_403 (); + convert_404 (); + + convert_411 (); + convert_412 (); + convert_413 (); + convert_414 (); + + convert_421 (); + convert_422 (); + convert_423 (); + convert_424 (); + + convert_431 (); + convert_432 (); + convert_433 (); + convert_434 (); + + convert_441 (); + convert_442 (); + convert_443 (); + convert_444 (); + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/convert-bfp-9.c b/gcc/testsuite/c-c++-common/dfp/convert-bfp-9.c new file mode 100644 index 00000000000..e609087525a --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/convert-bfp-9.c @@ -0,0 +1,192 @@ +/* { dg-xfail-run-if "" { lax_strtofp } "*" "" } */ +/* { dg-options "-w" } */ + +/* This test assumes IEEE float and double. */ + +#define __STDC_WANT_DEC_FP__ +#include + +#include "convert.h" + +volatile _Decimal32 sd; +volatile _Decimal64 dd; +volatile _Decimal128 td; +volatile float sf; +volatile double df; + +/* Exponent values that might cause problems with a particular + implementation. */ + +CONVERT_VALID (101, dd, df, 1.e309dd, 1.e309, 0.) +CONVERT_VALID (102, dd, df, 1.e308dd, 1.e308, 0.) +CONVERT_VALID (103, dd, df, 1.e307dd, 1.e307, 0.) +CONVERT_VALID (104, dd, df, 1.e306dd, 1.e306, 0.) +CONVERT_VALID (105, dd, df, 1.e305dd, 1.e305, 0.) +CONVERT_VALID (106, dd, df, 1.e304dd, 1.e304, 0.) +CONVERT_VALID (107, dd, df, 1.e303dd, 1.e303, 0.) +CONVERT_VALID (108, dd, df, 1.e302dd, 1.e302, 0.) +CONVERT_VALID (109, dd, df, 1.e301dd, 1.e301, 0.) +CONVERT_VALID (110, dd, df, 1.e300dd, 1.e300, 0.) +CONVERT_VALID (111, dd, df, 1.e299dd, 1.e299, 0.) +CONVERT_VALID (112, dd, df, 1.e298dd, 1.e298, 0.) +CONVERT_VALID (113, dd, df, 1.e297dd, 1.e297, 0.) +CONVERT_VALID (114, dd, df, 1.e296dd, 1.e296, 0.) +CONVERT_VALID (115, dd, df, 1.e295dd, 1.e295, 0.) +CONVERT_VALID (116, dd, df, 1.e294dd, 1.e294, 0.) +CONVERT_VALID (117, dd, df, 1.e293dd, 1.e293, 0.) +CONVERT_VALID (118, dd, df, 1.e292dd, 1.e292, 0.) +CONVERT_VALID (119, dd, df, 1.e291dd, 1.e291, 0.) +CONVERT_VALID (120, dd, df, 1.e290dd, 1.e290, 0.) + +CONVERT_VALID (201, dd, df, 1.e-309dd, 1.e-309, 0.) +CONVERT_VALID (202, dd, df, 1.e-308dd, 1.e-308, 0.) +CONVERT_VALID (203, dd, df, 1.e-307dd, 1.e-307, 0.) +CONVERT_VALID (204, dd, df, 1.e-306dd, 1.e-306, 0.) +CONVERT_VALID (205, dd, df, 1.e-305dd, 1.e-305, 0.) +CONVERT_VALID (206, dd, df, 1.e-304dd, 1.e-304, 0.) +CONVERT_VALID (207, dd, df, 1.e-303dd, 1.e-303, 0.) +CONVERT_VALID (208, dd, df, 1.e-302dd, 1.e-302, 0.) +CONVERT_VALID (209, dd, df, 1.e-301dd, 1.e-301, 0.) +CONVERT_VALID (210, dd, df, 1.e-300dd, 1.e-300, 0.) +CONVERT_VALID (211, dd, df, 1.e-299dd, 1.e-299, 0.) +CONVERT_VALID (212, dd, df, 1.e-298dd, 1.e-298, 0.) +CONVERT_VALID (213, dd, df, 1.e-297dd, 1.e-297, 0.) +CONVERT_VALID (214, dd, df, 1.e-296dd, 1.e-296, 0.) +CONVERT_VALID (215, dd, df, 1.e-295dd, 1.e-295, 0.) +CONVERT_VALID (216, dd, df, 1.e-294dd, 1.e-294, 0.) +CONVERT_VALID (217, dd, df, 1.e-293dd, 1.e-293, 0.) +CONVERT_VALID (218, dd, df, 1.e-292dd, 1.e-292, 0.) +CONVERT_VALID (219, dd, df, 1.e-291dd, 1.e-291, 0.) +CONVERT_VALID (220, dd, df, 1.e-290dd, 1.e-290, 0.) + +CONVERT_VALID (301, td, df, 1.e309dl, 1.e309, 0.) +CONVERT_VALID (302, td, df, 1.e308dl, 1.e308, 0.) +CONVERT_VALID (303, td, df, 1.e307dl, 1.e307, 0.) +CONVERT_VALID (304, td, df, 1.e306dl, 1.e306, 0.) +CONVERT_VALID (305, td, df, 1.e305dl, 1.e305, 0.) +CONVERT_VALID (306, td, df, 1.e304dl, 1.e304, 0.) +CONVERT_VALID (307, td, df, 1.e303dl, 1.e303, 0.) +CONVERT_VALID (308, td, df, 1.e302dl, 1.e302, 0.) +CONVERT_VALID (309, td, df, 1.e301dl, 1.e301, 0.) +CONVERT_VALID (310, td, df, 1.e300dl, 1.e300, 0.) +CONVERT_VALID (311, td, df, 1.e299dl, 1.e299, 0.) +CONVERT_VALID (312, td, df, 1.e298dl, 1.e298, 0.) +CONVERT_VALID (313, td, df, 1.e297dl, 1.e297, 0.) +CONVERT_VALID (314, td, df, 1.e296dl, 1.e296, 0.) +CONVERT_VALID (315, td, df, 1.e295dl, 1.e295, 0.) +CONVERT_VALID (316, td, df, 1.e294dl, 1.e294, 0.) +CONVERT_VALID (317, td, df, 1.e293dl, 1.e293, 0.) +CONVERT_VALID (318, td, df, 1.e292dl, 1.e292, 0.) +CONVERT_VALID (319, td, df, 1.e291dl, 1.e291, 0.) +CONVERT_VALID (320, td, df, 1.e290dl, 1.e290, 0.) + +CONVERT_VALID (401, td, df, 1.e-309dl, 1.e-309, 0.) +CONVERT_VALID (402, td, df, 1.e-308dl, 1.e-308, 0.) +CONVERT_VALID (403, td, df, 1.e-307dl, 1.e-307, 0.) +CONVERT_VALID (404, td, df, 1.e-306dl, 1.e-306, 0.) +CONVERT_VALID (405, td, df, 1.e-305dl, 1.e-305, 0.) +CONVERT_VALID (406, td, df, 1.e-304dl, 1.e-304, 0.) +CONVERT_VALID (407, td, df, 1.e-303dl, 1.e-303, 0.) +CONVERT_VALID (408, td, df, 1.e-302dl, 1.e-302, 0.) +CONVERT_VALID (409, td, df, 1.e-301dl, 1.e-301, 0.) +CONVERT_VALID (410, td, df, 1.e-300dl, 1.e-300, 0.) +CONVERT_VALID (411, td, df, 1.e-299dl, 1.e-299, 0.) +CONVERT_VALID (412, td, df, 1.e-298dl, 1.e-298, 0.) +CONVERT_VALID (413, td, df, 1.e-297dl, 1.e-297, 0.) +CONVERT_VALID (414, td, df, 1.e-296dl, 1.e-296, 0.) +CONVERT_VALID (415, td, df, 1.e-295dl, 1.e-295, 0.) +CONVERT_VALID (416, td, df, 1.e-294dl, 1.e-294, 0.) +CONVERT_VALID (417, td, df, 1.e-293dl, 1.e-293, 0.) +CONVERT_VALID (418, td, df, 1.e-292dl, 1.e-292, 0.) +CONVERT_VALID (419, td, df, 1.e-291dl, 1.e-291, 0.) +CONVERT_VALID (420, td, df, 1.e-290dl, 1.e-290, 0.) + +int +main () +{ + convert_101 (); + convert_102 (); + convert_103 (); + convert_104 (); + convert_105 (); + convert_106 (); + convert_107 (); + convert_108 (); + convert_109 (); + convert_110 (); + convert_111 (); + convert_112 (); + convert_113 (); + convert_114 (); + convert_115 (); + convert_116 (); + convert_117 (); + convert_118 (); + convert_119 (); + convert_120 (); + + convert_201 (); + convert_202 (); + convert_203 (); + convert_204 (); + convert_205 (); + convert_206 (); + convert_207 (); + convert_208 (); + convert_209 (); + convert_210 (); + convert_211 (); + convert_212 (); + convert_213 (); + convert_214 (); + convert_215 (); + convert_216 (); + convert_217 (); + convert_218 (); + convert_219 (); + convert_220 (); + + convert_301 (); + convert_302 (); + convert_303 (); + convert_304 (); + convert_305 (); + convert_306 (); + convert_307 (); + convert_308 (); + convert_309 (); + convert_310 (); + convert_311 (); + convert_312 (); + convert_313 (); + convert_314 (); + convert_315 (); + convert_316 (); + convert_317 (); + convert_318 (); + convert_319 (); + convert_320 (); + + convert_401 (); + convert_402 (); + convert_403 (); + convert_404 (); + convert_405 (); + convert_406 (); + convert_407 (); + convert_408 (); + convert_409 (); + convert_410 (); + convert_411 (); + convert_412 (); + convert_413 (); + convert_414 (); + convert_415 (); + convert_416 (); + convert_417 (); + convert_418 (); + convert_419 (); + convert_420 (); + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/convert-bfp-fold.c b/gcc/testsuite/c-c++-common/dfp/convert-bfp-fold.c new file mode 100644 index 00000000000..d62a7e4b21c --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/convert-bfp-fold.c @@ -0,0 +1,118 @@ +/* { dg-options "-O2" } */ + +/* N1150 5.2 Conversions among decimal floating types and between + decimal floating types and generic floating types. + C99 6.3.1.5(4) Conversions, arithmetic operands, real floating types. */ + +#include "dfp-dbg.h" + +_Decimal32 d32; +_Decimal64 d64; +_Decimal128 d128; +float sf; +double df; +long double tf; + +extern void link_error (void); + +int +main () +{ + /* Conversions from decimal float to binary float. */ + + /* Conversions from _Decimal32. */ + d32 = 2.0df; + sf = d32; + if (sf != 2.0f) + link_error (); + + df = d32; + if (df != 2.0) + link_error (); + + tf = d32; + if (tf != 2.0l) + link_error (); + + /* Conversions from _Decimal64. */ + d64 = -7.0dd; + sf = d64; + if (sf != -7.0f) + link_error (); + + df = d64; + if (df != -7.0) + link_error (); + + tf = d64; + if (tf != -7.0l) + link_error (); + + /* Conversions from _Decimal128. */ + d128 = 30.0dl; + sf = d128; + if (sf != 30.0f) + link_error (); + + df = d128; + if (df != 30.0) + link_error (); + + df = d128; + if (df != 30.0l) + link_error (); + + /* Conversions from binary float to decimal float. */ + sf = 30.0f; + d128 = sf; + if (d128 != 30.0dl) + link_error (); + + d64 = sf; + if (d64 != 30.0dd) + link_error (); + + d32 = sf; + if (d32 != 30.0df) + link_error (); + + df = -2.0; + d128 = df; + if (d128 != -2.0dl) + link_error (); + + d64 = df; + if (d64 != -2.0dd) + link_error (); + + d32 = df; + if (d32 != -2.0df) + link_error (); + + tf = -22.0l; + d128 = tf; + if (d128 != -22.0dl) + link_error (); + + d64 = tf; + if (d64 != -22.0dd) + link_error (); + + d32 = tf; + if (d32 != -22.0df) + link_error (); + + /* 2**(-11) = 0.00048828125. */ + d128 = 0.000488281251dl; + sf = d128; + if (sf != 0.00048828125f) + link_error (); + /* 2**(-25) = 0.298023223876953125E-7. */ + d128 = 2.98023223876953125E-8dl; + df = d128; + if (df < (2.9802322387695312e-08 - 0.00000000001) + || df > (2.9802322387695312e-08 + 0.00000000001)) + link_error (); + + return 0; +} diff --git a/gcc/testsuite/c-c++-common/dfp/convert-bfp.c b/gcc/testsuite/c-c++-common/dfp/convert-bfp.c new file mode 100644 index 00000000000..710538d467b --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/convert-bfp.c @@ -0,0 +1,131 @@ +/* N1150 5.2 Conversions among decimal floating types and between + decimal floating types and generic floating types. + C99 6.3.1.5(4) Conversions, arithmetic operands, real floating types. */ + +/* Long double isn't supported yet at runtime, so disable those checks. */ + +#include "dfp-dbg.h" + +static int skip_long_double; + +volatile _Decimal32 d32; +volatile _Decimal64 d64; +volatile _Decimal128 d128; +volatile float sf; +volatile double df; +volatile long double tf; + +int +main () +{ + /* Conversions from decimal float to binary float. */ + + if (sizeof (long double) == sizeof (double)) + skip_long_double = 1; + + /* Conversions from _Decimal32. */ + d32 = 2.0df; + sf = d32; + if (sf != 2.0f) + FAILURE + + df = d32; + if (df != 2.0) + FAILURE + + if (skip_long_double == 0) + { + tf = d32; + if (tf != 2.0l) + FAILURE + } + + /* Conversions from _Decimal64. */ + d64 = -7.0dd; + sf = d64; + if (sf != -7.0f) + FAILURE + + df = d64; + if (df != -7.0) + FAILURE + + if (skip_long_double == 0) + { + tf = d64; + if (tf != -7.0l) + FAILURE + } + + /* Conversions from _Decimal128. */ + d128 = 30.0dl; + sf = d128; + if (sf != 30.0f) + FAILURE + + df = d128; + if (df != 30.0) + FAILURE + + df = d128; + if (df != 30.0l) + FAILURE + + /* Conversions from binary float to decimal float. */ + sf = 30.0f; + d32 = sf; + if (d32 != 30.0df) + FAILURE + + d64 = sf; + if (d64 != 30.0dd) + FAILURE + + df = -2.0; + d32 = df; + if (d32 != -2.0df) + FAILURE + + d64 = df; + if (d64 != -2.0dd) + FAILURE + + d128 = df; + if (d128 != -2.0dl) + FAILURE + + sf = 30.0f; + d128 = sf; + if (d128 != 30.0dl) + FAILURE + + if (skip_long_double == 0) + { + tf = -22.0l; + d32 = tf; + if (d32 != -22.0df) + FAILURE + + d64 = tf; + if (d64 != -22.0dd) + FAILURE + + d128 = tf; + if (d128 != -22.0dl) + FAILURE + } + + /* 2**(-11) = 0.00048828125. */ + d128 = 0.000488281251dl; + sf = d128; + if (sf != 0.00048828125f) + FAILURE + /* 2**(-25) = 0.298023223876953125E-7. */ + d128 = 2.98023223876953125E-8dl; + df = d128; + if (df < (2.9802322387695312e-08 - 0.00000000001) + || df > (2.9802322387695312e-08 + 0.00000000001)) + FAILURE + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/convert-dfp-fold-2.c b/gcc/testsuite/c-c++-common/dfp/convert-dfp-fold-2.c new file mode 100644 index 00000000000..073f7abc4a6 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/convert-dfp-fold-2.c @@ -0,0 +1,15 @@ +/* Test for bug where fold narrowed decimal floating-point + operations. */ + +#include "dfp-dbg.h" + +volatile _Decimal32 f = 1.23456DF; +volatile _Decimal64 d = 1.23456DD; + +int +main (void) +{ + if ((_Decimal128)((_Decimal64)f * (_Decimal64)f) != (_Decimal128)(d * d)) + FAILURE + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/convert-dfp-fold.c b/gcc/testsuite/c-c++-common/dfp/convert-dfp-fold.c new file mode 100644 index 00000000000..67c9d71c224 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/convert-dfp-fold.c @@ -0,0 +1,47 @@ +/* { dg-options "-O2" } */ + +/* N1150 5.2 Conversions among decimal floating types and between + decimal floating types and generic floating types. + C99 6.3.1.5(3) New. */ + +#include "dfp-dbg.h" + +extern void link_error (); + +int +main () +{ + _Decimal32 d32; + _Decimal64 d64; + _Decimal128 d128; + + /* Conversions to larger types. */ + d32 = 123.4df; + d64 = d32; + if (d64 != 123.4dd) + link_error (); + d128 = d32; + if (d128 != 123.4dl) + link_error (); + d64 = 345.678dd; + d128 = d64; + if (d128 != 345.678dl) + link_error (); + + /* Conversions to smaller types for which the value fits. */ + d64 = 3456.789dd; + d32 = d64; + if (d32 != 3456.789df) + link_error (); + d128 = 123.4567dl; + d32 = d128; + if (d32 != 123.4567dl) + link_error (); + + d128 = 1234567890.123456dl; + d64 = d128; + if (d64 != 1234567890.123456dd) + link_error (); + + return 0; +} diff --git a/gcc/testsuite/c-c++-common/dfp/convert-dfp.c b/gcc/testsuite/c-c++-common/dfp/convert-dfp.c new file mode 100644 index 00000000000..d52ba51b0be --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/convert-dfp.c @@ -0,0 +1,94 @@ +/* { dg-options "-O0" } */ + +/* N1150 5.2 Conversions among decimal floating types and between + decimal floating types and generic floating types. + C99 6.3.1.5(3) New. + + Test various conversions involving decimal floating types. */ + +#ifndef __STDC_WANT_DEC_FP__ +#define __STDC_WANT_DEC_FP__ 1 +#endif + +#include "dfp-dbg.h" +#include + +volatile _Decimal32 d32; +volatile _Decimal64 d64; +volatile _Decimal128 d128; + +int +main () +{ + /* Conversions to larger types. */ + d32 = 123.4df; + d64 = d32; + if (d64 != 123.4dd) + FAILURE + d128 = d32; + if (d128 != 123.4dl) + FAILURE + d64 = 345.678dd; + d128 = d64; + if (d128 != 345.678dl) + FAILURE + + /* Conversions to smaller types for which the value fits. */ + d64 = 3456.789dd; + d32 = d64; + if (d32 != 3456.789df) + FAILURE + d128 = 123.4567dl; + d32 = d128; + if (d32 != 123.4567df) + FAILURE + + d128 = 1234567890.123456dl; + d64 = d128; + if (d64 != 1234567890.123456dd) + FAILURE + + /* Test demotion to non-representable decimal floating type. */ + + /* Assumes a default rounding mode of 'near'. This uses the rules + describe in the 27 July 2005 draft of IEEE 754r, which are much + more clear that what's described in draft 5 of N1107. */ + + /* Rounds to what _Decimal32 can handle. */ + d64 = 9.99999949E96DD; + d32 = d64; + if (d32 != DEC32_MAX) + FAILURE + + /* Rounds to more than _Decimal32 can handle. */ + d64 = 9.9999995E96DD; + d32 = d64; + if (d32 != __builtin_infd32()) + FAILURE + + /* Rounds to what _Decimal32 can handle. */ + d128 = 9.99999949E96DD; + d32 = d128; + if (d32 != DEC32_MAX) + FAILURE + + /* Rounds to more than _Decimal32 can handle. */ + d128= 9.9999995E96DD; + d32 = d128; + if (d32 != __builtin_infd32()) + FAILURE + + /* Rounds to what _Decimal64 can handle. */ + d128 = 9.99999999999999949E384DL; + d64 = d128; + if (d64 != DEC64_MAX) + FAILURE + + /* Rounds to more than _Decimal64 can handle. */ + d128 = 9.9999999999999995E384DL; + d64 = d128; + if (d64 != __builtin_infd64()) + FAILURE + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/convert-int-fold.c b/gcc/testsuite/c-c++-common/dfp/convert-int-fold.c new file mode 100644 index 00000000000..038559d41e4 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/convert-int-fold.c @@ -0,0 +1,173 @@ +/* { dg-options "-O2" } */ + +/* N1150 5.1 Conversion between decimal floating integer. + C99 6.3.1.4(1a) New. + These should all be folded at compile time. */ + +#include "dfp-dbg.h" + +#ifdef __cplusplus +#define BOOL bool +#else +#define BOOL _Bool +#endif + +extern void link_error (void); + +int +main () +{ + _Decimal32 d32; + _Decimal64 d64; + _Decimal128 d128; + unsigned int ui; + unsigned long ul; + unsigned long long ull; + int si; + long sl; + long long sll; + BOOL b; + + /* C99 Section 6.7.2 Type specifiers. Type _Bool is + mentioned in this section. Conversions between + BOOL and DFP types. */ + + /* Decimal float to unsigned integer. */ + d32 = 456.789df; + d64 = 23.456789dd; + d128 = 1234.5678dl; + + ui = d32; + if (ui != 456U) + link_error (); + ul = d32; + if (ul != 456UL) + link_error (); + ull = d32; + if (ull != 456ULL) + link_error (); + + ui = d64; + if (ui != 23U) + link_error (); + ul = d64; + if (ul != 23UL) + link_error (); + ull = d64; + if (ull != 23ULL) + link_error (); + + ui = d128; + if (ui != 1234U) + link_error (); + ul = d128; + if (ul != 1234UL) + link_error (); + ull = d128; + if (ull != 1234ULL) + link_error (); + + /* Decimal float to signed integer. */ + + /* Decimal float to BOOL. */ + d32 = 1.23df; + d64 = -3.4dd; + d128 = 0.00003dl; + + b = d32; + if (!b) + link_error (); + b = d64; + if (!b) + link_error (); + b = d128; + if (!b) + link_error (); + + /* Unsigned integer to decimal float. */ + ui = 987U; + ul = 345678UL; + ull = 1234567ULL; + + d32 = ui; + if (d32 != 987.0df) + link_error (); + d32 = ul; + if (d32 != 345678.0df) + link_error (); + d32 = ull; + if (d32 != 1234567.df) + link_error (); + + d64 = ui; + if (d64 != 987.0dd) + link_error (); + d64 = ul; + if (d64 != 345678.0dd) + link_error (); + d64 = ull; + if (d64 != 1234567.dd) + link_error (); + + d128 = ui; + if (d128 != 987.0dl) + link_error (); + d128 = ul; + if (d128 != 345678.0dl) + link_error (); + d128 = ull; + if (d128 != 1234567.dl) + link_error (); + + /* Signed integer to decimal float. */ + si = -987; + sl = -345678; + sll = -1234567; + + d32 = si; + if (d32 != -987.0df) + link_error (); + d32 = sl; + if (d32 != -345678.0df) + link_error (); + d32 = sll; + if (d32 != -1234567.df) + link_error (); + + d64 = si; + if (d64 != -987.0dd) + link_error (); + d64 = sl; + if (d64 != -345678.0dd) + link_error (); + d64 = sll; + if (d64 != -1234567.dd) + link_error (); + + d128 = si; + if (d128 != -987.0dl) + link_error (); + d128 = sl; + if (d128 != -345678.0dl) + link_error (); + d128 = sll; + if (d128 != -1234567.dl) + link_error (); + + /* BOOL to decimal float. */ + d32 = 0.0DF; + d64 = 0.0DD; + d128 = 0.0DL; + + b = d32; + if (b) + link_error (); + b = d64; + if (b) + link_error (); + b = d128; + if (b) + link_error (); + + return 0; +} diff --git a/gcc/testsuite/c-c++-common/dfp/convert-int-max-fold.c b/gcc/testsuite/c-c++-common/dfp/convert-int-max-fold.c new file mode 100644 index 00000000000..3f6faae34cc --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/convert-int-max-fold.c @@ -0,0 +1,148 @@ +/* { dg-options "-O2 -w" } */ + +/* N1150 5.1 Conversions from decimal float to integer. */ + +/* Test decimal float to integer conversions for values at the limit of + what will fit into the destination type. This assumes 32-bit int and + 64-bit long long (there's a check for that below). This version tests + conversions during compilation. */ + +#include "dfp-dbg.h" + +extern void link_error (void); + +void +doit () +{ + _Decimal32 d32; + _Decimal64 d64; + _Decimal128 d128; + int si; + unsigned int ui; + long long sll; + unsigned long long ull; + + /* _Decimal32 to int. */ + + d32 = 2147483.E3DF; + si = d32; + if (si != 2147483000) + link_error (); + + d32 = -2147483.E3DF; + si = d32; + if (si != -2147483000) + link_error (); + + /* _Decimal32 to unsigned int. */ + + d32 = 4.294967E9DF; + ui = d32; + if (ui != 4294967000U) + link_error (); + + /* _Decimal32 to long long. */ + + d32 = 922.3372E16DF; + sll = d32; + if (sll != 9223372000000000000LL) + link_error (); + + d32 = -92233.72E14DF; + sll = d32; + if (sll != -9223372000000000000LL) + link_error (); + + /* _Decimal32 to unsigned long long. */ + + d32 = 0.1844674E20DF; + ull = d32; + if (ull != 18446740000000000000ULL) + link_error (); + + /* _Decimal64 to int. */ + + d64 = 2.147483647E9DD; + si = d64; + if (si != 2147483647) + link_error (); + + d64 = -2147483648.DD; + si = d64; + if (si != -2147483648) + link_error (); + + /* _Decimal64 to unsigned int. */ + + d64 = 42949.67295E5DD; + ui = d64; + if (ui != 4294967295) + link_error (); + + /* _Decimal64 to long long. */ + + d64 = 9.223372036854775E18DD; + sll = d64; + if (sll != 9223372036854775000LL) + link_error (); + + d64 = -92233720.36854775E11DD; + sll = d64; + if (sll != -9223372036854775000LL) + link_error (); + + /* _Decimal64 to unsigned long long. */ + d64 = 1844674407370955.E4DD; + ull = d64; + if (ull != 18446744073709550000ULL) + link_error (); + + /* _Decimal128 to int. */ + + d128 = 2.147483647E9DL; + si = d128; + if (si != 2147483647) + link_error (); + + d128 = -2147483648.DL; + si = d128; + if (si != -2147483648) + link_error (); + + /* _Decimal128 to unsigned int. */ + + d128 = 4294.967295E6DL; + ui = d128; + if (ui != 4294967295) + link_error (); + + /* _Decimal128 to long long. */ + + d128 = 9223372036854775807.DL; + sll = d128; + if (sll != 9223372036854775807LL) + link_error (); + + d128 = -9.223372036854775808E19DL; + sll = d128; + if (sll != -9223372036854775807LL - 1LL) + link_error (); + + /* _Decimal128 to unsigned long long. */ + d128 = 18446744073709551615.DL; + ull = d128; + if (ull != 18446744073709551615ULL) + link_error (); +} + +int +main () +{ + /* This test assumes 32-bit int and 64-bit long long. */ + + if (sizeof (int) != 4 || sizeof (long long) != 8) + return 0; + + doit (); + return 0; +} diff --git a/gcc/testsuite/c-c++-common/dfp/convert-int-max.c b/gcc/testsuite/c-c++-common/dfp/convert-int-max.c new file mode 100644 index 00000000000..724627d3763 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/convert-int-max.c @@ -0,0 +1,146 @@ +/* { dg-options "-O0 -w" } */ + +/* N1150 5.1 Conversions from decimal float to integer. */ + +/* Test decimal float to integer conversions for values at the limit of + what will fit into the destination type. This assumes 32-bit int and + 64-bit long long (there's a check for that below). */ + +#include "dfp-dbg.h" + +volatile _Decimal32 d32; +volatile _Decimal64 d64; +volatile _Decimal128 d128; +volatile int si; +volatile unsigned int ui; +volatile long long sll; +volatile unsigned long long ull; + +void +doit () +{ + /* _Decimal32 to int. */ + + d32 = 2147483.E3DF; + si = d32; + if (si != 2147483000) + FAILURE + + d32 = -2147483.E3DF; + si = d32; + if (si != -2147483000) + FAILURE + + /* _Decimal32 to unsigned int. */ + + d32 = 4.294967E9DF; + ui = d32; + if (ui != 4294967000U) + FAILURE + + /* _Decimal32 to long long. */ + + d32 = 922.3372E16DF; + sll = d32; + if (sll != 9223372000000000000LL) + FAILURE + + d32 = -92233.72E14DF; + sll = d32; + if (sll != -9223372000000000000LL) + FAILURE + + /* _Decimal32 to unsigned long long. */ + + d32 = .1844674E20DF; + ull = d32; + if (ull != 18446740000000000000ULL) + FAILURE + + /* _Decimal64 to int. */ + + d64 = 2.147483647E9DD; + si = d64; + if (si != 2147483647) + FAILURE + + d64 = -2147483648.DD; + si = d64; + if (si != -2147483648) + FAILURE + + /* _Decimal64 to unsigned int. */ + + d64 = 42949.67295E5DD; + ui = d64; + if (ui != 4294967295) + FAILURE + + /* _Decimal64 to long long. */ + + d64 = 9.223372036854775E18DD; + sll = d64; + if (sll != 9223372036854775000LL) + FAILURE + + d64 = -92233720.36854775E11DD; + sll = d64; + if (sll != -9223372036854775000LL) + FAILURE + + /* _Decimal64 to unsigned long long. */ + d64 = 1844674407370955.E4DD; + ull = d64; + if (ull != 18446744073709550000ULL) + FAILURE + + /* _Decimal128 to int. */ + + d128 = 2.147483647E9DL; + si = d128; + if (si != 2147483647) + FAILURE + + d128 = -2147483648.DL; + si = d128; + if (si != -2147483648) + FAILURE + + /* _Decimal128 to unsigned int. */ + + d128 = 4294.967295E6DL; + ui = d128; + if (ui != 4294967295) + FAILURE + + /* _Decimal128 to long long. */ + + d128 = 9223372036854775807.DL; + sll = d128; + if (sll != 9223372036854775807LL) + FAILURE + + d128 = -9.223372036854775808E19DL; + sll = d128; + if (sll != -9223372036854775807LL - 1LL) + FAILURE + + /* _Decimal128 to unsigned long long. */ + d128 = 18446744073709551615.DL; + ull = d128; + if (ull != 18446744073709551615ULL) + FAILURE +} + +int +main () +{ + /* This test assumes 32-bit int and 64-bit long long. */ + + if (sizeof (int) != 4 || sizeof (long long) != 8) + return 0; + + doit (); + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/convert-int-saturate.c b/gcc/testsuite/c-c++-common/dfp/convert-int-saturate.c new file mode 100644 index 00000000000..c92502d56ad --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/convert-int-saturate.c @@ -0,0 +1,64 @@ +/* N1150 5.1 Conversion between decimal floating integer. + C99 6.3.1.4(1a) New. + Test integer saturation. */ + +#ifndef __STDC_WANT_DEC_FP__ +#define __STDC_WANT_DEC_FP__ 1 +#endif + +#include "dfp-dbg.h" +#include +#include + +volatile _Decimal32 d32; +volatile _Decimal64 d64; +volatile _Decimal128 d128; + +volatile signed int si; +volatile unsigned int usi; +volatile unsigned long long udi; + +int +main () +{ + + /* Unsigned. */ + usi = DEC32_MAX; /* { dg-warning "overflow in implicit constant conversion" } */ + if (usi != UINT_MAX) + FAILURE + + usi = DEC64_MAX; /* { dg-warning "overflow in implicit constant conversion" } */ + if (usi != UINT_MAX) + FAILURE + + usi = DEC128_MAX; /* { dg-warning "overflow in implicit constant conversion" } */ + if (usi != UINT_MAX) + FAILURE + + /* Signed. */ + si = DEC32_MAX; /* { dg-warning "overflow in implicit constant conversion" } */ + if (si != INT_MAX) + FAILURE + + si = DEC64_MAX; /* { dg-warning "overflow in implicit constant conversion" } */ + if (si != INT_MAX) + FAILURE + + si = DEC128_MAX; /* { dg-warning "overflow in implicit constant conversion" } */ + if (si != INT_MAX) + FAILURE + + si = - DEC32_MAX; /* { dg-warning "overflow in implicit constant conversion" } */ + if (si != INT_MIN) + FAILURE + + si = - DEC64_MAX; /* { dg-warning "overflow in implicit constant conversion" } */ + if (si != INT_MIN) + FAILURE + + si = - DEC128_MAX; /* { dg-warning "overflow in implicit constant conversion" } */ + if (si != INT_MIN) + FAILURE + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/convert-int.c b/gcc/testsuite/c-c++-common/dfp/convert-int.c new file mode 100644 index 00000000000..1525d5760a4 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/convert-int.c @@ -0,0 +1,199 @@ +/* { dg-options "-O0" } */ + +/* N1150 5.1 Conversion between decimal floating types and integer. + C99 6.3.1.4(1a) New. */ + +#include "dfp-dbg.h" + +#ifdef __cplusplus +#define BOOL bool +#else +#define BOOL _Bool +#endif + +_Decimal32 d32; +_Decimal64 d64; +_Decimal128 d128; +unsigned int ui; +unsigned long ul; +unsigned long long ull; +int si; +long sl; +long long sll; +BOOL b; + +void +init_dfp_1 (void) +{ + d32 = 456.789df; + d64 = 23.456789dd; + d128 = 1234.5678dl; +} +void +init_dfp_2 (void) +{ + d32 = 1.23df; + d64 = -3.4dd; + d128 = 0.00003dl; +} + +void +init_dfp_3 (void) +{ + d32 = 0.0DF; + d64 = 0.0DD; + d128 = 0.0DL; +} + +void +init_unsigned_int (void) +{ + ui = 987U; + ul = 345678UL; + ull = 1234567ULL; +} + +void +init_signed_int (void) +{ + si = -987; + sl = -345678; + sll = -1234567; +} + +int +main () +{ + /* C99 Section 6.7.2 Type specifiers. Type _Bool is + mentioned in this section. Conversions between + BOOL and DFP types. */ + + /* Decimal float to unsigned integer. */ + init_dfp_1 (); + + ui = d32; + if (ui != 456U) + FAILURE + ul = d32; + if (ul != 456UL) + FAILURE + ull = d32; + if (ull != 456ULL) + FAILURE + + ui = d64; + if (ui != 23U) + FAILURE + ul = d64; + if (ul != 23UL) + FAILURE + ull = d64; + if (ull != 23ULL) + FAILURE + + ui = d128; + if (ui != 1234U) + FAILURE + ul = d128; + if (ul != 1234UL) + FAILURE + ull = d128; + if (ull != 1234ULL) + FAILURE + + /* Decimal float to signed integer. */ + + /* Decimal float to BOOL. */ + init_dfp_2 (); + + b = d32; + if (!b) + FAILURE + b = d64; + if (!b) + FAILURE + b = d128; + if (!b) + FAILURE + + /* Unsigned integer to decimal float. */ + init_unsigned_int (); + + d32 = ui; + if (d32 != 987.0df) + FAILURE + d32 = ul; + if (d32 != 345678.0df) + FAILURE + d32 = ull; + if (d32 != 1234567.df) + FAILURE + + d64 = ui; + if (d64 != 987.0dd) + FAILURE + d64 = ul; + if (d64 != 345678.0dd) + FAILURE + d64 = ull; + if (d64 != 1234567.dd) + FAILURE + + d128 = ui; + if (d128 != 987.0dl) + FAILURE + d128 = ul; + if (d128 != 345678.0dl) + FAILURE + d128 = ull; + if (d128 != 1234567.dl) + FAILURE + + /* Signed integer to decimal float. */ + init_signed_int (); + + d32 = si; + if (d32 != -987.0df) + FAILURE + d32 = sl; + if (d32 != -345678.0df) + FAILURE + d32 = sll; + if (d32 != -1234567.df) + FAILURE + + d64 = si; + if (d64 != -987.0dd) + FAILURE + d64 = sl; + if (d64 != -345678.0dd) + FAILURE + d64 = sll; + if (d64 != -1234567.dd) + FAILURE + + d128 = si; + if (d128 != -987.0dl) + FAILURE + d128 = sl; + if (d128 != -345678.0dl) + FAILURE + d128 = sll; + if (d128 != -1234567.dl) + FAILURE + + /* BOOL to decimal float. */ + init_dfp_3 (); + + b = d32; + if (b) + FAILURE + b = d64; + if (b) + FAILURE + b = d128; + if (b) + FAILURE + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/convert.h b/gcc/testsuite/c-c++-common/dfp/convert.h new file mode 100644 index 00000000000..304164ff627 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/convert.h @@ -0,0 +1,462 @@ +#include "dfp-dbg.h" + +/* Macros are set up to skip using long double, which doesn't necessarily + map to TF mode. If there's a reason to skip those for a test, the + test itself can define USE_TF to be zero. */ +#ifndef USE_TF +#define USE_TF 1 +#endif + +/* Provide more information with FAILURE than what is available with + the version of that macro in dfp-dbg.h. */ + +#undef FAILURE +#if defined(DBG) || defined(DBG2) +#include +#define FAILURE(NUM) \ + { printf ("failed for test %s\n", NUM); failures++; } +#else +#define FAILURE(N) __builtin_abort (); +#endif + +/* This is useful when modifying the test to make sure that tests are + actually run. */ +#if defined(DBG2) +#define REPORT(NUM) \ + { printf ("%s\n", NUM); } +#else +#define REPORT(N) ; +#endif + +#define CONVERT_VALID(NUM,FROM,TO,FROMVAL,TOVAL,DIFF) \ +void \ +convert_##NUM (void) \ +{ \ + REPORT(#NUM " " #FROMVAL) \ + FROM = FROMVAL; \ + TO = FROM; \ + if (TO < (TOVAL - DIFF) || TO > (TOVAL + DIFF)) \ + FAILURE (#NUM); \ +} + +#define CONVERT_TO_PINF(NUM,FROM,TO,FROMVAL,TOSUFFIX) \ +void \ +convert_##NUM (void) \ +{ \ + REPORT(#NUM " " #FROMVAL) \ + FROM = FROMVAL; \ + TO = FROM; \ + if (__builtin_isinf##TOSUFFIX (TO) == 0) \ + FAILURE (#NUM " pinf: isinf"); \ + if (__builtin_signbit##TOSUFFIX (TO) != 0) \ + FAILURE (#NUM " pinf: sign"); \ +} + +#define CONVERT_TO_MINF(NUM,FROM,TO,FROMVAL,TOSUFFIX) \ +void \ +convert_##NUM (void) \ +{ \ + REPORT(#NUM " " #FROMVAL) \ + FROM = FROMVAL; \ + TO = FROM; \ + if (__builtin_isinf##TOSUFFIX (TO) == 0) \ + FAILURE (#NUM " pinf: isinf"); \ + if (__builtin_signbit##TOSUFFIX (TO) == 0) \ + FAILURE (#NUM " pinf: sign"); \ +} + +#define CONVERT_TO_PZERO(NUM,FROM,TO,FROMVAL,TOVAL,TOSUFFIX) \ +void \ +convert_##NUM (void) \ +{ \ + REPORT(#NUM " " #FROMVAL) \ + FROM = FROMVAL; \ + TO = FROM; \ + if (TO != TOVAL) \ + FAILURE (#NUM "_pzero: zero") \ + if (__builtin_signbit##TOSUFFIX (TO) != 0) \ + FAILURE (#NUM " _pzero: sign"); \ +} + +#define CONVERT_TO_MZERO(NUM,FROM,TO,FROMVAL,TOVAL,TOSUFFIX) \ +void \ +convert_##NUM (void) \ +{ \ + REPORT(#NUM " " #FROMVAL) \ + FROM = FROMVAL; \ + TO = FROM; \ + if (TO != TOVAL) \ + FAILURE (#NUM "_mzero: zero") \ + if (__builtin_signbit##TOSUFFIX (TO) == 0) \ + FAILURE (#NUM " _mzero: sign"); \ +} + +#define CONVERT_NAN(NUM,FROM,TO,FROMSUFFIX,TOSUFFIX) \ +void \ +convert_##NUM##_nan (void) \ +{ \ + REPORT(#NUM "_nan") \ + FROM = __builtin_nan##FROMSUFFIX (""); \ + TO = FROM; \ + if (__builtin_isnan##TOSUFFIX (TO) == 0) \ + FAILURE (#NUM " nan"); \ +} + +#define CONVERT_PINF(NUM,FROM,TO,FROMSUFFIX,TOSUFFIX) \ +void \ +convert_##NUM##_pinf (void) \ +{ \ + REPORT (#NUM "_pinf") \ + FROM = __builtin_inf##FROMSUFFIX (); \ + TO = FROM; \ + if (__builtin_isinf##TOSUFFIX (TO) == 0) \ + FAILURE (#NUM " pinf: isinf"); \ + if (__builtin_signbit##TOSUFFIX (TO) != 0) \ + FAILURE (#NUM " pinf: sign"); \ +} + +#define CONVERT_MINF(NUM,FROM,TO,FROMSUFFIX,TOSUFFIX) \ +void \ +convert_##NUM##_minf (void) \ +{ \ + REPORT (#NUM "_minf") \ + FROM = -__builtin_inf##FROMSUFFIX (); \ + TO = FROM; \ + if (__builtin_isinf##TOSUFFIX (TO) == 0) \ + FAILURE (#NUM " minf: isinf"); \ + if (__builtin_signbit##TOSUFFIX (TO) == 0) \ + FAILURE (#NUM " minf: sign"); \ +} + +#define CONVERT_PZERO(NUM,FROM,TO,FROMVALUE,TOVALUE,TOSUFFIX) \ +void \ +convert_##NUM##_pzero (void) \ +{ \ + REPORT (#NUM "_pzero") \ + FROM = FROMVALUE; \ + TO = FROM; \ + if (TO != TOVALUE) \ + FAILURE (#NUM "pzero: zero") \ + if (__builtin_signbit##TOSUFFIX (TO) != 0) \ + FAILURE (#NUM " pzero: sign"); \ +} + +#define CONVERT_MZERO(NUM,FROM,TO,FROMVALUE,TOVALUE,TOSUFFIX) \ +void \ +convert_##NUM##_mzero (void) \ +{ \ + REPORT (#NUM "_mzero") \ + FROM = FROMVALUE; \ + TO = FROM; \ + if (TO != TOVALUE) \ + FAILURE (#NUM "mzero: zero") \ + if (__builtin_signbit##TOSUFFIX (TO) == 0) \ + FAILURE (#NUM " mzero: sign"); \ +} + +#define CONVERT_VALID_NOTF(NUM,VAL,DIFF) \ +CONVERT_VALID (NUM##_sdsf, sd, sf, VAL##df, VAL##f, DIFF##f) \ +CONVERT_VALID (NUM##_sddf, sd, df, VAL##df, VAL, DIFF) \ +CONVERT_VALID (NUM##_ddsf, dd, sf, VAL##dd, VAL##f, DIFF##f) \ +CONVERT_VALID (NUM##_dddf, dd, df, VAL##dd, VAL, DIFF) \ +CONVERT_VALID (NUM##_tdsf, td, sf, VAL##dl, VAL##f, DIFF##f) \ +CONVERT_VALID (NUM##_tddf, td, df, VAL##dl, VAL, DIFF) \ +CONVERT_VALID (NUM##_sfsd, sf, sd, VAL##f, VAL##df, DIFF##df) \ +CONVERT_VALID (NUM##_sfdd, sf, dd, VAL##f, VAL##dd, DIFF##dd) \ +CONVERT_VALID (NUM##_sftd, sf, td, VAL##f, VAL##dl, DIFF##dl) \ +CONVERT_VALID (NUM##_dfsd, df, sd, VAL, VAL##df, DIFF##df) \ +CONVERT_VALID (NUM##_dfdd, df, dd, VAL, VAL##dd, DIFF##dd) \ +CONVERT_VALID (NUM##_dftd, df, td, VAL, VAL##dl, DIFF##dl) \ +CONVERT_VALID (NUM##_sddd, sd, dd, VAL##df, VAL##dd, DIFF##dd) \ +CONVERT_VALID (NUM##_sdtd, sd, dd, VAL##df, VAL##dd, DIFF##dd) \ +CONVERT_VALID (NUM##_ddsd, dd, sd, VAL##dd, VAL##df, DIFF##dd) \ +CONVERT_VALID (NUM##_ddtd, dd, td, VAL##dd, VAL##dl, DIFF##dl) \ +CONVERT_VALID (NUM##_tdsd, td, sd, VAL##dl, VAL##df, DIFF##df) \ +CONVERT_VALID (NUM##_tddd, td, dd, VAL##dl, VAL##dd, DIFF##dd) + +#if USE_TF == 0 +#define CONVERT_VALID_TF(NUM,VAL,DIFF) +#else +#define CONVERT_VALID_TF(NUM,VAL,DIFF) \ +CONVERT_VALID (NUM##_sdtf, sd, tf, VAL##df, VAL##l, DIFF##l) \ +CONVERT_VALID (NUM##_tdtf, td, tf, VAL##dl, VAL##l, DIFF##l) \ +CONVERT_VALID (NUM##_ddtf, dd, tf, VAL##dd, VAL##l, DIFF##l) \ +CONVERT_VALID (NUM##_tfsd, tf, sd, VAL##l, VAL##df, DIFF##df) \ +CONVERT_VALID (NUM##_tfdd, tf, dd, VAL##l, VAL##dd, DIFF##dd) \ +CONVERT_VALID (NUM##_tftd, tf, td, VAL##l, VAL##dl, DIFF##dl) +#endif + +#define CONVERT_VALID_ALL(NUM,VAL,DIFF) \ + CONVERT_VALID_NOTF(NUM,VAL,DIFF) \ + CONVERT_VALID_TF(NUM,VAL,DIFF) + +#define CALL_VALID_NOTF(NUM) \ + convert_##NUM##_sdsf (); \ + convert_##NUM##_sddf (); \ + convert_##NUM##_ddsf (); \ + convert_##NUM##_dddf (); \ + convert_##NUM##_tdsf (); \ + convert_##NUM##_tddf (); \ + convert_##NUM##_sfsd (); \ + convert_##NUM##_sfdd (); \ + convert_##NUM##_sftd (); \ + convert_##NUM##_dfsd (); \ + convert_##NUM##_dfdd (); \ + convert_##NUM##_dftd (); \ + convert_##NUM##_sddd (); \ + convert_##NUM##_sdtd (); \ + convert_##NUM##_ddsd (); \ + convert_##NUM##_ddtd (); \ + convert_##NUM##_tdsd (); \ + convert_##NUM##_tddd (); + +#if USE_TF == 0 +#define CALL_VALID_TF(NUM) +#else +#define CALL_VALID_TF(NUM) \ + convert_##NUM##_sdtf (); \ + convert_##NUM##_ddtf (); \ + convert_##NUM##_tdtf (); \ + convert_##NUM##_tfsd (); \ + convert_##NUM##_tfdd (); \ + convert_##NUM##_tftd (); +#endif + +#define CALL_VALID_ALL(NUM) \ + CALL_VALID_NOTF(NUM) \ + CALL_VALID_TF(NUM) + +#define CONVERT_ZEROES(NUM,FROM,TO,FROMVALUE,TOVALUE,TOSUFFIX) \ +CONVERT_PZERO(NUM, FROM, TO, FROMVALUE, TOVALUE, TOSUFFIX) \ +CONVERT_MZERO(NUM, FROM, TO, -FROMVALUE, -TOVALUE, TOSUFFIX) + +#define CONVERT_ZEROES_NOTF(NUM) \ +CONVERT_ZEROES (NUM##_sdsf, sd, sf, 0.0df, 0.0f, f) \ +CONVERT_ZEROES (NUM##_sddf, sd, df, 0.0df, 0.0, ) \ +CONVERT_ZEROES (NUM##_ddsf, dd, sf, 0.0dd, 0.0f, f) \ +CONVERT_ZEROES (NUM##_dddf, dd, df, 0.0dd, 0.0, ) \ +CONVERT_ZEROES (NUM##_tdsf, td, sf, 0.0dl, 0.0f, f) \ +CONVERT_ZEROES (NUM##_tddf, td, df, 0.0dl, 0.0, ) \ +CONVERT_ZEROES (NUM##_sfsd, sf, sd, 0.0f, 0.0df, d32) \ +CONVERT_ZEROES (NUM##_sfdd, sf, dd, 0.0f, 0.0dd, d64) \ +CONVERT_ZEROES (NUM##_sftd, sf, td, 0.0f, 0.0dl, d128) \ +CONVERT_ZEROES (NUM##_dfsd, df, sd, 0.0, 0.0df, d32) \ +CONVERT_ZEROES (NUM##_dfdd, df, dd, 0.0, 0.0dd, d64) \ +CONVERT_ZEROES (NUM##_dftd, df, td, 0.0, 0.0dl, d128) \ +CONVERT_ZEROES (NUM##_sddd, sd, dd, 0.0df, 0.0dd, d64) \ +CONVERT_ZEROES (NUM##_sdtd, sd, td, 0.0dl, 0.0dl, d128) \ +CONVERT_ZEROES (NUM##_ddsd, dd, sd, 0.0dd, 0.0df, d32) \ +CONVERT_ZEROES (NUM##_ddtd, dd, td, 0.0dd, 0.0dl, d128) \ +CONVERT_ZEROES (NUM##_tdsd, td, sd, 0.0dl, 0.0df, d32) \ +CONVERT_ZEROES (NUM##_tddd, td, dd, 0.0dl, 0.0dd, d64) + +#if USE_TF == 0 +#define CONVERT_ZEROES_TF(NUM) +#else +#define CONVERT_ZEROES_TF(NUM) \ +CONVERT_ZEROES (NUM##_sdtf, sd, tf, 0.0df, 0.0l, l) \ +CONVERT_ZEROES (NUM##_ddtf, dd, tf, 0.0dd, 0.0l, l) \ +CONVERT_ZEROES (NUM##_tdtf, td, tf, 0.0dl, 0.0l, l) \ +CONVERT_ZEROES (NUM##_tfsd, tf, sd, 0.0l, 0.0df, d32) \ +CONVERT_ZEROES (NUM##_tfdd, tf, dd, 0.0l, 0.0dd, d64) \ +CONVERT_ZEROES (NUM##_tftd, tf, td, 0.0l, 0.0dl, d128) +#endif + +#define CONVERT_ZEROES_ALL(NUM) \ + CONVERT_ZEROES_NOTF(NUM) \ + CONVERT_ZEROES_TF(NUM) + +#define CALL_ZEROES(NUM) \ + convert_##NUM##_pzero (); \ + convert_##NUM##_mzero (); + +#define CALL_ZEROES_NOTF(NUM) \ + CALL_ZEROES (NUM##_sdsf) \ + CALL_ZEROES (NUM##_sddf) \ + CALL_ZEROES (NUM##_ddsf) \ + CALL_ZEROES (NUM##_dddf) \ + CALL_ZEROES (NUM##_tdsf) \ + CALL_ZEROES (NUM##_tddf) \ + CALL_ZEROES (NUM##_sfsd) \ + CALL_ZEROES (NUM##_sfdd) \ + CALL_ZEROES (NUM##_sftd) \ + CALL_ZEROES (NUM##_dfsd) \ + CALL_ZEROES (NUM##_dfdd) \ + CALL_ZEROES (NUM##_dftd) \ + CALL_ZEROES (NUM##_sddd) \ + CALL_ZEROES (NUM##_sdtd) \ + CALL_ZEROES (NUM##_ddsd) \ + CALL_ZEROES (NUM##_ddtd) \ + CALL_ZEROES (NUM##_tdsd) \ + CALL_ZEROES (NUM##_tddd) + +#if USE_TF == 0 +#define CALL_ZEROES_TF(NUM) +#else +#define CALL_ZEROES_TF(NUM) \ + CALL_ZEROES (NUM##_sdtf) \ + CALL_ZEROES (NUM##_ddtf) \ + CALL_ZEROES (NUM##_tdtf) \ + CALL_ZEROES (NUM##_tfsd) \ + CALL_ZEROES (NUM##_tfdd) \ + CALL_ZEROES (NUM##_tftd) +#endif + +#define CALL_ZEROES_ALL(NUM) \ + CALL_ZEROES_NOTF(NUM) \ + CALL_ZEROES_TF(NUM) + +#define CONVERT_INF(NUM,FROM,TO,FROMSUFFIX,TOSUFFIX) \ +CONVERT_PINF (NUM, FROM, TO, FROMSUFFIX, TOSUFFIX) \ +CONVERT_MINF (NUM, FROM, TO, FROMSUFFIX, TOSUFFIX) + +#define CONVERT_INF_NOTF(NUM) \ +CONVERT_INF (NUM##_sdsf, sd, sf, d32, f) \ +CONVERT_INF (NUM##_sddf, sd, df, d32, ) \ +CONVERT_INF (NUM##_ddsf, dd, sf, d64, f) \ +CONVERT_INF (NUM##_dddf, dd, df, d64, ) \ +CONVERT_INF (NUM##_tdsf, td, sf, d128, f) \ +CONVERT_INF (NUM##_tddf, td, df, d128, ) \ +CONVERT_INF (NUM##_sfsd, sf, sd, f, d32) \ +CONVERT_INF (NUM##_sfdd, sf, dd, f, d64) \ +CONVERT_INF (NUM##_sftd, sf, td, f, d128) \ +CONVERT_INF (NUM##_dfsd, df, sd, , d32) \ +CONVERT_INF (NUM##_dfdd, df, dd, , d64) \ +CONVERT_INF (NUM##_dftd, df, td, , d128) \ +CONVERT_INF (NUM##_sddd, sd, dd, d32, d64) \ +CONVERT_INF (NUM##_sdtd, sd, td, d32, d128) \ +CONVERT_INF (NUM##_ddsd, dd, sd, d64, d32) \ +CONVERT_INF (NUM##_ddtd, dd, td, d64, d128) \ +CONVERT_INF (NUM##_tdsd, td, sd, d128, d32) \ +CONVERT_INF (NUM##_tddd, td, dd, d128, d64) + +#if USE_TF == 0 +#define CONVERT_INF_TF(NUM) +#else +#define CONVERT_INF_TF(NUM) \ +CONVERT_INF (NUM##_sdtf, sd, tf, d32, l) \ +CONVERT_INF (NUM##_ddtf, dd, tf, d64, l) \ +CONVERT_INF (NUM##_tdtf, td, tf, d128, l) \ +CONVERT_INF (NUM##_tfsd, tf, sd, l, d32) \ +CONVERT_INF (NUM##_tfdd, tf, dd, l, d64) \ +CONVERT_INF (NUM##_tftd, tf, td, l, d128) +#endif + +#define CONVERT_INF_ALL(NUM) \ + CONVERT_INF_NOTF(NUM) \ + CONVERT_INF_TF(NUM) + +#define CALL_INF(NUM) \ + convert_##NUM##_pinf (); \ + convert_##NUM##_minf (); + +#define CALL_INF_NOTF(NUM) \ + CALL_INF (NUM##_sdsf) \ + CALL_INF (NUM##_sddf) \ + CALL_INF (NUM##_ddsf) \ + CALL_INF (NUM##_dddf) \ + CALL_INF (NUM##_tdsf) \ + CALL_INF (NUM##_tddf) \ + CALL_INF (NUM##_sfsd) \ + CALL_INF (NUM##_sfdd) \ + CALL_INF (NUM##_sftd) \ + CALL_INF (NUM##_dfsd) \ + CALL_INF (NUM##_dfdd) \ + CALL_INF (NUM##_dftd) \ + CALL_INF (NUM##_sddd) \ + CALL_INF (NUM##_sdtd) \ + CALL_INF (NUM##_ddsd) \ + CALL_INF (NUM##_ddtd) \ + CALL_INF (NUM##_tdsd) \ + CALL_INF (NUM##_tddd) + +#if USE_TF == 0 +#define CALL_INF_TF(NUM) +#else +#define CALL_INF_TF(NUM) \ + CALL_INF (NUM##_sdtf) \ + CALL_INF (NUM##_ddtf) \ + CALL_INF (NUM##_tdtf) \ + CALL_INF (NUM##_tfsd) \ + CALL_INF (NUM##_tfdd) \ + CALL_INF (NUM##_tftd) +#endif + +#define CALL_INF_ALL(NUM) \ + CALL_INF_NOTF(NUM) \ + CALL_INF_TF(NUM) + +#define CONVERT_NAN_NOTF(NUM) \ +CONVERT_NAN (NUM##_sdsf, sd, sf, d32, f) \ +CONVERT_NAN (NUM##_sddf, sd, df, d32, ) \ +CONVERT_NAN (NUM##_ddsf, dd, sf, d64, f) \ +CONVERT_NAN (NUM##_dddf, dd, df, d64, ) \ +CONVERT_NAN (NUM##_tdsf, td, sf, d128, f) \ +CONVERT_NAN (NUM##_tddf, td, df, d128, ) \ +CONVERT_NAN (NUM##_sfsd, sf, sd, f, d32) \ +CONVERT_NAN (NUM##_sfdd, sf, dd, f, d64) \ +CONVERT_NAN (NUM##_sftd, sf, td, f, d128) \ +CONVERT_NAN (NUM##_dfsd, df, sd, , d32) \ +CONVERT_NAN (NUM##_dfdd, df, dd, , d64) \ +CONVERT_NAN (NUM##_dftd, df, td, , d128) \ +CONVERT_NAN (NUM##_sddd, sd, dd, d32, d64) \ +CONVERT_NAN (NUM##_sdtd, sd, td, d32, d128) \ +CONVERT_NAN (NUM##_ddsd, dd, sd, d64, d32) \ +CONVERT_NAN (NUM##_ddtd, dd, td, d64, d128) \ +CONVERT_NAN (NUM##_tdsd, td, sd, d128, d32) \ +CONVERT_NAN (NUM##_tddd, td, dd, d128, d64) + +#if USE_TF == 0 +#define CONVERT_NAN_TF(NUM) +#else +#define CONVERT_NAN_TF(NUM) \ +CONVERT_NAN (NUM##_sdtf, sd, tf, d32, l) \ +CONVERT_NAN (NUM##_ddtf, dd, tf, d64, l) \ +CONVERT_NAN (NUM##_tdtf, td, tf, d128, l) \ +CONVERT_NAN (NUM##_tfsd, tf, sd, l, d32) \ +CONVERT_NAN (NUM##_tfdd, tf, dd, l, d64) \ +CONVERT_NAN (NUM##_tftd, tf, td, l, d128) +#endif + +#define CONVERT_NAN_ALL(NUM) \ + CONVERT_NAN_NOTF(NUM) \ + CONVERT_NAN_TF(NUM) + +#define CALL_NAN(NUM) \ + convert_##NUM##_nan (); + +#define CALL_NAN_NOTF(NUM) \ + CALL_NAN (NUM##_sdsf) \ + CALL_NAN (NUM##_sddf) \ + CALL_NAN (NUM##_ddsf) \ + CALL_NAN (NUM##_dddf) \ + CALL_NAN (NUM##_tdsf) \ + CALL_NAN (NUM##_tddf) \ + CALL_NAN (NUM##_sfsd) \ + CALL_NAN (NUM##_sfdd) \ + CALL_NAN (NUM##_sftd) \ + CALL_NAN (NUM##_dfsd) \ + CALL_NAN (NUM##_dfdd) \ + CALL_NAN (NUM##_dftd) \ + CALL_NAN (NUM##_sddd) \ + CALL_NAN (NUM##_sdtd) \ + CALL_NAN (NUM##_ddsd) \ + CALL_NAN (NUM##_ddtd) \ + CALL_NAN (NUM##_tdsd) \ + CALL_NAN (NUM##_tddd) + +#if USE_TF == 0 +#define CALL_NAN_TF(NUM) +#else +#define CALL_NAN_TF(NUM) \ + CALL_NAN (NUM##_sdtf) \ + CALL_NAN (NUM##_ddtf) \ + CALL_NAN (NUM##_tdtf) \ + CALL_NAN (NUM##_tfsd) \ + CALL_NAN (NUM##_tfdd) \ + CALL_NAN (NUM##_tftd) +#endif + +#define CALL_NAN_ALL(NUM) \ + CALL_NAN_NOTF(NUM) \ + CALL_NAN_TF(NUM) diff --git a/gcc/testsuite/c-c++-common/dfp/dfp-dbg.h b/gcc/testsuite/c-c++-common/dfp/dfp-dbg.h new file mode 100644 index 00000000000..cde76c494ce --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/dfp-dbg.h @@ -0,0 +1,20 @@ +#ifdef __cplusplus +typedef float _Decimal32 __attribute__((mode(SD))); +typedef float _Decimal64 __attribute__((mode(DD))); +typedef float _Decimal128 __attribute__((mode(TD))); + +#define EXTERN extern "C" +#else +#define EXTERN extern +#endif + +int failures; + +#ifdef DBG +extern int printf (const char *, ...); +#define FAILURE { printf ("failed at line %d\n", __LINE__); failures++; } +#define FINISH if (failures != 0) __builtin_abort (); return 0; +#else +#define FAILURE __builtin_abort (); +#define FINISH return 0; +#endif diff --git a/gcc/testsuite/c-c++-common/dfp/func-array.c b/gcc/testsuite/c-c++-common/dfp/func-array.c new file mode 100644 index 00000000000..6d158f35523 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/func-array.c @@ -0,0 +1,157 @@ +/* C99 6.5.2.2 Function calls. + Test passing array elements involving decimal floating point types. */ + +#include "dfp-dbg.h" + +/* A handful of functions that return the Nth _Decimal32 argument of + an incoming array. */ + +_Decimal32 +arg0_32 (_Decimal32 args[]) +{ + return args[0]; +} + +_Decimal32 +arg1_32 (_Decimal32 args[]) +{ + return args[1]; +} + +_Decimal32 +arg2_32 (_Decimal32 args[]) +{ + return args[2]; +} + +_Decimal32 +arg3_32 (_Decimal32 args[]) +{ + return args[3]; +} + +_Decimal32 +arg4_32 (_Decimal32 args[]) +{ + return args[4]; +} + +_Decimal32 +arg5_32 (_Decimal32 args[]) +{ + return args[5]; +} + + +/* A handful of functions that return the Nth _Decimal64 argument of + an incoming array. */ + +_Decimal64 +arg0_64 (_Decimal64 args[]) +{ + return args[0]; +} + +_Decimal64 +arg1_64 (_Decimal64 args[]) +{ + return args[1]; +} + +_Decimal64 +arg2_64 (_Decimal64 args[]) +{ + return args[2]; +} + +_Decimal64 +arg3_64 (_Decimal64 args[]) +{ + return args[3]; +} + +_Decimal64 +arg4_64 (_Decimal64 args[]) +{ + return args[4]; +} + +_Decimal64 +arg5_64 (_Decimal64 args[]) +{ + return args[5]; +} + + +/* A handful of functions that return the Nth _Decimal128 argument of + an incoming array. */ + +_Decimal128 +arg0_128 (_Decimal128 args[]) +{ + return args[0]; +} + +_Decimal128 +arg1_128 (_Decimal128 args[]) +{ + return args[1]; +} + +_Decimal128 +arg2_128 (_Decimal128 args[]) +{ + return args[2]; +} + +_Decimal128 +arg3_128 (_Decimal128 args[]) +{ + return args[3]; +} + +_Decimal128 +arg4_128 (_Decimal128 args[]) +{ + return args[4]; +} + +_Decimal128 +arg5_128 (_Decimal128 args[]) +{ + return args[5]; +} + + +int main() +{ + _Decimal32 d32[] = { 0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df }; + _Decimal64 d64[] = { 0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd }; + _Decimal128 d128[] = { 0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl }; + + /* _Decimal32 variants. */ + if (arg0_32 (d32) != 0.0df) FAILURE + if (arg1_32 (d32) != 1.0df) FAILURE + if (arg2_32 (d32) != 2.0df) FAILURE + if (arg3_32 (d32) != 3.0df) FAILURE + if (arg4_32 (d32) != 4.0df) FAILURE + if (arg5_32 (d32) != 5.0df) FAILURE + + /* _Decimal64 variants. */ + if (arg0_64 (d64) != 0.0dd) FAILURE + if (arg1_64 (d64) != 1.0dd) FAILURE + if (arg2_64 (d64) != 2.0dd) FAILURE + if (arg3_64 (d64) != 3.0dd) FAILURE + if (arg4_64 (d64) != 4.0dd) FAILURE + if (arg5_64 (d64) != 5.0dd) FAILURE + + /* _Decimal128 variants. */ + if (arg0_128 (d128) != 0.0dl) FAILURE + if (arg1_128 (d128) != 1.0dl) FAILURE + if (arg2_128 (d128) != 2.0dl) FAILURE + if (arg3_128 (d128) != 3.0dl) FAILURE + if (arg4_128 (d128) != 4.0dl) FAILURE + if (arg5_128 (d128) != 5.0dl) FAILURE + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/func-deref.c b/gcc/testsuite/c-c++-common/dfp/func-deref.c new file mode 100644 index 00000000000..81a48a9f8e8 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/func-deref.c @@ -0,0 +1,205 @@ +/* C99 6.5.2.2 Function calls. + Test scalar passing and return values involving decimal floating + point types and dereferenced pointers. */ + +#include "dfp-dbg.h" + +/* A handful of functions that return their Nth _Decimal32 + argument. */ + +_Decimal32 __attribute__((noinline)) +arg0_32 (_Decimal32 arg0, _Decimal32 arg1, _Decimal32 arg2, + _Decimal32 arg3, _Decimal32 arg4, _Decimal32 arg5) +{ + return arg0; +} + +_Decimal32 __attribute__((noinline)) +arg1_32 (_Decimal32 arg0, _Decimal32 arg1, _Decimal32 arg2, + _Decimal32 arg3, _Decimal32 arg4, _Decimal32 arg5) +{ + return arg1; +} + +_Decimal32 __attribute__((noinline)) +arg2_32 (_Decimal32 arg0, _Decimal32 arg1, _Decimal32 arg2, + _Decimal32 arg3, _Decimal32 arg4, _Decimal32 arg5) +{ + return arg2; +} + +_Decimal32 __attribute__((noinline)) +arg3_32 (_Decimal32 arg0, _Decimal32 arg1, _Decimal32 arg2, + _Decimal32 arg3, _Decimal32 arg4, _Decimal32 arg5) +{ + return arg3; +} + +_Decimal32 __attribute__((noinline)) +arg4_32 (_Decimal32 arg0, _Decimal32 arg1, _Decimal32 arg2, + _Decimal32 arg3, _Decimal32 arg4, _Decimal32 arg5) +{ + return arg4; +} + +_Decimal32 __attribute__((noinline)) +arg5_32 (_Decimal32 arg0, _Decimal32 arg1, _Decimal32 arg2, + _Decimal32 arg3, _Decimal32 arg4, _Decimal32 arg5) +{ + return arg5; +} + + +/* A handful of functions that return their Nth _Decimal64 + argument. */ + +_Decimal64 __attribute__((noinline)) +arg0_64 (_Decimal64 arg0, _Decimal64 arg1, _Decimal64 arg2, + _Decimal64 arg3, _Decimal64 arg4, _Decimal64 arg5) +{ + return arg0; +} + +_Decimal64 __attribute__((noinline)) +arg1_64 (_Decimal64 arg0, _Decimal64 arg1, _Decimal64 arg2, + _Decimal64 arg3, _Decimal64 arg4, _Decimal64 arg5) +{ + return arg1; +} + +_Decimal64 __attribute__((noinline)) +arg2_64 (_Decimal64 arg0, _Decimal64 arg1, _Decimal64 arg2, + _Decimal64 arg3, _Decimal64 arg4, _Decimal64 arg5) +{ + return arg2; +} + +_Decimal64 __attribute__((noinline)) +arg3_64 (_Decimal64 arg0, _Decimal64 arg1, _Decimal64 arg2, + _Decimal64 arg3, _Decimal64 arg4, _Decimal64 arg5) +{ + return arg3; +} + +_Decimal64 __attribute__((noinline)) +arg4_64 (_Decimal64 arg0, _Decimal64 arg1, _Decimal64 arg2, + _Decimal64 arg3, _Decimal64 arg4, _Decimal64 arg5) +{ + return arg4; +} + +_Decimal64 __attribute__((noinline)) +arg5_64 (_Decimal64 arg0, _Decimal64 arg1, _Decimal64 arg2, + _Decimal64 arg3, _Decimal64 arg4, _Decimal64 arg5) +{ + return arg5; +} + + +/* A handful of functions that return their Nth _Decimal128 + argument. */ + +_Decimal128 __attribute__((noinline)) +arg0_128 (_Decimal128 arg0, _Decimal128 arg1, _Decimal128 arg2, + _Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5) +{ + return arg0; +} + +_Decimal128 __attribute__((noinline)) +arg1_128 (_Decimal128 arg0, _Decimal128 arg1, _Decimal128 arg2, + _Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5) +{ + return arg1; +} + +_Decimal128 __attribute__((noinline)) +arg2_128 (_Decimal128 arg0, _Decimal128 arg1, _Decimal128 arg2, + _Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5) +{ + return arg2; +} + +_Decimal128 __attribute__((noinline)) +arg3_128 (_Decimal128 arg0, _Decimal128 arg1, _Decimal128 arg2, + _Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5) +{ + return arg3; +} + +_Decimal128 __attribute__((noinline)) +arg4_128 (_Decimal128 arg0, _Decimal128 arg1, _Decimal128 arg2, + _Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5) +{ + return arg4; +} + +_Decimal128 __attribute__((noinline)) +arg5_128 (_Decimal128 arg0, _Decimal128 arg1, _Decimal128 arg2, + _Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5) +{ + return arg5; +} + + + +_Decimal32 df0 = 0.0df, df1 = 1.0df, df2 = 2.0df, + df3 = 3.0df, df4 = 4.0df, df5 = 5.0df; +_Decimal32 *pdf0 = &df0, *pdf1 = &df1, *pdf2 = &df2, + *pdf3 = &df3, *pdf4 = &df4, *pdf5 = &df5; +_Decimal64 dd0 = 0.0dd, dd1 = 1.0dd, dd2 = 2.0dd, + dd3 = 3.0dd, dd4 = 4.0dd, dd5 = 5.0dd; +_Decimal64 *pdd0 = &dd0, *pdd1 = &dd1, *pdd2 = &dd2, + *pdd3 = &dd3, *pdd4 = &dd4, *pdd5 = &dd5; +_Decimal128 dl0 = 0.0dl, dl1 = 1.0dl, dl2 = 2.0dl, + dl3 = 3.0dl, dl4 = 4.0dl, dl5 = 5.0dl; +_Decimal128 *pdl0 = &dl0, *pdl1 = &dl1, *pdl2 = &dl2, + *pdl3 = &dl3, *pdl4 = &dl4, *pdl5 = &dl5; + +int +main () +{ + /* _Decimal32 variants. */ + if (arg0_32 (*pdf0, *pdf1, *pdf2, *pdf3, *pdf4, *pdf5) != 0.0df) + FAILURE + if (arg1_32 (*pdf0, *pdf1, *pdf2, *pdf3, *pdf4, *pdf5) != 1.0df) + FAILURE + if (arg2_32 (*pdf0, *pdf1, *pdf2, *pdf3, *pdf4, *pdf5) != 2.0df) + FAILURE + if (arg3_32 (*pdf0, *pdf1, *pdf2, *pdf3, *pdf4, *pdf5) != 3.0df) + FAILURE + if (arg4_32 (*pdf0, *pdf1, *pdf2, *pdf3, *pdf4, *pdf5) != 4.0df) + FAILURE + if (arg5_32 (*pdf0, *pdf1, *pdf2, *pdf3, *pdf4, *pdf5) != 5.0df) + FAILURE + + /* _Decimal64 variants. */ + if (arg0_64 (*pdd0, *pdd1, *pdd2, *pdd3, *pdd4, *pdd5) != 0.0dd) + FAILURE + if (arg1_64 (*pdd0, *pdd1, *pdd2, *pdd3, *pdd4, *pdd5) != 1.0dd) + FAILURE + if (arg2_64 (*pdd0, *pdd1, *pdd2, *pdd3, *pdd4, *pdd5) != 2.0dd) + FAILURE + if (arg3_64 (*pdd0, *pdd1, *pdd2, *pdd3, *pdd4, *pdd5) != 3.0dd) + FAILURE + if (arg4_64 (*pdd0, *pdd1, *pdd2, *pdd3, *pdd4, *pdd5) != 4.0dd) + FAILURE + if (arg5_64 (*pdd0, *pdd1, *pdd2, *pdd3, *pdd4, *pdd5) != 5.0dd) + FAILURE + + /* _Decimal128 variants. */ + if (arg0_128 (*pdl0, *pdl1, *pdl2, *pdl3, *pdl4, *pdl5) != 0.0dl) + FAILURE + if (arg1_128 (*pdl0, *pdl1, *pdl2, *pdl3, *pdl4, *pdl5) != 1.0dl) + FAILURE + if (arg2_128 (*pdl0, *pdl1, *pdl2, *pdl3, *pdl4, *pdl5) != 2.0dl) + FAILURE + if (arg3_128 (*pdl0, *pdl1, *pdl2, *pdl3, *pdl4, *pdl5) != 3.0dl) + FAILURE + if (arg4_128 (*pdl0, *pdl1, *pdl2, *pdl3, *pdl4, *pdl5) != 4.0dl) + FAILURE + if (arg5_128 (*pdl0, *pdl1, *pdl2, *pdl3, *pdl4, *pdl5) != 5.0dl) + FAILURE + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/func-mixed.c b/gcc/testsuite/c-c++-common/dfp/func-mixed.c new file mode 100644 index 00000000000..6f7e2eb4157 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/func-mixed.c @@ -0,0 +1,174 @@ +/* { dg-options "-Wall" } */ + +/* C99 6.5.2.2 Function calls. + Test scalar passing and return values involving decimal floating + point types. */ + +#include "dfp-dbg.h" + +/* A handful of functions that return their Nth _Decimal32 + argument with mixed types in parameter list. */ + +_Decimal32 +arg0_32 (_Decimal32 arg0, int arg1, unsigned int arg2, + float arg3, double arg4, long double arg5) +{ + return arg0; +} + +_Decimal32 +arg1_32 (int arg0, _Decimal32 arg1, unsigned int arg2, + float arg3, double arg4, long double arg5) +{ + return arg1; +} + +_Decimal32 +arg2_32 (int arg0, unsigned int arg1, _Decimal32 arg2, + float arg3, double arg4, long double arg5) +{ + return arg2; +} + + +_Decimal32 +arg3_32 (int arg0, unsigned int arg1, float arg2, + _Decimal32 arg3, double arg4, long double arg5) +{ + return arg3; +} + +_Decimal32 +arg4_32 (int arg0, unsigned int arg1, float arg2, + double arg3, _Decimal32 arg4, long double arg5) +{ + return arg4; +} + +_Decimal32 +arg5_32 (int arg0, unsigned int arg1, float arg2, + double arg3, long double arg4, _Decimal32 arg5) +{ + return arg5; +} + +/* A handful of functions that return their Nth _Decimal64 + argument with mixed types in parameter list. */ + +_Decimal64 +arg0_64 (_Decimal64 arg0, int arg1, unsigned int arg2, + float arg3, double arg4, long double arg5) +{ + return arg0; +} + +_Decimal64 +arg1_64 (int arg0, _Decimal64 arg1, unsigned int arg2, + float arg3, double arg4, long double arg5) +{ + return arg1; +} + +_Decimal64 +arg2_64 (int arg0, unsigned int arg1, _Decimal64 arg2, + float arg3, double arg4, long double arg5) +{ + return arg2; +} + +_Decimal64 +arg3_64 (int arg0, unsigned int arg1, float arg2, + _Decimal64 arg3, double arg4, long double arg5) +{ + return arg3; +} + +_Decimal64 +arg4_64 (int arg0, unsigned int arg1, float arg2, + float arg3, _Decimal64 arg4, long double arg5) +{ + return arg4; +} + +_Decimal64 +arg5_64 (int arg0, unsigned int arg1, float arg2, + double arg3, long double arg4, _Decimal64 arg5) +{ + return arg5; +} + +/* A handful of functions that return their Nth _Decimal128 + argument with mixed types in parameter list. */ + +_Decimal128 +arg0_128 (_Decimal128 arg0, int arg1, unsigned int arg2, + float arg3, double arg4, long double arg5) +{ + return arg0; +} +_Decimal128 +arg1_128 (int arg0, _Decimal128 arg1, unsigned int arg2, + float arg3, double arg4, long double arg5) +{ + return arg1; +} + +_Decimal128 +arg2_128 (int arg0, unsigned int arg1, _Decimal128 arg2, + float arg3, double arg4, long double arg5) +{ + return arg2; +} + +_Decimal128 +arg3_128 (int arg0, unsigned int arg1, float arg2, + _Decimal128 arg3, double arg4, long double arg5) +{ + return arg3; +} + +_Decimal128 +arg4_128 (int arg0, unsigned int arg1, float arg2, + float arg3, _Decimal32 arg4, long double arg5) +{ + return arg4; +} + +_Decimal128 +arg5_128 (int arg0, unsigned int arg1, float arg2, + double arg3, long double arg4, _Decimal128 arg5) +{ + return arg5; +} + + + +int +main () +{ + /* _Decimal32 variants. */ + if (arg0_32 (0.0df, -1, 2, 3.0f, 4.0, 5.0l) != 0.0df) FAILURE + if (arg1_32 (0, 1.0df, 2, 3.0f, 4.0, 5.0l) != 1.0df) FAILURE + if (arg2_32 (0, -1, 2.0df, 3.0f, 4.0, 5.0l) != 2.0df) FAILURE + if (arg3_32 (0, -1, 2.0f, 3.0df, 4.0, 5.0l) != 3.0df) FAILURE + if (arg4_32 (0, -1, 2.0f, 3.0, 4.0df, 5.0l) != 4.0df) FAILURE + if (arg5_32 (0, -1, 2.0f, 3.0, 4.0l, 5.0df) != 5.0df) FAILURE + + /* _Decimal64 variants. */ + if (arg0_64 (0.0dd, -1, 2, 3.0f, 4.0, 5.0l) != 0.0dd) FAILURE + if (arg1_64 (0, 1.0dd, 2, 3.0f, 4.0, 5.0l) != 1.0dd) FAILURE + if (arg2_64 (0, -1, 2.0dd, 3.0f, 4.0, 5.0l) != 2.0dd) FAILURE + if (arg3_64 (0, -1, 2.0f, 3.0dd, 4.0, 5.0l) != 3.0dd) FAILURE + if (arg4_64 (0, -1, 2.0f, 3.0, 4.0dd, 5.0l) != 4.0dd) FAILURE + if (arg5_64 (0, -1, 2.0f, 3.0, 4.0l, 5.0dd) != 5.0dd) FAILURE + + /* _Decimal128 variants. */ + if (arg0_128 (0.0dl, -1, 2, 3.0f, 4.0, 5.0l) != 0.0dl) FAILURE + if (arg1_128 (0, 1.0dl, 2, 3.0f, 4.0, 5.0l) != 1.0dl) FAILURE + if (arg2_128 (0, -1, 2.0dl, 3.0f, 4.0, 5.0l) != 2.0dl) FAILURE + if (arg3_128 (0, -1, 2.0f, 3.0dl, 4.0, 5.0l) != 3.0dl) FAILURE + if (arg4_128 (0, -1, 2.0f, 3.0, 4.0dl, 5.0l) != 4.0dl) FAILURE + if (arg5_128 (0, -1, 2.0f, 3.0, 4.0l, 5.0dl) != 5.0dl) FAILURE + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/func-pointer.c b/gcc/testsuite/c-c++-common/dfp/func-pointer.c new file mode 100644 index 00000000000..cfdf2356c9d --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/func-pointer.c @@ -0,0 +1,205 @@ +/* C99 6.5.2.2 Function calls. + Test pointer argument passing and return values involving decimal floating + point types. */ + +#include "dfp-dbg.h" + +/* A handful of functions that return their Nth pointer to Decimal32 + argument. */ + +_Decimal32 * +arg0_32 (_Decimal32 *arg0, _Decimal32 *arg1, _Decimal32 *arg2, + _Decimal32 *arg3, _Decimal32 *arg4, _Decimal32 *arg5) +{ + return arg0; +} + +_Decimal32 * +arg1_32 (_Decimal32 *arg0, _Decimal32 *arg1, _Decimal32 *arg2, + _Decimal32 *arg3, _Decimal32 *arg4, _Decimal32 *arg5) +{ + return arg1; +} + +_Decimal32 * +arg2_32 (_Decimal32 *arg0, _Decimal32 *arg1, _Decimal32 *arg2, + _Decimal32 *arg3, _Decimal32 *arg4, _Decimal32 *arg5) +{ + return arg2; +} + +_Decimal32 * +arg3_32 (_Decimal32 *arg0, _Decimal32 *arg1, _Decimal32 *arg2, + _Decimal32 *arg3, _Decimal32 *arg4, _Decimal32 *arg5) +{ + return arg3; +} + +_Decimal32 * +arg4_32 (_Decimal32 *arg0, _Decimal32 *arg1, _Decimal32 *arg2, + _Decimal32 *arg3, _Decimal32 *arg4, _Decimal32 *arg5) +{ + return arg4; +} + +_Decimal32 * +arg5_32 (_Decimal32 *arg0, _Decimal32 *arg1, _Decimal32 *arg2, + _Decimal32 *arg3, _Decimal32 *arg4, _Decimal32 *arg5) +{ + return arg5; +} + + +/* A handful of functions that return their Nth pointer to _Decimal64 + argument. */ + +_Decimal64 * +arg0_64 (_Decimal64 *arg0, _Decimal64 *arg1, _Decimal64 *arg2, + _Decimal64 *arg3, _Decimal64 *arg4, _Decimal64 *arg5) +{ + return arg0; +} + +_Decimal64 * +arg1_64 (_Decimal64 *arg0, _Decimal64 *arg1, _Decimal64 *arg2, + _Decimal64 *arg3, _Decimal64 *arg4, _Decimal64 *arg5) +{ + return arg1; +} + +_Decimal64 * +arg2_64 (_Decimal64 *arg0, _Decimal64 *arg1, _Decimal64 *arg2, + _Decimal64 *arg3, _Decimal64 *arg4, _Decimal64 *arg5) +{ + return arg2; +} + +_Decimal64 * +arg3_64 (_Decimal64 *arg0, _Decimal64 *arg1, _Decimal64 *arg2, + _Decimal64 *arg3, _Decimal64 *arg4, _Decimal64 *arg5) +{ + return arg3; +} + +_Decimal64 * +arg4_64 (_Decimal64 *arg0, _Decimal64 *arg1, _Decimal64 *arg2, + _Decimal64 *arg3, _Decimal64 *arg4, _Decimal64 *arg5) +{ + return arg4; +} + +_Decimal64 * +arg5_64 (_Decimal64 *arg0, _Decimal64 *arg1, _Decimal64 *arg2, + _Decimal64 *arg3, _Decimal64 *arg4, _Decimal64 *arg5) +{ + return arg5; +} + + +/* A handful of functions that return their Nth _Decimal128 + argument. */ + +_Decimal128 * +arg0_128 (_Decimal128 *arg0, _Decimal128 *arg1, _Decimal128 *arg2, + _Decimal128 *arg3, _Decimal128 *arg4, _Decimal128 *arg5) +{ + return arg0; +} + +_Decimal128 * +arg1_128 (_Decimal128 *arg0, _Decimal128 *arg1, _Decimal128 *arg2, + _Decimal128 *arg3, _Decimal128 *arg4, _Decimal128 *arg5) +{ + return arg1; +} + +_Decimal128 * +arg2_128 (_Decimal128 *arg0, _Decimal128 *arg1, _Decimal128 *arg2, + _Decimal128 *arg3, _Decimal128 *arg4, _Decimal128 *arg5) +{ + return arg2; +} + +_Decimal128 * +arg3_128 (_Decimal128 *arg0, _Decimal128 *arg1, _Decimal128 *arg2, + _Decimal128 *arg3, _Decimal128 *arg4, _Decimal128 *arg5) +{ + return arg3; +} + +_Decimal128 * +arg4_128 (_Decimal128 *arg0, _Decimal128 *arg1, _Decimal128 *arg2, + _Decimal128 *arg3, _Decimal128 *arg4, _Decimal128 *arg5) +{ + return arg4; +} + +_Decimal128 * +arg5_128 (_Decimal128 *arg0, _Decimal128 *arg1, _Decimal128 *arg2, + _Decimal128 *arg3, _Decimal128 *arg4, _Decimal128 *arg5) +{ + return arg5; +} + + + +_Decimal32 df0 = 0.0df, df1 = 1.0df, df2 = 2.0df, + df3 = 3.0df, df4 = 4.0df, df5 = 5.0df; +_Decimal32 *pdf0 = &df0, *pdf1 = &df1, *pdf2 = &df2, + *pdf3 = &df3, *pdf4 = &df4, *pdf5 = &df5; +_Decimal64 dd0 = 0.0dd, dd1 = 1.0dd, dd2 = 2.0dd, + dd3 = 3.0dd, dd4 = 4.0dd, dd5 = 5.0dd; +_Decimal64 *pdd0 = &dd0, *pdd1 = &dd1, *pdd2 = &dd2, + *pdd3 = &dd3, *pdd4 = &dd4, *pdd5 = &dd5; +_Decimal128 dl0 = 0.0dl, dl1 = 1.0dl, dl2 = 2.0dl, + dl3 = 3.0dl, dl4 = 4.0dl, dl5 = 5.0dl; +_Decimal128 *pdl0 = &dl0, *pdl1 = &dl1, *pdl2 = &dl2, + *pdl3 = &dl3, *pdl4 = &dl4, *pdl5 = &dl5; + +int +main () +{ + /* _Decimal32 variants. */ + if (*arg0_32 (pdf0, pdf1, pdf2, pdf3, pdf4, pdf5) != 0.0df) + FAILURE + if (*arg1_32 (pdf0, pdf1, pdf2, pdf3, pdf4, pdf5) != 1.0df) + FAILURE + if (*arg2_32 (pdf0, pdf1, pdf2, pdf3, pdf4, pdf5) != 2.0df) + FAILURE + if (*arg3_32 (pdf0, pdf1, pdf2, pdf3, pdf4, pdf5) != 3.0df) + FAILURE + if (*arg4_32 (pdf0, pdf1, pdf2, pdf3, pdf4, pdf5) != 4.0df) + FAILURE + if (*arg5_32 (pdf0, pdf1, pdf2, pdf3, pdf4, pdf5) != 5.0df) + FAILURE + + /* _Decimal64 variants. */ + if (*arg0_64 (pdd0, pdd1, pdd2, pdd3, pdd4, pdd5) != 0.0dd) + FAILURE + if (*arg1_64 (pdd0, pdd1, pdd2, pdd3, pdd4, pdd5) != 1.0dd) + FAILURE + if (*arg2_64 (pdd0, pdd1, pdd2, pdd3, pdd4, pdd5) != 2.0dd) + FAILURE + if (*arg3_64 (pdd0, pdd1, pdd2, pdd3, pdd4, pdd5) != 3.0dd) + FAILURE + if (*arg4_64 (pdd0, pdd1, pdd2, pdd3, pdd4, pdd5) != 4.0dd) + FAILURE + if (*arg5_64 (pdd0, pdd1, pdd2, pdd3, pdd4, pdd5) != 5.0dd) + FAILURE + + /* _Decimal128 variants. */ + if (*arg0_128 (pdl0, pdl1, pdl2, pdl3, pdl4, pdl5) != 0.0dl) + FAILURE + if (*arg1_128 (pdl0, pdl1, pdl2, pdl3, pdl4, pdl5) != 1.0dl) + FAILURE + if (*arg2_128 (pdl0, pdl1, pdl2, pdl3, pdl4, pdl5) != 2.0dl) + FAILURE + if (*arg3_128 (pdl0, pdl1, pdl2, pdl3, pdl4, pdl5) != 3.0dl) + FAILURE + if (*arg4_128 (pdl0, pdl1, pdl2, pdl3, pdl4, pdl5) != 4.0dl) + FAILURE + if (*arg5_128 (pdl0, pdl1, pdl2, pdl3, pdl4, pdl5) != 5.0dl) + FAILURE + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/func-scalar.c b/gcc/testsuite/c-c++-common/dfp/func-scalar.c new file mode 100644 index 00000000000..370c21b20e2 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/func-scalar.c @@ -0,0 +1,192 @@ +/* C99 6.5.2.2 Function calls. + Test scalar passing and return values involving decimal floating + point types. */ + +#include "dfp-dbg.h" + +/* A handful of functions that return their Nth _Decimal32 + argument. */ + +_Decimal32 +arg0_32 (_Decimal32 arg0, _Decimal32 arg1, _Decimal32 arg2, + _Decimal32 arg3, _Decimal32 arg4, _Decimal32 arg5) +{ + return arg0; +} + +_Decimal32 +arg1_32 (_Decimal32 arg0, _Decimal32 arg1, _Decimal32 arg2, + _Decimal32 arg3, _Decimal32 arg4, _Decimal32 arg5) +{ + return arg1; +} + +_Decimal32 +arg2_32 (_Decimal32 arg0, _Decimal32 arg1, _Decimal32 arg2, + _Decimal32 arg3, _Decimal32 arg4, _Decimal32 arg5) +{ + return arg2; +} + +_Decimal32 +arg3_32 (_Decimal32 arg0, _Decimal32 arg1, _Decimal32 arg2, + _Decimal32 arg3, _Decimal32 arg4, _Decimal32 arg5) +{ + return arg3; +} + +_Decimal32 +arg4_32 (_Decimal32 arg0, _Decimal32 arg1, _Decimal32 arg2, + _Decimal32 arg3, _Decimal32 arg4, _Decimal32 arg5) +{ + return arg4; +} + +_Decimal32 +arg5_32 (_Decimal32 arg0, _Decimal32 arg1, _Decimal32 arg2, + _Decimal32 arg3, _Decimal32 arg4, _Decimal32 arg5) +{ + return arg5; +} + + +/* A handful of functions that return their Nth _Decimal64 + argument. */ + +_Decimal64 +arg0_64 (_Decimal64 arg0, _Decimal64 arg1, _Decimal64 arg2, + _Decimal64 arg3, _Decimal64 arg4, _Decimal64 arg5) +{ + return arg0; +} + +_Decimal64 +arg1_64 (_Decimal64 arg0, _Decimal64 arg1, _Decimal64 arg2, + _Decimal64 arg3, _Decimal64 arg4, _Decimal64 arg5) +{ + return arg1; +} + +_Decimal64 +arg2_64 (_Decimal64 arg0, _Decimal64 arg1, _Decimal64 arg2, + _Decimal64 arg3, _Decimal64 arg4, _Decimal64 arg5) +{ + return arg2; +} + +_Decimal64 +arg3_64 (_Decimal64 arg0, _Decimal64 arg1, _Decimal64 arg2, + _Decimal64 arg3, _Decimal64 arg4, _Decimal64 arg5) +{ + return arg3; +} + +_Decimal64 +arg4_64 (_Decimal64 arg0, _Decimal64 arg1, _Decimal64 arg2, + _Decimal64 arg3, _Decimal64 arg4, _Decimal64 arg5) +{ + return arg4; +} + +_Decimal64 +arg5_64 (_Decimal64 arg0, _Decimal64 arg1, _Decimal64 arg2, + _Decimal64 arg3, _Decimal64 arg4, _Decimal64 arg5) +{ + return arg5; +} + + +/* A handful of functions that return their Nth _Decimal128 + argument. */ + +_Decimal128 +arg0_128 (_Decimal128 arg0, _Decimal128 arg1, _Decimal128 arg2, + _Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5) +{ + return arg0; +} + +_Decimal128 +arg1_128 (_Decimal128 arg0, _Decimal128 arg1, _Decimal128 arg2, + _Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5) +{ + return arg1; +} + +_Decimal128 +arg2_128 (_Decimal128 arg0, _Decimal128 arg1, _Decimal128 arg2, + _Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5) +{ + return arg2; +} + +_Decimal128 +arg3_128 (_Decimal128 arg0, _Decimal128 arg1, _Decimal128 arg2, + _Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5) +{ + return arg3; +} + +_Decimal128 +arg4_128 (_Decimal128 arg0, _Decimal128 arg1, _Decimal128 arg2, + _Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5) +{ + return arg4; +} + +_Decimal128 +arg5_128 (_Decimal128 arg0, _Decimal128 arg1, _Decimal128 arg2, + _Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5) +{ + return arg5; +} + + + +int +main () +{ + /* _Decimal32 variants. */ + if (arg0_32 (0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 0.0df) + FAILURE + if (arg1_32 (0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 1.0df) + FAILURE + if (arg2_32 (0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 2.0df) + FAILURE + if (arg3_32 (0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 3.0df) + FAILURE + if (arg4_32 (0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 4.0df) + FAILURE + if (arg5_32 (0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 5.0df) + FAILURE + + /* _Decimal64 variants. */ + if (arg0_64 (0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 0.0dd) + FAILURE + if (arg1_64 (0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 1.0dd) + FAILURE + if (arg2_64 (0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 2.0dd) + FAILURE + if (arg3_64 (0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 3.0dd) + FAILURE + if (arg4_64 (0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 4.0dd) + FAILURE + if (arg5_64 (0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 5.0dd) + FAILURE + + /* _Decimal128 variants. */ + if (arg0_128 (0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 0.0dl) + FAILURE + if (arg1_128 (0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 1.0dl) + FAILURE + if (arg2_128 (0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 2.0dl) + FAILURE + if (arg3_128 (0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 3.0dl) + FAILURE + if (arg4_128 (0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 4.0dl) + FAILURE + if (arg5_128 (0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 5.0dl) + FAILURE + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/func-struct.c b/gcc/testsuite/c-c++-common/dfp/func-struct.c new file mode 100644 index 00000000000..ad0224d6cad --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/func-struct.c @@ -0,0 +1,93 @@ +/* C99 6.5.2.2 Function calls. + Test structure passing and return values involving decimal floating + point types. */ + +#include "dfp-dbg.h" + +struct example +{ + _Decimal128 d128; + char dummy1; + _Decimal64 d64; + char dummy2; + _Decimal32 d32; +} nums = { 1.0dl, 'a', 2.0dd, 'b', 3.0df }; + +_Decimal32 +d32_field (struct example s) +{ + return s.d32; +} + +_Decimal64 +d64_field (struct example s) +{ + return s.d64; +} + +_Decimal128 +d128_field (struct example s) +{ + return s.d128; +} + +char +dummy1_field (struct example s) +{ + return s.dummy1; +} + +char +dummy2_field (struct example s) +{ + return s.dummy2; +} + +_Decimal32 +ptr_d32_field (struct example *s) +{ + return s->d32; +} + +_Decimal64 +ptr_d64_field (struct example *s) +{ + return s->d64; +} + +_Decimal128 +ptr_d128_field (struct example *s) +{ + return s->d128; +} + +char +ptr_dummy1_field (struct example *s) +{ + return s->dummy1; +} + +char +ptr_dummy2_field (struct example *s) +{ + return s->dummy2; +} + + +int +main () +{ + if (d32_field (nums) != 3.0df) FAILURE + if (d64_field (nums) != 2.0dd) FAILURE + if (d128_field (nums) != 1.0dl) FAILURE + if (dummy1_field (nums) != 'a') FAILURE + if (dummy2_field (nums) != 'b') FAILURE + + if (ptr_d32_field (&nums) != 3.0df) FAILURE + if (ptr_d64_field (&nums) != 2.0dd) FAILURE + if (ptr_d128_field (&nums) != 1.0dl) FAILURE + if (ptr_dummy1_field (&nums) != 'a') FAILURE + if (ptr_dummy2_field (&nums) != 'b') FAILURE + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/func-vararg-alternate-d128-2.c b/gcc/testsuite/c-c++-common/dfp/func-vararg-alternate-d128-2.c new file mode 100644 index 00000000000..2960c357ade --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/func-vararg-alternate-d128-2.c @@ -0,0 +1,22 @@ +/* { dg-do run { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ +/* { dg-options "-mpreferred-stack-boundary=2" } */ + +/* Simple test of vararg passing for problematic types with and without + double values passed between them. */ + +#define DTYPE _Decimal128 +#define ONE 1.0dl +#define THREE 3.0dl +#define SEVEN 7.0dl +#define ELEVEN 11.0dl +#define INTS 4 + +#include "func-vararg-alternate.h" + +int +main () +{ + doit (); + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/func-vararg-alternate-d128.c b/gcc/testsuite/c-c++-common/dfp/func-vararg-alternate-d128.c new file mode 100644 index 00000000000..8d452eadc38 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/func-vararg-alternate-d128.c @@ -0,0 +1,19 @@ +/* Simple test of vararg passing for problematic types with and without + double values passed between them. */ + +#define DTYPE _Decimal128 +#define ONE 1.0dl +#define THREE 3.0dl +#define SEVEN 7.0dl +#define ELEVEN 11.0dl +#define INTS 4 + +#include "func-vararg-alternate.h" + +int +main () +{ + doit (); + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/func-vararg-alternate-d32.c b/gcc/testsuite/c-c++-common/dfp/func-vararg-alternate-d32.c new file mode 100644 index 00000000000..651b7e8c50f --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/func-vararg-alternate-d32.c @@ -0,0 +1,19 @@ +/* Simple test of vararg passing for problematic types with and without + double values passed between them. */ + +#define DTYPE _Decimal32 +#define ONE 1.0df +#define THREE 3.0df +#define SEVEN 7.0df +#define ELEVEN 11.0df +#define INTS 1 + +#include "func-vararg-alternate.h" + +int +main () +{ + doit (); + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/func-vararg-alternate-d64.c b/gcc/testsuite/c-c++-common/dfp/func-vararg-alternate-d64.c new file mode 100644 index 00000000000..86b475d2ada --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/func-vararg-alternate-d64.c @@ -0,0 +1,19 @@ +/* Simple test of vararg passing for problematic types with and without + double values passed between them. */ + +#define DTYPE _Decimal64 +#define ONE 1.0dd +#define THREE 3.0dd +#define SEVEN 7.0dd +#define ELEVEN 11.0dd +#define INTS 2 + +#include "func-vararg-alternate.h" + +int +main () +{ + doit (); + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/func-vararg-alternate.h b/gcc/testsuite/c-c++-common/dfp/func-vararg-alternate.h new file mode 100644 index 00000000000..5ba0ab0dc1f --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/func-vararg-alternate.h @@ -0,0 +1,143 @@ +/* Simple test of vararg passing for problematic types with and without + double values passed between them. */ + +#include "dfp-dbg.h" +#include + +DTYPE a[10]; +double b[10]; + +union U { + DTYPE d; + unsigned int i[INTS]; +}; + +void +compare (double r, double s, unsigned int *p, unsigned int *q, int n, int line) +{ + int i; + + for (i = 0; i < n; i++) + if (r != s || p[i] != q[i]) +#ifdef DBG + { + int j; + + failures++; + printf ("line %-3d", line); + for (j = 0; j < n; j++) + printf (" %08x", p[j]); + printf (" %10.2g\n ", r); + for (j = 0; j < n; j++) + printf (" %08x", q[j]); + printf (" %10.2g\n\n", s); + + return; + } +#else + __builtin_abort (); +#endif +} + +void +bar0 (int n, ...) +{ + union U u; + int j; + va_list ap; + + va_start (ap, n); + for (j = 0; j < n; j++) + a[j] = va_arg (ap, DTYPE); + va_end (ap); +} + +void +bar1 (int n, ...) +{ + union U u; + int j; + va_list ap; + + va_start (ap, n); + for (j = 0; j < n; j++) + { + a[j] = va_arg (ap, DTYPE); + b[j] = va_arg (ap, double); + } + va_end (ap); +} + +void +bar2 (int n, ...) +{ + union U u; + int j; + va_list ap; + + va_start (ap, n); + for (j = 0; j < n; j++) + { + b[j] = va_arg (ap, double); + a[j] = va_arg (ap, DTYPE); + } + va_end (ap); +} + +void +doit () +{ + DTYPE x, y, z; + union U u1, u2; + + /* Sanity check that test setup is right, especially for long double + which can be changed by command line option. */ + if (INTS * 4 != sizeof (DTYPE)) + { +#ifdef DBG + printf ("test error: INTS = %d, sizeof (DTYPE) = %d\n", + INTS, sizeof (DTYPE)); +#endif + __builtin_abort (); + } + + x = ONE / THREE; + y = ONE / SEVEN; + z = ONE / ELEVEN; + + bar0 (1, x); + u1.d = x; u2.d = a[0]; compare (0.0, 0.0, u1.i, u2.i, INTS, __LINE__); + + bar0 (2, x, y); + u1.d = x; u2.d = a[0]; compare (0.0, 0.0, u1.i, u2.i, INTS, __LINE__); + u1.d = y; u2.d = a[1]; compare (0.0, 0.0, u1.i, u2.i, INTS, __LINE__); + + bar0 (3, x, y, z); + u1.d = x; u2.d = a[0]; compare (0.0, 0.0, u1.i, u2.i, INTS, __LINE__); + u1.d = y; u2.d = a[1]; compare (0.0, 0.0, u1.i, u2.i, INTS, __LINE__); + u1.d = z; u2.d = a[2]; compare (0.0, 0.0, u1.i, u2.i, INTS, __LINE__); + + bar1 (1, x, 1.5); + u1.d = x; u2.d = a[0]; compare (1.5, b[0], u1.i, u2.i, INTS, __LINE__); + + bar1 (2, x, 1.5, y, 2.5); + u1.d = x; u2.d = a[0]; compare (1.5, b[0], u1.i, u2.i, INTS, __LINE__); + u1.d = y; u2.d = a[1]; compare (2.5, b[1], u1.i, u2.i, INTS, __LINE__); + + bar1 (3, x, 1.5, y, 2.5, z, 3.5); + u1.d = x; u2.d = a[0]; compare (1.5, b[0], u1.i, u2.i, INTS, __LINE__); + u1.d = y; u2.d = a[1]; compare (2.5, b[1], u1.i, u2.i, INTS, __LINE__); + u1.d = z; u2.d = a[2]; compare (3.5, b[2], u1.i, u2.i, INTS, __LINE__); + + bar2 (1, 1.5, x); + u1.d = x; u2.d = a[0]; compare (1.5, b[0], u1.i, u2.i, INTS, __LINE__); + + bar2 (2, 1.5, x, 2.5, y); + u1.d = x; u2.d = a[0]; compare (1.5, b[0], u1.i, u2.i, INTS, __LINE__); + u1.d = y; u2.d = a[1]; compare (2.5, b[1], u1.i, u2.i, INTS, __LINE__); + + bar2 (3, 1.5, x, 2.5, y, 3.5, z); + u1.d = x; u2.d = a[0]; compare (1.5, b[0], u1.i, u2.i, INTS, __LINE__); + u1.d = y; u2.d = a[1]; compare (2.5, b[1], u1.i, u2.i, INTS, __LINE__); + u1.d = z; u2.d = a[2]; compare (3.5, b[2], u1.i, u2.i, INTS, __LINE__); +} diff --git a/gcc/testsuite/c-c++-common/dfp/func-vararg-dfp.c b/gcc/testsuite/c-c++-common/dfp/func-vararg-dfp.c new file mode 100644 index 00000000000..5add1f7fd38 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/func-vararg-dfp.c @@ -0,0 +1,95 @@ +/* C99 6.5.2.2 Function calls. + Test passing varargs of the decimal float types. */ + +#include +#include "dfp-dbg.h" + +static _Decimal32 +vararg32 (unsigned arg, ...) +{ + int i; + va_list ap; + _Decimal32 result; + + va_start (ap, arg); + for (i = 0; i <= arg; i++) + result = va_arg (ap, _Decimal32); + va_end (ap); + return result; +} + +static _Decimal64 +vararg64 (unsigned arg, ...) +{ + int i; + va_list ap; + _Decimal64 result; + + va_start (ap, arg); + for (i = 0; i <= arg; i++) + result = va_arg (ap, _Decimal64); + va_end (ap); + return result; +} + +static _Decimal128 +vararg128 (unsigned arg, ...) +{ + int i; + va_list ap; + _Decimal128 result; + + va_start (ap, arg); + for (i = 0; i <= arg; i++) + result = va_arg (ap, _Decimal128); + va_end (ap); + return result; +} + + +int main() +{ + /* _Decimal32 variants. */ + if (vararg32 (0, 0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 0.0df) + FAILURE + if (vararg32 (1, 0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 1.0df) + FAILURE + if (vararg32 (2, 0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 2.0df) + FAILURE + if (vararg32 (3, 0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 3.0df) + FAILURE + if (vararg32 (4, 0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 4.0df) + FAILURE + if (vararg32 (5, 0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 5.0df) + FAILURE + + /* _Decimal64 variants. */ + if (vararg64 (0, 0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 0.0dd) + FAILURE + if (vararg64 (1, 0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 1.0dd) + FAILURE + if (vararg64 (2, 0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 2.0dd) + FAILURE + if (vararg64 (3, 0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 3.0dd) + FAILURE + if (vararg64 (4, 0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 4.0dd) + FAILURE + if (vararg64 (5, 0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 5.0dd) + FAILURE + + /* _Decimal128 variants. */ + if (vararg128 (0, 0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 0.0dl) + FAILURE + if (vararg128 (1, 0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 1.0dl) + FAILURE + if (vararg128 (2, 0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 2.0dl) + FAILURE + if (vararg128 (3, 0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 3.0dl) + FAILURE + if (vararg128 (4, 0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 4.0dl) + FAILURE + if (vararg128 (5, 0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 5.0dl) + FAILURE + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/func-vararg-mixed-2.c b/gcc/testsuite/c-c++-common/dfp/func-vararg-mixed-2.c new file mode 100644 index 00000000000..893cdae27ff --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/func-vararg-mixed-2.c @@ -0,0 +1,105 @@ +/* { dg-do run { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ +/* { dg-options "-mpreferred-stack-boundary=2" } */ + +/* C99 6.5.2.2 Function calls. + Test passing varargs of the combination of decimal float types and + other types. */ + +#include +#include "dfp-dbg.h" + +/* Supposing the list of varying number of arguments is: + unsigned int, _Decimal128, double, _Decimal32, _Decimal64. */ + +static _Decimal32 +vararg_d32 (unsigned arg, ...) +{ + va_list ap; + _Decimal32 result; + + va_start (ap, arg); + + va_arg (ap, unsigned int); + va_arg (ap, _Decimal128); + va_arg (ap, double); + result = va_arg (ap, _Decimal32); + + va_end (ap); + return result; +} + +static _Decimal32 +vararg_d64 (unsigned arg, ...) +{ + va_list ap; + _Decimal64 result; + + va_start (ap, arg); + + va_arg (ap, unsigned int); + va_arg (ap, _Decimal128); + va_arg (ap, double); + va_arg (ap, _Decimal32); + result = va_arg (ap, _Decimal64); + + va_end (ap); + return result; +} + +static _Decimal128 +vararg_d128 (unsigned arg, ...) +{ + va_list ap; + _Decimal128 result; + + va_start (ap, arg); + + va_arg (ap, unsigned int); + result = va_arg (ap, _Decimal128); + + va_end (ap); + return result; +} + +static unsigned int +vararg_int (unsigned arg, ...) +{ + va_list ap; + unsigned int result; + + va_start (ap, arg); + + result = va_arg (ap, unsigned int); + + va_end (ap); + return result; +} + +static double +vararg_double (unsigned arg, ...) +{ + va_list ap; + float result; + + va_start (ap, arg); + + va_arg (ap, unsigned int); + va_arg (ap, _Decimal128); + result = va_arg (ap, double); + + va_end (ap); + return result; +} + + +int +main () +{ + if (vararg_d32 (3, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 3.0df) FAILURE + if (vararg_d64 (4, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 4.0dd) FAILURE + if (vararg_d128 (1, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 1.0dl) FAILURE + if (vararg_int (0, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 0) FAILURE + if (vararg_double (2, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 2.0) FAILURE + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/func-vararg-mixed.c b/gcc/testsuite/c-c++-common/dfp/func-vararg-mixed.c new file mode 100644 index 00000000000..1669eaf959a --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/func-vararg-mixed.c @@ -0,0 +1,102 @@ +/* C99 6.5.2.2 Function calls. + Test passing varargs of the combination of decimal float types and + other types. */ + +#include +#include "dfp-dbg.h" + +/* Supposing the list of varying number of arguments is: + unsigned int, _Decimal128, double, _Decimal32, _Decimal64. */ + +static _Decimal32 +vararg_d32 (unsigned arg, ...) +{ + va_list ap; + _Decimal32 result; + + va_start (ap, arg); + + va_arg (ap, unsigned int); + va_arg (ap, _Decimal128); + va_arg (ap, double); + result = va_arg (ap, _Decimal32); + + va_end (ap); + return result; +} + +static _Decimal32 +vararg_d64 (unsigned arg, ...) +{ + va_list ap; + _Decimal64 result; + + va_start (ap, arg); + + va_arg (ap, unsigned int); + va_arg (ap, _Decimal128); + va_arg (ap, double); + va_arg (ap, _Decimal32); + result = va_arg (ap, _Decimal64); + + va_end (ap); + return result; +} + +static _Decimal128 +vararg_d128 (unsigned arg, ...) +{ + va_list ap; + _Decimal128 result; + + va_start (ap, arg); + + va_arg (ap, unsigned int); + result = va_arg (ap, _Decimal128); + + va_end (ap); + return result; +} + +static unsigned int +vararg_int (unsigned arg, ...) +{ + va_list ap; + unsigned int result; + + va_start (ap, arg); + + result = va_arg (ap, unsigned int); + + va_end (ap); + return result; +} + +static double +vararg_double (unsigned arg, ...) +{ + va_list ap; + float result; + + va_start (ap, arg); + + va_arg (ap, unsigned int); + va_arg (ap, _Decimal128); + result = va_arg (ap, double); + + va_end (ap); + return result; +} + + +int +main () +{ + if (vararg_d32 (3, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 3.0df) FAILURE + if (vararg_d64 (4, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 4.0dd) FAILURE + if (vararg_d128 (1, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 1.0dl) FAILURE + if (vararg_int (0, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 0) FAILURE + if (vararg_double (2, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 2.0) FAILURE + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/func-vararg-size0.c b/gcc/testsuite/c-c++-common/dfp/func-vararg-size0.c new file mode 100644 index 00000000000..bc8b20fd484 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/func-vararg-size0.c @@ -0,0 +1,41 @@ +/* C99 6.5.2.2 Function calls. */ + +#include +#include "dfp-dbg.h" + +struct S1 +{ + struct + { + _Decimal64 e; + } b[0]; +}; + +/* Test handling vararg parameters whose size is 0. */ + +int check_var(int z,...) +{ + double d; + struct S1 s1; + long long result; + va_list ap; + va_start (ap, z); + d = va_arg (ap, double); + s1 = va_arg (ap, struct S1); + result = va_arg (ap, long long); + va_end (ap); + return (result == 2LL); + +} + +int +main () +{ + struct S1 s1; + struct S1 a1[5]; + + if (check_var(5, 1.0, s1, 2LL, a1[2], a1[2]) == 0) + FAILURE + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/inf-1.c b/gcc/testsuite/c-c++-common/dfp/inf-1.c new file mode 100644 index 00000000000..c4f8cd79610 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/inf-1.c @@ -0,0 +1,61 @@ +/* N1150 4: Characteristics of decimal floating types (not explicit) + C99 5.2.4.2.2: Characteristics of floating types. + A few simple checks on arithmetic operations. */ + +#include "dfp-dbg.h" + +int main() +{ + /* Assumes rounding mode. */ + if (9999999.E90DF + 1.E90df != __builtin_infd32 ()) + FAILURE + + if (!__builtin_isinfd32 (9999999.E90DF + 1.E90df)) + FAILURE + + if (9.999999999999999E384dd + .000000000000001e384dd + != __builtin_infd32 ()) + FAILURE + + if (-9999999.E90DF - 1.E90df != -__builtin_infd32 ()) + FAILURE + + if (!__builtin_isinfd32 (9.999999999999999E384dd + .000000000000001e384dd)) + FAILURE + + if (7.999999999999999999999999999999999E6144dl + 3.0E6144dl + != __builtin_infd32 ()) + FAILURE + + if (__builtin_infd32 () * __builtin_infd32 () != __builtin_infd32 ()) + FAILURE + + if (__builtin_infd32 () * 2 != __builtin_infd32 ()) + FAILURE + + if (__builtin_infd64 () * -5 != -__builtin_infd32 ()) + FAILURE + + if (!__builtin_isinfd128 (__builtin_infd32 () / 4)) + FAILURE + + if (__builtin_infd64 () != __builtin_infd128 ()) + FAILURE + + if (!__builtin_isinfd64 (__builtin_infd128 ())) + FAILURE + + if (__builtin_finited64 (__builtin_infd32 () * 4)) + FAILURE + + if (!__builtin_finited128 (9.999999E90DL - 1.E90dd)) + FAILURE + + if (__builtin_finited128 (__builtin_infd32 () *__builtin_infd128 ())) + FAILURE + + if (__builtin_finited32 (__builtin_nand32 (""))) + FAILURE + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/loop-index.c b/gcc/testsuite/c-c++-common/dfp/loop-index.c new file mode 100644 index 00000000000..a944042a79b --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/loop-index.c @@ -0,0 +1,57 @@ +/* C99 6.8.5.2: The for statement. */ + +#include +#include +#include "dfp-dbg.h" + +void +f32 (void) +{ + _Decimal32 d; + int i; + + for (d = 1.1df, i=0; d <= 1.5df; d += 0.1df) + i++; + + if (i != 5) + FAILURE +} + +void +f64 (void) +{ + _Decimal64 d; + int i; + + for (d = 1.1dd, i=0; d <= 1.5dd; d += 0.1dd) + i++; + + if (i != 5) + FAILURE +} + +void +f128 (void) +{ + _Decimal128 d; + int i; + + for (d = 1.1dl, i=0; d <= 1.5dl; d += 0.1dl) + i++; + + if (i != 5) + FAILURE +} + +int +main () +{ + int i; + + f32 (); + f64 (); + f128 (); + + FINISH + return (0); +} diff --git a/gcc/testsuite/c-c++-common/dfp/modes.c b/gcc/testsuite/c-c++-common/dfp/modes.c new file mode 100644 index 00000000000..09d4a15c264 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/modes.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ + +typedef float decimal32 __attribute__ ((mode (SD))); +typedef float decimal64 __attribute__ ((mode (DD))); +typedef float decimal128 __attribute__ ((mode (TD))); + +int ssize[sizeof (decimal32) == 4 ? 1 : -1]; +int dsize[sizeof (decimal64) == 8 ? 1 : -1]; +int tsize[sizeof (decimal128) == 16 ? 1 : -1]; + +int salign = __alignof (decimal32); +int dalign = __alignof (decimal64); +int talign = __alignof (decimal128); + diff --git a/gcc/testsuite/c-c++-common/dfp/nan-1.c b/gcc/testsuite/c-c++-common/dfp/nan-1.c new file mode 100644 index 00000000000..8961777c79b --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/nan-1.c @@ -0,0 +1,106 @@ +/* N1150 4: Characteristics of decimal floating types (not explicit) + C99 5.2.4.2.2: Characteristics of floating types. + A few simple checks on arithmetic operations. */ + +#include "dfp-dbg.h" + +int main() +{ + /* Some possibly non-obvious tests, but most logical + operations on NaN return false, including NaN == NaN. */ + if (__builtin_nand32("") == __builtin_nand32("")) + FAILURE + + if (__builtin_nand64("") == __builtin_nand64("")) + FAILURE + + if (__builtin_nand128("") == __builtin_nand128("")) + FAILURE + + if (!(__builtin_nand32("") != __builtin_nand32(""))) + FAILURE + + if (!(__builtin_nand64("") != __builtin_nand64(""))) + FAILURE + + if (!(__builtin_nand128("") != __builtin_nand128(""))) + FAILURE + + if (__builtin_nand32("") > __builtin_nand32("")) + FAILURE + + if (__builtin_nand64("") >= __builtin_nand64("")) + FAILURE + + if (__builtin_nand128("") < __builtin_nand128("")) + FAILURE + + if (-__builtin_nand128("") < +__builtin_nand128("")) + FAILURE + + /* 0.0/0.0 => NaN, but NaN != NaN. */ + if (0.0df/0.0dl == __builtin_nand32("")) + FAILURE + + /* 0.0 * INF => NaN. */ + if (!__builtin_isnand32 (0.0df * __builtin_infd32())) + FAILURE + + if (!__builtin_isnand64 (0.0dd * __builtin_infd64())) + FAILURE + + if (!__builtin_isnand128 (0.0dd * __builtin_infd128())) + FAILURE + + /* INF - INF => NaN. */ + if (!__builtin_isnand32 (__builtin_infd32() - __builtin_infd32())) + FAILURE + + if (!__builtin_isnand64 (__builtin_infd64() - __builtin_infd64())) + FAILURE + + if (!__builtin_isnand128 (__builtin_infd128() - __builtin_infd128())) + FAILURE + + /* INF/INF => NaN. */ + if (!__builtin_isnand32 (__builtin_infd32()/__builtin_infd32()) ) + FAILURE + + if (!__builtin_isnand64 (__builtin_infd64()/__builtin_infd64()) ) + FAILURE + + if (!__builtin_isnand128 (__builtin_infd128()/__builtin_infd128()) ) + FAILURE + + /* 0.0/0.0 => NaN, but NaN != NaN. */ + if ((0.0dd/0.0df) == (0.0dd/0.0df)) + FAILURE + + if (__builtin_nand32("") < __builtin_infd32()) + FAILURE + + if (__builtin_nand32("") >= __builtin_infd32()) + FAILURE + + /* Fixme: Add sqrtdf(-x.df) test when sqrt is supported. */ + + if (!__builtin_isnand32(__builtin_nand32(""))) + FAILURE + + if (!__builtin_isnand64(__builtin_nand64(""))) + FAILURE + + if (!__builtin_isnand128(__builtin_nand128(""))) + FAILURE + + if (!__builtin_isnand128(8.0df * __builtin_nand128(""))) + FAILURE + + if (!__builtin_isnand32(8.1dl - __builtin_nand32(""))) + FAILURE + + if (!__builtin_isnand128(__builtin_nand64("") + __builtin_nand128(""))) + FAILURE + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/nan-2.c b/gcc/testsuite/c-c++-common/dfp/nan-2.c new file mode 100644 index 00000000000..ec9d18e1000 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/nan-2.c @@ -0,0 +1,53 @@ +/* N1150 4: Characteristics of decimal floating types (not explicit) + C99 5.2.4.2.2: Characteristics of floating types. + A few simple checks on arithmetic operations. Based on nan-1.c with + the consideration of negative zero. */ + +#include "dfp-dbg.h" + +int main() +{ + _Decimal32 d32; + _Decimal64 d64; + _Decimal128 d128; + + /* Verify that division by negative zero produces a negative infinity + result. */ + d32 = 123.45f; + if (d32/-0.0df != -__builtin_infd32()) + FAILURE + if (123.45df/-0.0df != -__builtin_infd32()) + FAILURE + + d64 = 123.45f; + if (d64/-0.0dd != -__builtin_infd64()) + FAILURE + if (123.45dd/-0.0dd != -__builtin_infd64()) + FAILURE + + d128 = 123.45f; + if (d128/-0.0dl != -__builtin_infd64()) + FAILURE + if (123.45dl/-0.0dl != -__builtin_infd128()) + FAILURE + + d32 = 0.0df; + if (!__builtin_isnand32(-(d32/-0.0df))) + FAILURE + if (!__builtin_isnand32(-(0.0df/-0.0df))) + FAILURE + + d64 = 0.0dd; + if (!__builtin_isnand64(-(d64/-0.0dd))) + FAILURE + if (!__builtin_isnand64(-(0.0dd/-0.0dd))) + FAILURE + + d128 = 0.0dl; + if (!__builtin_isnand128(-(d128/-0.0dl))) + FAILURE + if (!__builtin_isnand128(-(0.0dl/-0.0dl))) + FAILURE + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/operator-arith-fold.c b/gcc/testsuite/c-c++-common/dfp/operator-arith-fold.c new file mode 100644 index 00000000000..c4aa4cbb27e --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/operator-arith-fold.c @@ -0,0 +1,45 @@ +/* { dg-options "-O2" } */ + +/* C99 6.5.5: Multiplicative operators. + C99 6.5.6: Additive operators. */ + +#include "dfp-dbg.h" + +extern void link_error (void); + +int +main () +{ + _Decimal32 d32_1, d32_2; + + /* Compare like-typed positive constants. */ + if (2.99df + 5.1df != 8.09df) + link_error (); + + if (5.77df - 2.22dd != 3.55df) + link_error (); + + if (2.0dl * 3.7dd * -2 != -14.8df) + link_error (); + + if (.18df / -.2df + 1 != 1.e-1dd) + link_error (); + + d32_1 = 3.0df; + d32_2 = 1.0df; + + if (!__builtin_constant_p (d32_1 + 0.2df)) + link_error (); + + if (!__builtin_constant_p (1.0df / 3.0df)) + link_error (); + + if (!__builtin_constant_p (d32_2 / d32_1)) + link_error (); + + d32_2 = 2.0df; + if (!__builtin_constant_p (d32_2 / d32_1)) + link_error (); + + return 0; +} 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 00000000000..faadf1e8650 --- /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 +} diff --git a/gcc/testsuite/c-c++-common/dfp/operator-comma.c b/gcc/testsuite/c-c++-common/dfp/operator-comma.c new file mode 100644 index 00000000000..be6bf6f8cd1 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/operator-comma.c @@ -0,0 +1,47 @@ +/* { dg-options "-O0" } */ + +/* C99 6.5.17: Comma operator. + Test with decimal float operands. */ + +#include "dfp-dbg.h" + +volatile _Decimal32 d32a, d32b, d32c; +volatile _Decimal64 d64a, d64b, d64c; +volatile _Decimal128 d128a, d128b, d128c; + +void +init () +{ + d32b = 123.456e94df; + d64b = 12.3456789012345e383dd; + d128b = 12345.6789012345678901e4000dl; + + d32c = 1.3df; + d64c = 1.2dd; + d128c = 1.1dl; +} + +int +main () +{ + d32a = (d32b, d32c); + if (d32a != d32c) + FAILURE + d64a = (d64b, 7.89dd, d64c); + if (d64a != d64c) + FAILURE + d128a = (45678.987654dl, d128c, d128b); + if (d128a != d128b) + FAILURE + d128a = (d32b, d64b, d128b); + if (d128a != d128b) + FAILURE + d32a = (d32b, 12, d64c); + if (d32a != d64c) + FAILURE; + d64a = (d64b, d32b, 12); + if (d64a != 12.0dd) + FAILURE; + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/operator-cond.c b/gcc/testsuite/c-c++-common/dfp/operator-cond.c new file mode 100644 index 00000000000..140dd95074a --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/operator-cond.c @@ -0,0 +1,57 @@ +/* { dg-options "-O0" } */ + +/* C99 6.5.15 Conditional operator. + Test with decimal float operands. */ + +#include "dfp-dbg.h" + +volatile _Decimal32 d32a, d32b, d32c; +volatile _Decimal64 d64a, d64b, d64c; +volatile _Decimal128 d128a, d128b, d128c; +volatile int i, yes, no; + +void +init () +{ + d32b = 123.456e94df; + d64b = 12.3456789012345e383dd; + d128b = 12345.6789012345678901e4000dl; + + d32c = 1.3df; + d64c = 1.2dd; + d128c = 1.1dl; + + i = 2; + yes = 1; + no = 0; +} + +int +main () +{ + init (); + + /* Operands and the result are all the same decimal float type. */ + d32a = yes ? d32b : d32c; + if (d32a != d32b) + FAILURE + d64a = no ? d64b : d64c; + if (d64a != d64c) + FAILURE + d128a = yes ? d128b : d128c; + if (d128a != d128b) + FAILURE + + /* Operand types are different. */ + d128a = yes ? d32b : d64b; + if (d128a != d32b) + FAILURE + d128a = yes ? d128b : d64b; + if (d128a != d128b) + FAILURE + d128a = no ? d32b : d128b; + if (d128a != d128b) + FAILURE + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/operator-logical.c b/gcc/testsuite/c-c++-common/dfp/operator-logical.c new file mode 100644 index 00000000000..c784468c77a --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/operator-logical.c @@ -0,0 +1,63 @@ +/* C99 Logical AND operator. + C99 Logical OR operator. + Test with decimal float operands. */ + +#include "dfp-dbg.h" + +#define OPERATE(OPRD1,OPRT,OPRD2,RLT) \ +do \ +{ \ + if (( (OPRD1) OPRT (OPRD2) )!= RLT) \ + __builtin_abort (); \ +} while (0) + +#define DECIMAL_LOGICAL_OR(OPRD) \ +do \ +{ \ + OPRD = 1.0; \ + OPERATE(1,||,OPRD,1); \ + OPERATE(0,||,OPRD,1); \ + OPERATE(OPRD,||,1,1); \ + OPERATE(OPRD,||,0,1); \ + OPRD = 0.0; \ + OPERATE(1,||,OPRD,1); \ + OPERATE(0,||,OPRD,0); \ + OPERATE(OPRD,||,1,1); \ + OPERATE(OPRD,||,0,0); \ +} while (0) + +#define DECIMAL_LOGICAL_AND(OPRD) \ +do \ +{ \ + OPRD = 1.0; \ + OPERATE(1,&&,OPRD,1); \ + OPERATE(0,&&,OPRD,0); \ + OPERATE(OPRD,&&,1,1); \ + OPERATE(OPRD,&&,0,0); \ + OPRD = 0.0; \ + OPERATE(1,&&,OPRD,0); \ + OPERATE(0,&&,OPRD,0); \ + OPERATE(OPRD,&&,1,0); \ + OPERATE(OPRD,&&,0,0); \ +} while (0) + +int +main () +{ + _Decimal32 d32; + _Decimal64 d64; + _Decimal128 d128; + + /* C99 Section 6.5.{13,14} Logical operator. Constraints Each of the + operands shall have scalar type. DFP types would obey this. */ + DECIMAL_LOGICAL_OR (d32); + DECIMAL_LOGICAL_AND (d32); + + DECIMAL_LOGICAL_OR (d64); + DECIMAL_LOGICAL_AND (d64); + + DECIMAL_LOGICAL_OR (d128); + DECIMAL_LOGICAL_AND (d128); + + return 0; +} diff --git a/gcc/testsuite/c-c++-common/dfp/operator-unary.c b/gcc/testsuite/c-c++-common/dfp/operator-unary.c new file mode 100644 index 00000000000..65f0be074d9 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/operator-unary.c @@ -0,0 +1,52 @@ +/* C99 6.5.3 Unary operators. */ + +#include "dfp-dbg.h" + +#define AUTO_INCREASE_DECREASE(TYPE,SUFFIX) \ +do \ +{ \ + _Decimal##TYPE in_de_d##TYPE = 0.0##SUFFIX; \ + if (in_de_d##TYPE++) FAILURE \ + if (--in_de_d##TYPE) FAILURE \ + if (++in_de_d##TYPE == 0.0##SUFFIX) FAILURE \ + if (in_de_d##TYPE-- == 0.0##SUFFIX) FAILURE \ +} while(0) + +#define UNARY_OPERATOR(TYPE,SUFFIX) \ +do \ +{ \ + _Decimal##TYPE unary_d##TYPE = 1.0##SUFFIX; \ + _Decimal##TYPE* unary_dp##TYPE; \ + /* & operator. */ \ + unary_dp##TYPE = &(unary_d##TYPE); \ + /* * operator. */ \ + unary_d##TYPE = *(unary_dp##TYPE); \ + /* - operator. */ \ + unary_d##TYPE = -unary_d##TYPE; \ + if (unary_d##TYPE != -1.0##SUFFIX) FAILURE \ + /* + operator. */ \ + unary_d##TYPE = +unary_d##TYPE; \ + if (unary_d##TYPE != -1.0##SUFFIX) FAILURE \ + if (!unary_d##TYPE) FAILURE /*! operator. */ \ +} while (0) + +int +main () +{ + /* C99 6.5.3.1 Prefix increment and decrement operators. */ + AUTO_INCREASE_DECREASE(32, DF); + AUTO_INCREASE_DECREASE(64, DD); + AUTO_INCREASE_DECREASE(128, DL); + + /* C99 6.5.3 Unary operators. */ + UNARY_OPERATOR(32, DF); + UNARY_OPERATOR(64, DD); + UNARY_OPERATOR(128, DL); + + /* C99 6.5.3 Unary operators for zero values. */ + if (- +0.df != -0.df) FAILURE + if (+ -0.df != -0.df) FAILURE + if (- -0.df != +0.df) FAILURE + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/pr31385.c b/gcc/testsuite/c-c++-common/dfp/pr31385.c new file mode 100644 index 00000000000..fc024a3e6b8 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/pr31385.c @@ -0,0 +1,30 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +typedef float fp_t __attribute__((mode(SD))); + +extern fp_t g(fp_t); + +fp_t +bug(fp_t x) +{ + fp_t result; + int n; + fp_t f, f3, y, z; + + n = 0; + y = 1.DF; + f = g(x); + + if (f < 0.DF) + f = -f; + + f3 = 2.DF; + + z = (y + y + f / (y * y)); + y = (z + z) / (9.DF) + f3 / (z * z); + + result = y; + + return (result); +} diff --git a/gcc/testsuite/c-c++-common/dfp/pr33466.c b/gcc/testsuite/c-c++-common/dfp/pr33466.c new file mode 100644 index 00000000000..e1cd76b74ff --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/pr33466.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ + +/* The suffix for a decimal float constant must use a single case. + + These are invalid for all targets, not just those that support + decimal float. */ + +long double dF = 4.5dF; /* { dg-error "invalid suffix" } */ +long double Df = 4.5Df; /* { dg-error "invalid suffix" } */ +long double dD = 4.5dD; /* { dg-error "invalid suffix" } */ +long double Dd = 4.5Dd; /* { dg-error "invalid suffix" } */ +long double dL = 4.5dL; /* { dg-error "invalid suffix" } */ +long double Dl = 4.5Dl; /* { dg-error "invalid suffix" } */ diff --git a/gcc/testsuite/c-c++-common/dfp/pr35620.c b/gcc/testsuite/c-c++-common/dfp/pr35620.c new file mode 100644 index 00000000000..37a9c4044ed --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/pr35620.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +#ifdef __cplusplus +typedef float _Decimal32 __attribute__((mode(SD))); +#endif + +extern void foo (_Decimal32); +_Decimal32 *p; + +extern int i; +union { _Decimal32 a; int b; } u; + +void +blatz (void) +{ + _Decimal32 d; + u.b = i; + d = u.a; + foo (d); +} + +void +bar (void) +{ + foo (*p); +} diff --git a/gcc/testsuite/c-c++-common/dfp/pr36800.c b/gcc/testsuite/c-c++-common/dfp/pr36800.c new file mode 100644 index 00000000000..76ff28c9815 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/pr36800.c @@ -0,0 +1,32 @@ +/* { dg-do run } */ + +#include +#include "dfp-dbg.h" + +void +f (int a, ...) +{ + va_list ap; + if (a != 0) + FAILURE + va_start (ap, a); + if (va_arg (ap, _Decimal128) != 1.2DL) + FAILURE + if (va_arg (ap, _Decimal128) != 2.34DL) + FAILURE + if (va_arg (ap, _Decimal128) != 3.456DL) + FAILURE + if (va_arg (ap, _Decimal128) != 4.567DL) + FAILURE + if (va_arg (ap, double) != 5.125) + FAILURE + va_end (ap); +} + +int +main (void) +{ + f (0, 1.2DL, 2.34DL, 3.456DL, 4.567DL, 5.125); + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/pr39034.c b/gcc/testsuite/c-c++-common/dfp/pr39034.c new file mode 100644 index 00000000000..2a7eedbdbe2 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/pr39034.c @@ -0,0 +1,100 @@ +/* { dg-do run } */ +/* { dg-options "-O" } */ + +/* DFP TR 24732 == WG14 / N1176, N1312 */ +/* Based on a test from Fred Tydeman. */ + +#include "dfp-dbg.h" + +/* Test runtime computations. */ + +void +runtime32 (void) +{ + volatile float v1 = 28.f, v2 = 3.f, v3 = 9.f, v4 = 31.f, v5 = 3.f, v6 = 10.f; + float b32 = (float)((v1/v2-v3) - (v4/v5-v6)); + _Decimal32 d32 = (float)((v1/v2-v3) - (v4/v5-v6)); + + if (b32) + FAILURE + if (d32) + FAILURE +} + +void +runtime64 (void) +{ + volatile double v1 = 28., v2 = 3., v3 = 9., v4 = 31., v5 = 3., v6 = 10.; + double b64 = (double)((v1/v2-v3) - (v4/v5-v6)); + _Decimal64 d64 = (double)((v1/v2-v3) - (v4/v5-v6)); + + if (b64) + FAILURE + if (d64) + FAILURE +} + +void +runtime128 (void) +{ + volatile long double v1 = 28.l, v2 = 3.l, v3 = 9.l, + v4 = 31.l, v5 = 3.l, v6 = 10.l; + long double b128 = (long double)((v1/v2-v3) - (v4/v5-v6)); + _Decimal128 d128 = (long double)((v1/v2-v3) - (v4/v5-v6)); + + if (b128) + FAILURE + if (d128) + FAILURE +} + +/* Test constant folding. */ + +void +fold32 (void) +{ + double d32 = (float)((28.f/3.f-9.f) - (31.f/3.f-10.f)); + _Decimal32 b32 = (float)((28.f/3.f-9.f) - (31.f/3.f-10.f)); + + if (b32) + FAILURE + if (d32) + FAILURE +} + +void +fold64 (void) +{ + double b64 = (double)((28./3.-9.) - (31./3.-10.)); + _Decimal64 d64 = (double)((28./3.-9.) - (31./3.-10.)); + + if (b64) + FAILURE + if (d64) + FAILURE +} + +void +fold128 (void) +{ + long double b128 = (long double)((28./3.-9.) - (31./3.-10.)); + _Decimal128 d128 = (long double)((28./3.-9.) - (31./3.-10.)); + + if (b128) + FAILURE + if (d128) + FAILURE +} + +int +main () +{ + runtime32 (); + runtime64 (); + runtime128 (); + fold32 (); + fold64 (); + fold128 (); + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/pr39035.c b/gcc/testsuite/c-c++-common/dfp/pr39035.c new file mode 100644 index 00000000000..2c9e8b386ed --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/pr39035.c @@ -0,0 +1,71 @@ +/* { dg-do run } */ +/* { dg-options "-O" } */ + +/* DFP TR 24732 == WG14 / N1176, N1312 */ +/* Based on a test from Fred Tydeman. */ + +#include "dfp-dbg.h" + +/* Test runtime computations. */ + +void +runtime32 (void) +{ + volatile _Decimal32 d; + d = 0.0DF; + if (d) + FAILURE +} + +void +runtime64 (void) +{ + volatile _Decimal64 d; + d = 0.0DD; + if (d) + FAILURE +} + +void +runtime128 (void) +{ + volatile _Decimal128 d; + d = 0.0DL; + if (d) + FAILURE +} + +void +fold32 (void) +{ + if (0.0DF) + FAILURE +} + +void +fold64 (void) +{ + if (0.0DD) + FAILURE +} + +void +fold128 (void) +{ + if (0.0DL) + FAILURE +} + +int +main(void) +{ + runtime32 (); + runtime64 (); + runtime128 (); + + fold32 (); + fold64 (); + fold128 (); + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/pr39902.c b/gcc/testsuite/c-c++-common/dfp/pr39902.c new file mode 100644 index 00000000000..847069966e3 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/pr39902.c @@ -0,0 +1,226 @@ +/* Check that optimizations like (x * 1) to x, or (x * -1) to -x, + do not apply to decimal float computations where trailing zeroes + are significant. */ + +#include "dfp-dbg.h" + +#define COMPARE32(A,B) \ + A.i == B.i + +#define COMPARE64(A,B) \ + A.i[0] == B.i[0] && A.i[1] == B.i[1] + +#define COMPARE128(A,B) \ + A.i[0] == B.i[0] && A.i[1] == B.i[1] && A.i[2] == B.i[2] && A.i[3] == B.i[3] + +typedef union { + _Decimal32 d; + unsigned int i; +} u32; + +typedef union { + _Decimal64 d; + unsigned int i[2]; +} u64; + +typedef union { + _Decimal128 d; + unsigned int i[4]; +} u128; + +volatile u32 p32_1; +volatile u32 p32_1_0; +volatile u32 p32_2_0; +volatile u32 m32_1; +volatile u32 m32_1_0; +volatile u32 m32_2_0; +volatile u32 a32; + +volatile u64 p64_1; +volatile u64 p64_1_0; +volatile u64 p64_2_0; +volatile u64 m64_1; +volatile u64 m64_1_0; +volatile u64 m64_2_0; +volatile u64 a64; + +volatile u128 p128_1; +volatile u128 p128_1_0; +volatile u128 p128_2_0; +volatile u128 m128_1; +volatile u128 m128_1_0; +volatile u128 m128_2_0; +volatile u128 a128; + +void +init32 (void) +{ + p32_1.d = 1.DF; + p32_1_0.d = 1.0DF; + p32_2_0.d = 2.0DF; + m32_1.d = -1.DF; + m32_1_0.d = -1.0DF; + m32_2_0.d = -2.0DF; +} + +void +init64 (void) +{ + p64_1.d = 1.DD; + p64_1_0.d = 1.0DD; + p64_2_0.d = 2.0DD; + m64_1.d = -1.DD; + m64_1_0.d = -1.0DD; + m64_2_0.d = -2.0DD; +} + +void +init128 (void) +{ + p128_1.d = 1.DL; + p128_1_0.d = 1.0DL; + p128_2_0.d = 2.0DL; + m128_1.d = -1.DL; + m128_1_0.d = -1.0DL; + m128_2_0.d = -2.0DL; +} + +void +doit32 (void) +{ + /* Multiplying by a value with no trailing zero should not change the + quantum exponent. */ + + a32.d = p32_2_0.d * p32_1.d; + if (! (COMPARE32 (a32, p32_2_0))) + FAILURE + + a32.d = p32_2_0.d * 1.DF; + if (! (COMPARE32 (a32, p32_2_0))) + FAILURE + + a32.d = p32_2_0.d * m32_1.d; + if (! (COMPARE32 (a32, m32_2_0))) + FAILURE + + a32.d = p32_2_0.d * -1.DF; + if (! (COMPARE32 (a32, m32_2_0))) + FAILURE + + /* Multiplying by a value with a trailing zero should change the + quantum exponent. */ + + a32.d = p32_2_0.d * p32_1_0.d; + if (COMPARE32 (a32, p32_2_0)) + FAILURE + + a32.d = p32_2_0.d * 1.0DF; + if (COMPARE32 (a32, p32_2_0)) + FAILURE + + a32.d = p32_2_0.d * m32_1_0.d; + if (COMPARE32 (a32, m32_2_0)) + FAILURE + + a32.d = p32_2_0.d * -1.0DF; + if (COMPARE32 (a32, m32_2_0)) + FAILURE +} + +void +doit64 (void) +{ + /* Multiplying by a value with no trailing zero should not change the + quantum exponent. */ + + a64.d = p64_2_0.d * p64_1.d; + if (! (COMPARE64 (a64, p64_2_0))) + FAILURE + + a64.d = p64_2_0.d * 1.DD; + if (! (COMPARE64 (a64, p64_2_0))) + FAILURE + + a64.d = p64_2_0.d * m64_1.d; + if (! (COMPARE64 (a64, m64_2_0))) + FAILURE + + a64.d = p64_2_0.d * -1.DD; + if (! (COMPARE64 (a64, m64_2_0))) + FAILURE + + /* Multiplying by a value with a trailing zero should change the + quantum exponent. */ + + a64.d = p64_2_0.d * p64_1_0.d; + if (COMPARE64 (a64, p64_2_0)) + FAILURE + + a64.d = p64_2_0.d * 1.0DD; + if (COMPARE64 (a64, p64_2_0)) + FAILURE + + a64.d = p64_2_0.d * m64_1_0.d; + if (COMPARE64 (a64, m64_2_0)) + FAILURE + + a64.d = p64_2_0.d * -1.0DD; + if (COMPARE64 (a64, m64_2_0)) + FAILURE +} + +void +doit128 (void) +{ + /* Multiplying by a value with no trailing zero should not change the + quantum exponent. */ + + a128.d = p128_2_0.d * p128_1_0.d; + if (COMPARE128 (a128, p128_2_0)) + FAILURE + + a128.d = p128_2_0.d * 1.0DL; + if (COMPARE128 (a128, p128_2_0)) + FAILURE + + a128.d = p128_2_0.d * m128_1_0.d; + if (COMPARE128 (a128, m128_2_0)) + FAILURE + + a128.d = p128_2_0.d * -1.0DL; + if (COMPARE128 (a128, m128_2_0)) + FAILURE + + /* Multiplying by a value with a trailing zero should change the + quantum exponent. */ + + a128.d = p128_2_0.d * p128_1.d; + if (! (COMPARE128 (a128, p128_2_0))) + FAILURE + + a128.d = p128_2_0.d * 1.DL; + if (! (COMPARE128 (a128, p128_2_0))) + FAILURE + + a128.d = p128_2_0.d * m128_1.d; + if (! (COMPARE128 (a128, m128_2_0))) + FAILURE + + a128.d = p128_2_0.d * -1.DL; + if (! (COMPARE128 (a128, m128_2_0))) + FAILURE +} + +int +main (void) +{ + init32 (); + init64 (); + init128 (); + + doit32 (); + doit64 (); + doit128 (); + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/pr39986.c b/gcc/testsuite/c-c++-common/dfp/pr39986.c new file mode 100644 index 00000000000..e7c9ce98283 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/pr39986.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ + +#include "dfp-dbg.h" + +/* Check that the compiler generates the correct decimal float constants. */ + +_Decimal32 a = 100.223df; +_Decimal32 b = -2.3df; +_Decimal64 c = 3.4e-4dd; +_Decimal64 d = -4.500dd; +_Decimal128 e = 5678901234567.89e+200dl; +_Decimal128 f = -678901.234e-6dl; + +/* The first value is DPD, the second is BID. The order differs depending + on whether the target is big-endian or little-endian. */ + +/* { dg-final { scan-assembler ".long\t(572653859|822183807)\n" } } */ + +/* { dg-final { scan-assembler ".long\t(-1572863965|-1308622825)\n" } } */ + +/* { dg-final { scan-assembler ".long\t(52|34)\n" } } */ +/* { dg-final { scan-assembler ".long\t(572784640|824180736)\n" } } */ + +/* { dg-final { scan-assembler ".long\t(4736|4500)\n" } } */ +/* { dg-final { scan-assembler ".long\t(-1574174720|-1319108608)\n" } } */ + +/* { dg-final { scan-assembler ".long\t(-1975952433|957645077)\n" } } */ +/* { dg-final { scan-assembler ".long\t(190215|132222)\n" } } */ +/* { dg-final { scan-assembler ".long\t(574193664|835452928)\n" } } */ + +/* { dg-final { scan-assembler ".long\t(931280180|678901234)\n" } } */ +/* { dg-final { scan-assembler ".long\t(-1576681472|-1339162624)\n" } } */ diff --git a/gcc/testsuite/c-c++-common/dfp/signbit-1.c b/gcc/testsuite/c-c++-common/dfp/signbit-1.c new file mode 100644 index 00000000000..d83d2a48ed7 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/signbit-1.c @@ -0,0 +1,40 @@ +/* { dg-options "-O0" } */ + +/* Decimal float versions of __builtin_signbit. */ + +#include "dfp-dbg.h" + +#define CHECK32(D,I) \ + if ((__builtin_signbitd32 (D) != 0) != I) FAILURE + +#define CHECK64(D,I) \ + if ((__builtin_signbitd64 (D) != 0) != I) FAILURE + +#define CHECK128(D,I) \ + if ((__builtin_signbitd128 (D) != 0) != I) FAILURE + +/* Prevent the compiler from folding the calls at compile time. */ +volatile _Decimal32 sd; +volatile _Decimal64 dd; +volatile _Decimal128 td; + +int +main () +{ + sd = 1.9df; CHECK32 (sd, 0) + sd = -5.3df; CHECK32 (sd, 1) + sd = 0.0df; CHECK32 (sd, 0) + sd = -0.0df; CHECK32 (sd, 1) + + dd = 1.9dd; CHECK64 (dd, 0) + dd = -5.3dd; CHECK64 (dd, 1) + dd = 0.0dd; CHECK64 (dd, 0) + dd = -0.0dd; CHECK64 (dd, 1) + + td = 1.9dl; CHECK128 (td, 0) + td = -5.3dl; CHECK128 (td, 1) + td = 0.0dl; CHECK128 (td, 0) + td = -0.0dl; CHECK128 (td, 1) + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/signbit-2.c b/gcc/testsuite/c-c++-common/dfp/signbit-2.c new file mode 100644 index 00000000000..e51bf918bf4 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/signbit-2.c @@ -0,0 +1,33 @@ +/* { dg-options "-O0" } */ + +/* Check that the compiler uses builtins for signbit; if not the link + will fail because library functions are in libm. */ + +#include "dfp-dbg.h" + +volatile _Decimal32 sd = 2.3df; +volatile _Decimal64 dd = -4.5dd; +volatile _Decimal128 tf = 5.3dl; +volatile float f = 1.2f; +volatile double d = -7.8; +volatile long double ld = 3.4L; + +EXTERN int signbitf (float); +EXTERN int signbit (double); +EXTERN int signbitl (long double); +EXTERN int signbitd32 (_Decimal32); +EXTERN int signbitd64 (_Decimal64); +EXTERN int signbitd128 (_Decimal128); + +int +main () +{ + if (signbitf (f) != 0) FAILURE + if (signbit (d) == 0) FAILURE + if (signbitl (ld) != 0) FAILURE + if (signbitd32 (sd) != 0) FAILURE + if (signbitd64 (dd) == 0) FAILURE + if (signbitd128 (tf) != 0) FAILURE + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/struct-layout-1.c b/gcc/testsuite/c-c++-common/dfp/struct-layout-1.c new file mode 100644 index 00000000000..2a9d7304fd1 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/struct-layout-1.c @@ -0,0 +1,71 @@ +#include +#include "dfp-dbg.h" + +struct S1 +{ + _Decimal64 a[0]; +}; + +struct S2 +{ + struct + { + _Decimal64 e; + } b[0]; +}; + +struct S3 +{ + union + { + _Decimal64 c; + } a[0]; +}; + +struct S4 +{ + int a[0]; + _Decimal64 b[0]; +}; + +struct S5 +{ + union + { + _Decimal64 c[0]; + } a; +}; + +int check_var (int z, ...) +{ + long long result; + va_list ap; + va_start (ap, z); + va_arg (ap, struct S1); + result = va_arg (ap, long long); + va_end (ap); + + return (result == 2LL); +} + +int main () +{ + struct S1 s1; + struct S2 s2; + struct S3 s3; + struct S4 s4; + struct S5 s5; + + if (check_var (2, s1, 2LL) == 0) + FAILURE; + if (check_var (2, s2, 2LL) == 0) + FAILURE; + if (check_var (2, s3, 2LL) == 0) + FAILURE; + if (check_var (2, s4, 2LL) == 0) + FAILURE; + if (check_var (2, s5, 2LL) == 0) + FAILURE; + + FINISH +} diff --git a/gcc/testsuite/c-c++-common/dfp/usual-arith-conv-const.c b/gcc/testsuite/c-c++-common/dfp/usual-arith-conv-const.c new file mode 100644 index 00000000000..2d72bba4235 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/usual-arith-conv-const.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ + +/* Test various conversions involving decimal floating types. */ + +#include "dfp-dbg.h" + +/* Assertion that constant C is of type T. */ +#define ASSERT_CONST_TYPE(C, T) \ + do { \ + typedef T type; \ + typedef type **typepp; \ + typedef __typeof__((C)) ctype; \ + typedef ctype **ctypepp; \ + typepp x = 0; \ + ctypepp y = 0; \ + x = y; \ + y = x; \ + } while (0) + +int +main () +{ + ASSERT_CONST_TYPE (3 + 2.1df, _Decimal32); /* { dg-bogus "assignment from incompatible pointer type" } */ + ASSERT_CONST_TYPE (1.3df + 2, _Decimal32); /* { dg-bogus "assignment from incompatible pointer type" } */ + ASSERT_CONST_TYPE (56U - 55.0dd, _Decimal64); /* { dg-bogus "assignment from incompatible pointer type" } */ + ASSERT_CONST_TYPE (5 * .2DL, _Decimal128); /* { dg-bogus "assignment from incompatible pointer type" } */ + ASSERT_CONST_TYPE (.88dl / 2L, _Decimal128); /* { dg-bogus "assignment from incompatible pointer type" } */ + ASSERT_CONST_TYPE (.114df - 1.6dd, _Decimal64); /* { dg-bogus "assignment from incompatible pointer type" } */ + ASSERT_CONST_TYPE (3L - 1 + .55df, _Decimal32); /* { dg-bogus "assignment from incompatible pointer type" } */ + + return 0; +} diff --git a/gcc/testsuite/c-c++-common/dfp/usual-arith-conv.c b/gcc/testsuite/c-c++-common/dfp/usual-arith-conv.c new file mode 100644 index 00000000000..baff06bc175 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dfp/usual-arith-conv.c @@ -0,0 +1,117 @@ +/* { dg-options "-O0" } */ + +/* N1150 5.4: Usual arithmetic conversions. + C99 6.3.1.8[1] (New). + + Test arithmetic operators with different decimal float types, and + between decimal float types and integer types. */ + +#include "dfp-dbg.h" + +volatile _Decimal32 d32a, d32b, d32c; +volatile _Decimal64 d64a, d64b, d64c; +volatile _Decimal128 d128a, d128b, d128c; +volatile int i; + +void +init () +{ + d32b = 123.456e94df; + d64b = 12.3456789012345e383dd; + d128b = 12345.6789012345678901e4000dl; + + d32c = 1.3df; + d64c = 1.2dd; + d128c = 1.1dl; + + i = 2; +} + +int +main () +{ + init (); + + /* Usual arithmetic conversions between decimal float types; addition. */ + d128a = d128b + d32b; + if (d128a < d128b) + FAILURE + d128a = d32b + d128b; + if (d128a < d128b) + FAILURE + d128a = d128b + d64b; + if (d128a < d128b) + FAILURE + d128a = d64b + d128b; + if (d128a < d128b) + FAILURE + d64a = d64b + d32b; + if (d64a < d64b) + FAILURE + d64a = d32b + d64b; + if (d64a < d64b) + FAILURE + + /* Usual arithmetic conversions between decimal float types; + multiplication. */ + d128a = d128b * d32c; + if (d128a < d128b) + FAILURE + d128a = d32c * d128b; + if (d128a < d128b) + FAILURE + d128a = d128b * d64c; + if (d128a < d128b) + FAILURE + d128a = d64c * d128b; + if (d128a < d128b) + FAILURE + d64a = d64b * d32c; + if (d64a < d64b) + FAILURE + d64a = d32c * d64b; + if (d64a < d64b) + FAILURE + + /* Usual arithmetic conversions between decimal float and integer types. */ + d32a = d32c + i; + if (d32a != d32c + 2.0df) + FAILURE + d32a = d32c - i; + if (d32a != d32c - 2.0df) + FAILURE + d32a = i * d32c; + if (d32a != d32c + d32c) + FAILURE + d32a = d32c / i; + if (d32a != d32c / 2.0df) + FAILURE + + d64a = i + d64c; + if (d64a != d64c + 2.0dd) + FAILURE + d64a = d64c - i; + if (d64a != d64c - 2.0dd) + FAILURE + d64a = d64c * i; + if (d64a != d64c + d64c) + FAILURE + d64a = d64c / i; + if (d64a != d64c / 2.0dd) + FAILURE + + d128a = d128c + i; + if (d128a != d128c + 2.0dl) + FAILURE + d128a = d128c - i; + if (d128a != d128c - 2.0dl) + FAILURE + d128a = i * d128c; + if (d128a != d128c + d128c) + FAILURE + d128a = d128c / i; + if (d128a != d128c / 2.0dl) + FAILURE + + FINISH +} diff --git a/gcc/testsuite/gcc.dg/dfp/call-by-value.c b/gcc/testsuite/gcc.dg/dfp/call-by-value.c deleted file mode 100644 index 74aec53aefb..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/call-by-value.c +++ /dev/null @@ -1,43 +0,0 @@ -/* C99 6.9.1(9) Function definitions; parameter has automatic storage. - - Test that actual parameters are passed by value and that modifications - made within functions are lost on function return. */ - -#include "dfp-dbg.h" - -int foo32 (_Decimal32 z) -{ - z = z + 1.0df; -} - -int foo64 (_Decimal64 z) -{ - z = z + 1.0dd; -} - -int foo128 (_Decimal128 z) -{ - z = z + 1.0dl; -} - -int -main () -{ - _Decimal32 d32 = 1.1df; - _Decimal64 d64 = 1.2dd; - _Decimal128 d128 = 1.3dl; - - foo32 (d32); - if (d32 != 1.1df) - FAILURE - - foo64 (d64); - if (d64 != 1.2dd) - FAILURE - - foo128 (d128); - if (d128 != 1.3dl) - FAILURE - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/cast.c b/gcc/testsuite/gcc.dg/dfp/cast.c deleted file mode 100644 index b6585d70c8b..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/cast.c +++ /dev/null @@ -1,75 +0,0 @@ -/* C99 6.5.4 Cast operators. - Test valid casts involving decimal float. */ - -#include "dfp-dbg.h" - -_Decimal32 d32; -_Decimal64 d64; -_Decimal128 d128; - -static float f = 2.f; -static double d = 2.l; - -int -main (void) -{ - /* Casts between DFP types. */ - d32 = 1.2df; - d64 = 1.2dd; - d128 = 1.2dl; - - if (d32 != (_Decimal32) d64) - FAILURE - if (d32 != (_Decimal32) d128) - FAILURE - - if (d64 != (_Decimal64) d32) - FAILURE - if (d64 != (_Decimal64) d128) - FAILURE - - if (d128 != (_Decimal128) d32) - FAILURE - if (d128 != (_Decimal128) d64) - FAILURE - - /* Casts between generic and decimal floating point types. Use a - value that we can assume can be represented exactly in all - representations. */ - - d32 = 2.0df; - d64 = 2.0dd; - d128 = 2.0dl; - - /* To generic floating types. */ - if ((float) d32 != 2.0f) - FAILURE - if ((double) d32 != 2.0l) - FAILURE - if ((float) d64 != 2.0f) - FAILURE - if ((double) d64 != 2.0l) - FAILURE - if ((float) d128 != 2.0f) - FAILURE - if ((double) d128 != 2.0l) - FAILURE - - /* float to decimal floating types. */ - if (d32 != (_Decimal32) f) - FAILURE - if (d64 != (_Decimal64) f) - FAILURE - if (d128 != (_Decimal128) f) - FAILURE - - /* double to decimal floating types. */ - if (d32 != (_Decimal32) d) - FAILURE - if (d64 != (_Decimal64) d) - FAILURE - if (d128 != (_Decimal128) d) - FAILURE - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/compare-eq-const.c b/gcc/testsuite/gcc.dg/dfp/compare-eq-const.c deleted file mode 100644 index 0c9ff200b28..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/compare-eq-const.c +++ /dev/null @@ -1,28 +0,0 @@ -/* C99 6.5.9 Equality operators. - Compare decimal float constants against each other. */ - -#include "dfp-dbg.h" - -extern void link_error (void); - -int -main () -{ - /* Compare like-typed positive constants. */ - if (2.0df != 2.0df) - link_error (); - - /* Compare decimal float constants of different types. */ - if (500e-2dl != 0.05e2df) - link_error (); - - /* Binary floating point introduces errors to decimal values. */ - if (1.4 + 1.4 + 1.4 == 4.2) - link_error (); - - /* But, this looks more like what one would expect. */ - if (1.4dd + 1.4dd + 1.4dd != 4.2dd) - link_error (); - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/compare-eq-d128.c b/gcc/testsuite/gcc.dg/dfp/compare-eq-d128.c deleted file mode 100644 index 79fcac3195e..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/compare-eq-d128.c +++ /dev/null @@ -1,14 +0,0 @@ -/* { dg-options "-O0" } */ - -/* C99 6.5.9 Equality operators. - Compare decimal float values against each other at runtime. */ - -#define WIDTH 128 -#include "compare-eq.h" - -int main () -{ - test_compares (); - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/compare-eq-d32.c b/gcc/testsuite/gcc.dg/dfp/compare-eq-d32.c deleted file mode 100644 index 6b1a4c6d7c4..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/compare-eq-d32.c +++ /dev/null @@ -1,14 +0,0 @@ -/* { dg-options "-O0" } */ - -/* C99 6.5.9 Equality operators. - Compare decimal float values against each other at runtime. */ - -#define WIDTH 32 -#include "compare-eq.h" - -int main () -{ - test_compares (); - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/compare-eq-d64.c b/gcc/testsuite/gcc.dg/dfp/compare-eq-d64.c deleted file mode 100644 index f1b463ebe6a..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/compare-eq-d64.c +++ /dev/null @@ -1,14 +0,0 @@ -/* { dg-options "-O0" } */ - -/* C99 6.5.9 Equality operators. - Compare decimal float values against each other at runtime. */ - -#define WIDTH 64 -#include "compare-eq.h" - -int main () -{ - test_compares (); - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/compare-eq-dfp.c b/gcc/testsuite/gcc.dg/dfp/compare-eq-dfp.c deleted file mode 100644 index 79a5691ebfc..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/compare-eq-dfp.c +++ /dev/null @@ -1,53 +0,0 @@ -/* { dg-options "-O0" } */ - -/* C99 6.5.9 Equality operators. - Compare decimal float values against variables of different types. */ - -#include "dfp-dbg.h" - -_Decimal32 d32; -_Decimal64 d64; -_Decimal128 d128; - -/* Use some typedefs of decimal float types, too. */ -typedef _Decimal32 SDtype; -typedef _Decimal64 DDtype; -typedef _Decimal128 TDtype; - -SDtype d32b; -DDtype d64b; -TDtype d128b; - -void -inits (void) -{ - d32 = 1.0df; - d64 = 3.0dd; - d128 = 5.0dl; - d32b = -1.0df; - d64b = -4.0dd; - d128b = -6.0dl; -} - -void -compare_dfp (void) -{ - if ((d32 == d64) != 0) FAILURE - if ((d32 != d128b) != 1) FAILURE - - if ((d64 != d32) != 1) FAILURE - if ((d64 == d128) != 0) FAILURE - - if ((d128 != d32) != 1) FAILURE - if ((d128 == d64) != 0) FAILURE -} - -int -main () -{ - inits (); - - compare_dfp (); - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/compare-eq.h b/gcc/testsuite/gcc.dg/dfp/compare-eq.h deleted file mode 100644 index 830b3289bde..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/compare-eq.h +++ /dev/null @@ -1,92 +0,0 @@ -/* Basic test of runtime equality comparisons using simple values that - are not affected by rounding. */ - -#include -#include "dfp-dbg.h" - -#define PASTE2(A,B) A ## B -#define PASTE(A,B) PASTE2(A,B) - -#undef FAILURE -#ifdef DBG -#define FAILURE(OP,KIND) \ - { printf ("failed at line %d: %s for %s values\n", __LINE__, OP, KIND); \ - failures++; } -#else -#define FAILURE(OP,KIND) __builtin_abort (); -#endif - -#ifndef WIDTH -#error define WIDTH as decimal float size in bytes -#endif - -#if WIDTH == 32 -#define DTYPE _Decimal32 -#define SUFFIX DF -#elif WIDTH == 64 -#define DTYPE _Decimal64 -#define SUFFIX DD -#elif WIDTH == 128 -#define DTYPE _Decimal128 -#define SUFFIX DL -#elif WIDTH == 0 -/* This is for testing the test using a type known to work. */ -#define DTYPE double -#define SUFFIX -#else -#error invalid width for decimal float type -#endif - -DTYPE m_two = PASTE(-2.0, SUFFIX); -DTYPE m_one = PASTE(-1.0, SUFFIX); -DTYPE zero = PASTE(0.0, SUFFIX); -DTYPE one = PASTE(1.0, SUFFIX); -DTYPE two = PASTE(2.0, SUFFIX); - -void -test_compares (void) -{ - DTYPE x = one; - DTYPE y = zero; - DTYPE z = m_one; - - /* Equal to: comparisons against equal values. */ - - if (! (x == one)) FAILURE ("==", "equal") - if (! (y == zero)) FAILURE ("==", "equal") - if (! (z == m_one)) FAILURE ("==", "equal") - - /* Equal to: comparisons against lesser values. */ - - if (x == m_one) FAILURE ("==", "lesser") - if (x == zero) FAILURE ("==", "lesser") - if (y == m_one) FAILURE ("==", "lesser") - if (z == m_two) FAILURE ("==", "lesser") - - /* Equal to: comparisons against greater values. */ - - if (x == two) FAILURE ("==", "greater") - if (y == one) FAILURE ("==", "greater") - if (z == zero) FAILURE ("==", "greater") - if (z == one) FAILURE ("==", "greater") - - /* Not equal to: comparisons against equal values. */ - - if (x != one) FAILURE ("!=", "equal") - if (y != zero) FAILURE ("!=", "equal") - if (z != m_one) FAILURE ("!=", "equal") - - /* Not equal to: comparisons against lesser values. */ - - if (! (x != m_one)) FAILURE ("!=", "lesser") - if (! (x != zero)) FAILURE ("!=", "lesser") - if (! (y != m_one)) FAILURE ("!=", "lesser") - if (! (z != m_two)) FAILURE ("!=", "lesser") - - /* Not equal to: comparisons against greater values. */ - - if (! (x != m_one)) FAILURE ("!=", "greater") - if (! (x != zero)) FAILURE ("!=", "greater") - if (! (y != m_one)) FAILURE ("!=", "greater") - if (! (z != m_two)) FAILURE ("!=", "greater") -} diff --git a/gcc/testsuite/gcc.dg/dfp/compare-rel-const.c b/gcc/testsuite/gcc.dg/dfp/compare-rel-const.c deleted file mode 100644 index 8e99b4466dc..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/compare-rel-const.c +++ /dev/null @@ -1,57 +0,0 @@ -/* C99 6.5.8 Relational operators. - Compare decimal float constants against each other. */ - -extern void link_error (void); - -int -main () -{ - /* Compare like-typed negative constants. */ - if (-2.0dl < -2.0dl) - link_error (); - - /* Compare like-typed constants. */ - if (-2.0dl >= .01dl) - link_error (); - - /* Compare like-typed constants. */ - if (0.2dd > 0.02e1dd) - link_error (); - - /* Compare decimal float constants of different types. */ - if (-.000005dd >= -.0000049DL) - link_error(); - - /* Test use gcc builtins for comparisons. */ - if (__builtin_isless(-2.0dl,-2.0dl)) - link_error(); - - if (__builtin_isgreaterequal(-2.0dl,.01dl)) - link_error(); - - if (!(__builtin_islessequal(-2.0dl, -2.0dd))) - link_error(); - - if (!(__builtin_isgreater(2.0dl, -2.0dd))) - link_error(); - - if (__builtin_islessequal(2.0df, __builtin_nand64(""))) - link_error(); - - if (__builtin_islessgreater(2.0dd, __builtin_nand64(""))) - link_error(); - - if (!__builtin_islessgreater(2.0dd, -2.0dd)) - link_error(); - - if (!__builtin_islessgreater(-3.0dd, 2.0dd)) - link_error(); - - if (__builtin_isunordered(1.1df, 0.003dd)) - link_error(); - - if (!__builtin_isunordered(-3.1df, __builtin_nand32(""))) - link_error(); - - return 0; -} diff --git a/gcc/testsuite/gcc.dg/dfp/compare-rel-d128.c b/gcc/testsuite/gcc.dg/dfp/compare-rel-d128.c deleted file mode 100644 index 38c931a0207..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/compare-rel-d128.c +++ /dev/null @@ -1,14 +0,0 @@ -/* { dg-options "-O0" } */ - -/* C99 6.5.8 Relational operators. - Compare decimal float values against each other at runtime. */ - -#define WIDTH 128 -#include "compare-rel.h" - -int -main () -{ - test_compares (); - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/compare-rel-d32.c b/gcc/testsuite/gcc.dg/dfp/compare-rel-d32.c deleted file mode 100644 index 04128aab924..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/compare-rel-d32.c +++ /dev/null @@ -1,14 +0,0 @@ -/* { dg-options "-O0" } */ - -/* C99 6.5.8 Relational operators. - Compare decimal float values against each other at runtime. */ - -#define WIDTH 32 -#include "compare-rel.h" - -int -main () -{ - test_compares (); - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/compare-rel-d64.c b/gcc/testsuite/gcc.dg/dfp/compare-rel-d64.c deleted file mode 100644 index 92f904a8154..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/compare-rel-d64.c +++ /dev/null @@ -1,14 +0,0 @@ -/* { dg-options "-O0" } */ - -/* C99 6.5.8 Relational operators. - Compare decimal float values against each other at runtime. */ - -#define WIDTH 64 -#include "compare-rel.h" - -int -main () -{ - test_compares (); - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/compare-rel-dfp.c b/gcc/testsuite/gcc.dg/dfp/compare-rel-dfp.c deleted file mode 100644 index 59cc2035306..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/compare-rel-dfp.c +++ /dev/null @@ -1,53 +0,0 @@ -/* { dg-options "-O0" } */ - -/* C99 6.5.8 Relational operators. - Compare decimal float values against variables of different types. */ - -#include "dfp-dbg.h" - -_Decimal32 d32; -_Decimal64 d64; -_Decimal128 d128; - -/* Use some typedefs of decimal float types, too. */ -typedef _Decimal32 SDtype; -typedef _Decimal64 DDtype; -typedef _Decimal128 TDtype; - -SDtype d32b; -DDtype d64b; -TDtype d128b; - -void -inits (void) -{ - d32 = 1.0df; - d64 = 3.0dd; - d128 = 5.0dl; - d32b = -1.0df; - d64b = -4.0dd; - d128b = -6.0dl; -} - -void -compare_dfp (void) -{ - if ((d32 > d64) != 0) FAILURE - if ((d32 >= d128b) != 1) FAILURE - - if ((d64 < d32) != 0) FAILURE - if ((d64 <= d128) != 1) FAILURE - - if ((d128 > d32) != 1) FAILURE - if ((d128 >= d64) != 1) FAILURE -} - -int -main () -{ - inits (); - - compare_dfp (); - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/compare-rel.h b/gcc/testsuite/gcc.dg/dfp/compare-rel.h deleted file mode 100644 index 7840108142d..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/compare-rel.h +++ /dev/null @@ -1,132 +0,0 @@ -/* Basic test of runtime relational comparisons using simple values that - are not affected by rounding. */ - -#include -#include "dfp-dbg.h" - -#undef FAILURE -#ifdef DBG -#define FAILURE(OP,KIND) \ - { printf ("failed at line %d: %s for %s values\n", __LINE__, OP, KIND); \ - failures++; } -#else -#define FAILURE(OP,KIND) __builtin_abort (); -#endif - -#define PASTE2(A,B) A ## B -#define PASTE(A,B) PASTE2(A,B) - -#ifndef WIDTH -#error define WIDTH as decimal float size in bytes -#endif - -#if WIDTH == 32 -#define DTYPE _Decimal32 -#define SUFFIX DF -#elif WIDTH == 64 -#define DTYPE _Decimal64 -#define SUFFIX DD -#elif WIDTH == 128 -#define DTYPE _Decimal128 -#define SUFFIX DL -#elif WIDTH == 0 -/* This is for testing the test using a type known to work. */ -#define DTYPE double -#define SUFFIX -#else -#error invalid width for decimal float type -#endif - -DTYPE m_two = PASTE(-2.0, SUFFIX); -DTYPE m_one = PASTE(-1.0, SUFFIX); -DTYPE zero = PASTE(0.0, SUFFIX); -DTYPE one = PASTE(1.0, SUFFIX); -DTYPE two = PASTE(2.0, SUFFIX); - -void -test_compares (void) -{ - DTYPE x = one; - DTYPE y = zero; - DTYPE z = m_one; - - /* Less than or equal to: comparisons against equal values. */ - - if (! (x <= one)) FAILURE ("<=", "equal") - if (! (y <= zero)) FAILURE ("<=", "equal") - if (! (z <= m_one)) FAILURE ("<=", "equal") - - /* Less than or equal to: comparisons against lesser values. */ - - if (x <= m_one) FAILURE ("<=", "lesser") - if (x <= zero) FAILURE ("<=", "lesser") - if (y <= m_one) FAILURE ("<=", "lesser") - if (z <= m_two) FAILURE ("<=", "lesser") - - /* Less than or equal to: comparisons against greater values. */ - - if (! (x <= two)) FAILURE ("<=", "greater") - if (! (y <= one)) FAILURE ("<=", "greater") - if (! (z <= zero)) FAILURE ("<=", "greater") - if (! (z <= one)) FAILURE ("<=", "greater") - - /* Less than: comparisons against equal values. */ - - if (x < one) FAILURE ("<", "equal") - if (y < zero) FAILURE ("<", "equal") - if (z < m_one) FAILURE ("<", "equal") - - /* Less than: comparisons against lesser values. */ - - if (x < m_one) FAILURE ("<", "lesser") - if (x < zero) FAILURE ("<", "lesser") - if (y < m_one) FAILURE ("<", "lesser") - if (z < m_two) FAILURE ("<", "lesser") - - /* Less than: comparisons against greater values. */ - - if (! (x < two)) FAILURE ("<", "greater") - if (! (y < one)) FAILURE ("<", "greater") - if (! (z < zero)) FAILURE ("<", "greater") - if (! (z < one)) FAILURE ("<", "greater") - - /* Greater than or equal to: comparisons against equal values. */ - - if (! (x >= one)) FAILURE (">=", "equal") - if (! (y >= zero)) FAILURE (">=", "equal") - if (! (z >= m_one)) FAILURE (">=", "equal") - - /* Greater than or equal to: comparisons against lesser values. */ - - if (! (x >= m_one)) FAILURE (">=", "lesser") - if (! (x >= zero)) FAILURE (">=", "lesser") - if (! (y >= m_one)) FAILURE (">=", "lesser") - if (! (z >= m_two)) FAILURE (">=", "lesser") - - /* Greater than or equal to: comparisons against greater values. */ - - if (x >= two) FAILURE (">=", "greater") - if (y >= one) FAILURE (">=", "greater") - if (z >= zero) FAILURE (">=", "greater") - if (z >= one) FAILURE (">=", "greater") - - /* Greater than: comparisons against equal values. */ - - if (x > one) FAILURE (">", "equal") - if (y > zero) FAILURE (">", "equal") - if (z > m_one) FAILURE (">", "equal") - - /* Greater than: comparisons against lesser values. */ - - if (! (x > m_one)) FAILURE (">", "lesser") - if (! (x > zero)) FAILURE (">", "lesser") - if (! (y > m_one)) FAILURE (">", "lesser") - if (! (z > m_two)) FAILURE (">", "lesser") - - /* Greater than: comparisons against greater values. */ - - if (x > two) FAILURE (">", "greater") - if (y > one) FAILURE (">", "greater") - if (z > zero) FAILURE (">", "greater") - if (z > one) FAILURE (">", "greater") -} diff --git a/gcc/testsuite/gcc.dg/dfp/compare-special-d128.c b/gcc/testsuite/gcc.dg/dfp/compare-special-d128.c deleted file mode 100644 index d1f5bc5edd4..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/compare-special-d128.c +++ /dev/null @@ -1,15 +0,0 @@ -/* { dg-options "-O0" } */ - -/* C99 6.5.8 Relational operators. - C99 6.5.9 Equality operators. - Compare decimal float special values at runtime. */ - -#define WIDTH 128 -#include "compare-special.h" - -int -main () -{ - test_compares (); - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/compare-special-d32.c b/gcc/testsuite/gcc.dg/dfp/compare-special-d32.c deleted file mode 100644 index 377c65a5bb7..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/compare-special-d32.c +++ /dev/null @@ -1,15 +0,0 @@ -/* { dg-options "-O0" } */ - -/* C99 6.5.8 Relational operators. - C99 6.5.9 Equality operators. - Compare decimal float special values at runtime. */ - -#define WIDTH 32 -#include "compare-special.h" - -int -main () -{ - test_compares (); - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/compare-special-d64.c b/gcc/testsuite/gcc.dg/dfp/compare-special-d64.c deleted file mode 100644 index 16154eff323..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/compare-special-d64.c +++ /dev/null @@ -1,15 +0,0 @@ -/* { dg-options "-O0" } */ - -/* C99 6.5.8 Relational operators. - C99 6.5.9 Equality operators. - Compare decimal float special values at runtime. */ - -#define WIDTH 64 -#include "compare-special.h" - -int -main () -{ - test_compares (); - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/compare-special.h b/gcc/testsuite/gcc.dg/dfp/compare-special.h deleted file mode 100644 index 9c27d126c29..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/compare-special.h +++ /dev/null @@ -1,284 +0,0 @@ -/* Basic test of runtime relational comparisons using NaNs and infinities. */ - -#include -#include "dfp-dbg.h" - -#define PASTE2(A,B) A ## B -#define PASTE(A,B) PASTE2(A,B) - -/* Override FAILURE from dfp-dbg.h with one that provides additional info. */ -#undef FAILURE -#ifdef DBG -#define FAILURE(OP,KIND) \ - { printf ("failed at line %d: %s for %s values\n", __LINE__, OP, KIND); \ - failures++; } -#else -#define FAILURE(OP,KIND) __builtin_abort (); -#endif - -#ifndef WIDTH -#error define WIDTH as decimal float size in bytes -#endif - -#if WIDTH == 32 -#define DTYPE _Decimal32 -#define SUFFIX DF -#define SUFFIX2 d32 -#elif WIDTH == 64 -#define DTYPE _Decimal64 -#define SUFFIX DD -#define SUFFIX2 d64 -#elif WIDTH == 128 -#define DTYPE _Decimal128 -#define SUFFIX DL -#define SUFFIX2 d128 -#elif WIDTH == 0 -/* This is for testing the test using a type known to work. */ -#define DTYPE double -#define SUFFIX -#define SUFFIX2 -#else -#error invalid width for decimal float type -#endif - -DTYPE m_two = PASTE(-2.0, SUFFIX); -DTYPE m_one = PASTE(-1.0, SUFFIX); -DTYPE zero = PASTE(0.0, SUFFIX); -DTYPE one = PASTE(1.0, SUFFIX); -DTYPE two = PASTE(2.0, SUFFIX); - -volatile DTYPE x, y, z, _nan, inf, m_inf; - -void -test_compares (void) -{ - _nan = PASTE(__builtin_nan, SUFFIX2) (""); - inf = PASTE(__builtin_inf, SUFFIX2) (); - m_inf = - PASTE(__builtin_inf, SUFFIX2) (); - - x = PASTE(__builtin_nan, SUFFIX2) (""); - y = PASTE(__builtin_inf, SUFFIX2) (); - z = - PASTE(__builtin_inf, SUFFIX2) (); - - /* Less than or equal to with NaN. */ - - if (x <= two) FAILURE ("<=", "NaN") - if (x <= zero) FAILURE ("<=", "NaN") - if (x <= m_one) FAILURE ("<=", "NaN") - if (x <= _nan) FAILURE ("<=", "NaN") - if (x <= inf) FAILURE ("<=", "NaN") - if (x <= m_inf) FAILURE ("<=", "NaN") - - if (two <= x) FAILURE ("<=", "NaN") - if (zero <= x) FAILURE ("<=", "NaN") - if (m_one <= x) FAILURE ("<=", "NaN") - if (_nan <= x) FAILURE ("<=", "NaN") - if (inf <= x) FAILURE ("<=", "NaN") - if (m_inf <= x) FAILURE ("<=", "NaN") - - /* Less than or equal to with infinities, no NaNs. */ - - if (y <= two) FAILURE ("<=", "inf") - if (y <= zero) FAILURE ("<=", "inf") - if (y <= m_one) FAILURE ("<=", "inf") - if (!(two <= y)) FAILURE ("<=", "inf") - if (!(zero <= y)) FAILURE ("<=", "inf") - if (!(m_one <= y)) FAILURE ("<=", "inf") - - if (!(z <= two)) FAILURE ("<=", "-inf") - if (!(z <= zero)) FAILURE ("<=", "-inf") - if (!(z <= m_one)) FAILURE ("<=", "-inf") - if (two <= z) FAILURE ("<=", "-inf") - if (zero <= z) FAILURE ("<=", "-inf") - if (m_one <= z) FAILURE ("<=", "-inf") - - if (!(y <= inf)) FAILURE ("<=", "inf") - if (y <= m_inf) FAILURE ("<=", "inf") - if (!(z <= inf)) FAILURE ("<=", "inf") - if (!(z <= m_inf)) FAILURE ("<=", "inf") - - /* Less than with NaN. */ - - if (x < two) FAILURE ("<", "NaN") - if (x < zero) FAILURE ("<", "NaN") - if (x < m_one) FAILURE ("<", "NaN") - if (x < _nan) FAILURE ("<", "NaN") - if (x < inf) FAILURE ("<", "NaN") - if (x < m_inf) FAILURE ("<", "NaN") - - if (two < x) FAILURE ("<", "NaN") - if (zero < x) FAILURE ("<", "NaN") - if (m_one < x) FAILURE ("<", "NaN") - if (_nan < x) FAILURE ("<", "NaN") - if (inf < x) FAILURE ("<", "NaN") - if (m_inf < x) FAILURE ("<", "NaN") - - /* Less than with infinities, no NaNs. */ - - if (y < two) FAILURE ("<", "inf") - if (y < zero) FAILURE ("<", "inf") - if (y < m_one) FAILURE ("<", "inf") - if (!(two < y)) FAILURE ("<", "inf") - if (!(zero < y)) FAILURE ("<", "inf") - if (!(m_one < y)) FAILURE ("<", "inf") - - if (!(z < two)) FAILURE ("<", "-inf") - if (!(z < zero)) FAILURE ("<", "-inf") - if (!(z < m_one)) FAILURE ("<", "-inf") - if (two < z) FAILURE ("<", "-inf") - if (zero < z) FAILURE ("<", "-inf") - if (m_one < z) FAILURE ("<", "-inf") - - if (y < inf) FAILURE ("<=", "inf") - if (y < m_inf) FAILURE ("<=", "inf") - if (!(z < inf)) FAILURE ("<=", "inf") - if (z < m_inf) FAILURE ("<=", "inf") - - /* Greater than or equal to with NaN. */ - - if (x >= two) FAILURE (">=", "NaN") - if (x >= zero) FAILURE (">=", "NaN") - if (x >= m_one) FAILURE (">=", "NaN") - if (x >= _nan) FAILURE (">=", "NaN") - if (x >= inf) FAILURE (">=", "NaN") - if (x >= m_inf) FAILURE (">=", "NaN") - - if (two >= x) FAILURE (">=", "NaN") - if (zero >= x) FAILURE (">=", "NaN") - if (m_one >= x) FAILURE (">=", "NaN") - if (_nan >= x) FAILURE (">=", "NaN") - if (inf >= x) FAILURE (">=", "NaN") - if (m_inf >= x) FAILURE (">=", "NaN") - - /* Greater than or equal to with infinities, no NaNs. */ - - if (!(y >= two)) FAILURE (">=", "inf") - if (!(y >= zero)) FAILURE (">=", "inf") - if (!(y >= m_one)) FAILURE (">=", "inf") - if (two >= y) FAILURE (">=", "inf") - if (zero >= y) FAILURE (">=", "inf") - if (m_one >= y) FAILURE (">=", "inf") - - if (z >= two) FAILURE (">=", "-inf") - if (z >= zero) FAILURE (">=", "-inf") - if (z >= m_one) FAILURE (">=", "-inf") - if (!(two >= z)) FAILURE (">=", "-inf") - if (!(zero >= z)) FAILURE (">=", "-inf") - if (!(m_one >= z)) FAILURE (">=", "-inf") - - if (!(y >= inf)) FAILURE ("<=", "inf") - if (!(y >= m_inf)) FAILURE ("<=", "inf") - if (z >= inf) FAILURE ("<=", "inf") - if (!(z >= m_inf)) FAILURE ("<=", "inf") - - /* Greater than with NaN. */ - - if (x > two) FAILURE (">", "NaN") - if (x > zero) FAILURE (">", "NaN") - if (x > m_one) FAILURE (">", "NaN") - if (x > _nan) FAILURE (">", "NaN") - if (x > inf) FAILURE (">", "NaN") - if (x > m_inf) FAILURE (">", "NaN") - - if (two > x) FAILURE (">", "NaN") - if (zero > x) FAILURE (">", "NaN") - if (m_one > x) FAILURE (">", "NaN") - if (_nan > x) FAILURE (">", "NaN") - if (inf > x) FAILURE (">", "NaN") - if (m_inf > x) FAILURE (">", "NaN") - - /* Greater than with infinities, no NaNs. */ - - if (!(y > two)) FAILURE (">", "inf") - if (!(y > zero)) FAILURE (">", "inf") - if (!(y > m_one)) FAILURE (">", "inf") - if (two > y) FAILURE (">", "inf") - if (zero > y) FAILURE (">", "inf") - if (m_one > y) FAILURE (">", "inf") - - if (z > two) FAILURE (">", "-inf") - if (z > zero) FAILURE (">", "-inf") - if (z > m_one) FAILURE (">", "-inf") - if (!(two > z)) FAILURE (">", "-inf") - if (!(zero > z)) FAILURE (">", "-inf") - if (!(m_one > z)) FAILURE (">", "-inf") - - if (y > inf) FAILURE (">", "inf") - if (!(y > m_inf)) FAILURE (">", "inf") - if (z > inf) FAILURE (">", "inf") - if (z > m_inf) FAILURE (">", "inf") - - /* Equal with NaN. */ - - if (x == two) FAILURE ("==", "NaN") - if (x == zero) FAILURE ("==", "NaN") - if (x == m_one) FAILURE ("==", "NaN") - if (x == _nan) FAILURE ("==", "NaN") - if (x == inf) FAILURE ("==", "NaN") - if (x == m_inf) FAILURE ("==", "NaN") - - if (two == x) FAILURE ("==", "NaN") - if (zero == x) FAILURE ("==", "NaN") - if (m_one == x) FAILURE ("==", "NaN") - if (_nan == x) FAILURE ("==", "NaN") - if (inf == x) FAILURE ("==", "NaN") - if (m_inf == x) FAILURE ("==", "NaN") - - /* Equal with infinities, no NaNs. */ - - if (y == two) FAILURE ("==", "inf") - if (y == zero) FAILURE ("==", "inf") - if (y == m_one) FAILURE ("==", "inf") - if (two == y) FAILURE ("==", "inf") - if (zero == y) FAILURE ("==", "inf") - if (m_one == y) FAILURE ("==", "inf") - - if (z == two) FAILURE ("==", "-inf") - if (z == zero) FAILURE ("==", "-inf") - if (z == m_one) FAILURE ("==", "-inf") - if (two == z) FAILURE ("==", "-inf") - if (zero == z) FAILURE ("==", "-inf") - if (m_one == z) FAILURE ("==", "-inf") - - if (!(y == inf)) FAILURE ("==", "inf") - if (y == m_inf) FAILURE ("==", "inf") - if (z == inf) FAILURE ("==", "inf") - if (!(z == m_inf)) FAILURE ("==", "inf") - - /* Not equal with NaN. */ - - if (!(x != two)) FAILURE ("!=", "NaN") - if (!(x != zero)) FAILURE ("!=", "NaN") - if (!(x != m_one)) FAILURE ("!=", "NaN") - if (!(x != _nan)) FAILURE ("!=", "NaN") - if (!(x != inf)) FAILURE ("!=", "NaN") - if (!(x != m_inf)) FAILURE ("!=", "NaN") - - if (!(two != x)) FAILURE ("!=", "NaN") - if (!(zero != x)) FAILURE ("!=", "NaN") - if (!(m_one != x)) FAILURE ("!=", "NaN") - if (!(_nan != x)) FAILURE ("!=", "NaN") - if (!(inf != x)) FAILURE ("!=", "NaN") - if (!(m_inf != x)) FAILURE ("!=", "NaN") - - /* Not equal with infinities, no NaNs. */ - - if (!(y != two)) FAILURE ("!=", "inf") - if (!(y != zero)) FAILURE ("!=", "inf") - if (!(y != m_one)) FAILURE ("!=", "inf") - if (!(two != y)) FAILURE ("!=", "inf") - if (!(zero != y)) FAILURE ("!=", "inf") - if (!(m_one != y)) FAILURE ("!=", "inf") - - if (!(z != two)) FAILURE ("!=", "-inf") - if (!(z != zero)) FAILURE ("!=", "-inf") - if (!(z != m_one)) FAILURE ("!=", "-inf") - if (!(two != z)) FAILURE ("!=", "-inf") - if (!(zero != z)) FAILURE ("!=", "-inf") - if (!(m_one != z)) FAILURE ("!=", "-inf") - - if (y != inf) FAILURE ("!=", "inf") - if (!(y != m_inf)) FAILURE ("!=", "inf") - if (!(z != inf)) FAILURE ("!=", "inf") - if (z != m_inf) FAILURE ("!=", "inf") -} diff --git a/gcc/testsuite/gcc.dg/dfp/constants-zero.c b/gcc/testsuite/gcc.dg/dfp/constants-zero.c deleted file mode 100644 index 64b0054d2d3..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/constants-zero.c +++ /dev/null @@ -1,159 +0,0 @@ -/* { dg-options "-O0" } */ - -/* Decimal float values can have significant trailing zeroes. This is - true for zero values as well. Check that various representations of - zero are handled correctly when specified as literal constants. */ - -#include "dfp-dbg.h" - -int big_endian; - -typedef union U32 { - unsigned int i; - _Decimal32 d; - unsigned char b[4]; -} u32_t; - -typedef union U64 { - unsigned long long i; - _Decimal64 d; -} u64_t; - -typedef union U128 { - unsigned long long i[2]; - _Decimal128 d; -} u128_t; - -int -compare32 (_Decimal32 d, unsigned int i) -{ - u32_t u; - - u.d = d; - return (u.i == i); -} - -int -compare64 (_Decimal64 d, unsigned long long i) -{ - u64_t u; - - u.d = d; - return (u.i == i); -} - -int -compare128 (_Decimal64 d, unsigned long long i, unsigned long long j) -{ - u128_t u; - - u.d = d; - if (big_endian) - return (u.i[0] == i && u.i[1] == j); - else - return (u.i[1] == i && u.i[0] == j); -} - -void -dpd_tests (void) -{ - if (! compare32 (0.DF, 0x22500000U)) - FAILURE - if (! compare32 (-0.DF, 0xa2500000U)) - FAILURE - if (! compare32 (0.E-4DF, 0x22100000U)) - FAILURE - if (! compare32 (0.E-7DF, 0x21e00000U)) - FAILURE - if (! compare32 (0.E+3DF, 0x22800000U)) - FAILURE - - if (! compare64 (0.DD, 0x2238000000000000ULL)) - FAILURE - if (! compare64 (-0.DD, 0xa238000000000000ULL)) - FAILURE - if (! compare64 (0.E-6DD, 0x2220000000000000ULL)) - FAILURE - if (! compare64 (0.E-7DD, 0x221c000000000000ULL)) - FAILURE - if (! compare64 (0.E+2DD, 0x2240000000000000ULL)) - FAILURE - - if (! compare128 (0.DL, 0x2208000000000000ULL, 0x0000000000000000ULL)) - FAILURE - if (! compare128 (-0.DL, 0xa208000000000000ULL, 0x0000000000000000ULL)) - FAILURE - if (! compare128 (0.E-3DL, 0x2207400000000000ULL, 0x0000000000000000ULL)) - FAILURE - if (! compare128 (0.E-8DL, 0x2206000000000000ULL, 0x0000000000000000ULL)) - FAILURE - if (! compare128 (0.E+2DL, 0x2208800000000000ULL, 0x0000000000000000ULL)) - FAILURE -} - -void -bid_tests (void) -{ - if (! compare32 (0.DF, 0x32800000U)) - FAILURE - if (! compare32 (-0.DF, 0xb2800000U)) - FAILURE - if (! compare32 (0.E-4DF, 0x30800000U)) - FAILURE - if (! compare32 (0.E-7DF, 0x2f000000U)) - FAILURE - if (! compare32 (0.E+3DF, 0x34000000U)) - FAILURE - - if (! compare64 (0.DD, 0x31c0000000000000ULL)) - FAILURE - if (! compare64 (-0.DD, 0xb1c0000000000000ULL)) - FAILURE - if (! compare64 (0.E-6DD, 0x3100000000000000ULL)) - FAILURE - if (! compare64 (0.E-7DD, 0x30e0000000000000ULL)) - FAILURE - if (! compare64 (0.E+2DD, 0x3200000000000000ULL)) - FAILURE - - if (! compare128 (0.DL, 0x3040000000000000ULL, 0x0000000000000000ULL)) - FAILURE - if (! compare128 (-0.DL, 0xb040000000000000ULL, 0x0000000000000000ULL)) - FAILURE - if (! compare128 (0.E-3DL, 0x303a000000000000ULL, 0x0000000000000000ULL)) - FAILURE - if (! compare128 (0.E-8DL, 0x3030000000000000ULL, 0x0000000000000000ULL)) - FAILURE - if (! compare128 (0.E+2DL, 0x3044000000000000ULL, 0x0000000000000000ULL)) - FAILURE -} - -int -main () -{ - u32_t u32; - - /* These sizes are probably always true for targets that support decimal - float types, but check anyway. Abort so we can fix the test. */ - if ((sizeof (_Decimal64) != sizeof (long long)) - || (sizeof (_Decimal128) != 2 * sizeof (long long)) - || (sizeof (_Decimal32) != sizeof (_Decimal32))) - FAILURE - - u32.d = 1.DF; - - if (u32.i == 0x22500001) - { - big_endian = (u32.b[0] == 0x22); - dpd_tests (); - } - else if (u32.i == 0x32800001) - { - big_endian = (u32.b[0] == 0x32); - bid_tests (); - } - else - FAILURE /* unknown format; test problem */ - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/convert-bfp-10.c b/gcc/testsuite/gcc.dg/dfp/convert-bfp-10.c deleted file mode 100644 index 3fef98a3384..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/convert-bfp-10.c +++ /dev/null @@ -1,107 +0,0 @@ -/* This test assumes IEEE float and double. */ - -#include "convert.h" - -volatile _Decimal32 sd; -volatile _Decimal64 dd; -volatile _Decimal128 td; -volatile float sf; -volatile double df; - -/* Conversions using denormalized float values. */ -CONVERT_VALID (111, sf, sd, 1.2e-38f, 1.2e-38df, 0.df) -CONVERT_VALID (112, sf, sd, 1.1e-38f, 1.1e-38df, 0.df) -CONVERT_VALID (113, sf, sd, 1.1e-40f, 1.1e-40df, 1.1e-45df) - -CONVERT_VALID (121, sd, sf, 1.2e-38df, 1.2e-38f, 0.f) -CONVERT_VALID (122, sd, sf, 1.1e-38df, 1.1e-38f, 0.f) - -CONVERT_VALID (131, sf, sd, -1.2e-38f, -1.2e-38df, 0.df) -CONVERT_VALID (132, sf, sd, -1.1e-38f, -1.1e-38df, 0.df) - -CONVERT_VALID (141, sd, sf, -1.2e-38df, -1.2e-38f, 0.f) -CONVERT_VALID (142, sd, sf, -1.1e-38df, -1.1e-38f, 0.f) - -/* Conversions using denormalized double values. */ -CONVERT_VALID (211, df, sd, 1.2e-38, 1.2e-38df, 0.df) -CONVERT_VALID (212, df, sd, 1.1e-38, 1.1e-38df, 0.df) -CONVERT_VALID (213, df, sd, 1.e-40, 1.e-40df, 0.df) -CONVERT_VALID (214, df, sd, 8.e-44, 8.e-44df, 0.df) -CONVERT_VALID (215, df, sd, 9.e-44, 9.e-44df, 0.df) -CONVERT_VALID (216, df, sd, 8.e-46, 8.e-46df, 0.df) -CONVERT_VALID (217, df, sd, 7.e-46, 7.e-46df, 0.df) - -CONVERT_VALID (221, sd, df, 1.2e-38df, 1.2e-38, 1.e-53) -CONVERT_VALID (222, sd, df, 1.1e-38df, 1.1e-38, 1.e-53) -CONVERT_VALID (223, sd, df, 1.e-40df, 1.e-40, 0.) -CONVERT_VALID (224, sd, df, 8.e-44df, 8.e-44, 0.) -CONVERT_VALID (225, sd, df, 9.e-44df, 9.e-44, 0.) -CONVERT_VALID (226, sd, df, 8.e-46df, 8.e-46, 0.) -CONVERT_VALID (227, sd, df, 7.e-46df, 7.e-46, 0.) - -CONVERT_VALID (231, df, sd, -1.2e-38, -1.2e-38df, 0.df) -CONVERT_VALID (232, df, sd, -1.1e-38f, -1.1e-38df, 0.df) -CONVERT_VALID (233, df, sd, -1.e-40, -1.e-40df, 0.df) -CONVERT_VALID (234, df, sd, -8.e-44, -8.e-44df, 0.df) -CONVERT_VALID (235, df, sd, -9.e-44, -9.e-44df, 0.df) -CONVERT_VALID (236, df, sd, -8.e-46, -8.e-46df, 0.df) -CONVERT_VALID (237, df, sd, -7.e-46, -7.e-46df, 0.df) - -CONVERT_VALID (241, sd, df, -1.2e-38df, -1.2e-38, 1.e-53) -CONVERT_VALID (242, sd, df, -1.1e-38df, -1.1e-38, 1.e-53) -CONVERT_VALID (243, sd, df, -1.e-40df, -1.e-40, 0.) -CONVERT_VALID (244, sd, df, -8.e-44df, -8.e-44, 0.) -CONVERT_VALID (245, sd, df, -9.e-44df, -9.e-44, 0.) -CONVERT_VALID (246, sd, df, -8.e-46df, -8.e-46, 0.) -CONVERT_VALID (247, sd, df, -7.e-46df, -7.e-46, 0.) - -int -main () -{ - convert_111 (); - convert_112 (); - convert_113 (); - - convert_121 (); - convert_122 (); - - convert_131 (); - convert_132 (); - - convert_141 (); - convert_142 (); - - convert_211 (); - convert_212 (); - convert_213 (); - convert_214 (); - convert_215 (); - convert_216 (); - convert_217 (); - - convert_221 (); - convert_222 (); - convert_223 (); - convert_224 (); - convert_225 (); - convert_226 (); - convert_227 (); - - convert_231 (); - convert_232 (); - convert_233 (); - convert_234 (); - convert_235 (); - convert_236 (); - convert_237 (); - - convert_241 (); - convert_242 (); - convert_243 (); - convert_244 (); - convert_245 (); - convert_246 (); - convert_247 (); - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/convert-bfp-11.c b/gcc/testsuite/gcc.dg/dfp/convert-bfp-11.c deleted file mode 100644 index d16919f81ac..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/convert-bfp-11.c +++ /dev/null @@ -1,58 +0,0 @@ -/* { dg-skip-if "" { ! "powerpc*-*-linux*" } { "*" } { "" } } */ - -/* Test decimal float conversions to and from IBM 128-bit long double. - Checks are skipped at runtime if long double is not 128 bits. - Don't force 128-bit long doubles because runtime support depends - on glibc. */ - -#include "convert.h" - -volatile _Decimal32 sd; -volatile _Decimal64 dd; -volatile _Decimal128 td; -volatile float sf; -volatile double df; -volatile long double tf; - -/* A value slightly less than DEC32_MAX can be converted in both directions. */ -CONVERT_VALID (101, sd, tf, 9.999998e96df, 9.999998e96L, 1.e+81L) -CONVERT_VALID (102, tf, sd, 9.999998e96L, 9.999998e96df, 0.df) - -/* A value slightly less than DBL_MAX can be converted in both directions. */ -CONVERT_VALID (201, tf, dd, 1.79768e+308l, 1.79768e+308dd, 0.dd) -CONVERT_VALID (202, dd, tf, 1.79768e+308dd, 1.79768e+308l, 2.e292l) -CONVERT_VALID (203, tf, td, 1.79768e+308l, 1.79768e+308dl, 1.e292dl) -CONVERT_VALID (204, td, tf, 1.79768e+308dl, 1.79768e+308l, 2.e292l) - -/* Check values that are too large for the result type. */ -CONVERT_TO_PINF (301, dd, tf, 1.8e+308dd, l) -CONVERT_TO_PINF (302, dd, tf, 9.9e+384dd, l) -CONVERT_TO_PINF (303, td, tf, 1.8e+308dl, l) -CONVERT_TO_PINF (304, td, tf, 9.9e+384dl, l) - -CONVERT_TO_PINF (311, tf, sd, 1.0e+97L, d32) -CONVERT_TO_PINF (312, tf, sd, 1.6e+308L, d32) - -int -main () -{ - if (sizeof (long double) != 16) - return 0; - - convert_101 (); - convert_102 (); - - convert_201 (); - convert_202 (); - convert_203 (); - convert_204 (); - - convert_301 (); - convert_302 (); - convert_303 (); - convert_304 (); - convert_311 (); - convert_312 (); - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/convert-bfp-12.c b/gcc/testsuite/gcc.dg/dfp/convert-bfp-12.c deleted file mode 100644 index 7a909552afc..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/convert-bfp-12.c +++ /dev/null @@ -1,16 +0,0 @@ -/* Test for bug where fold wrongly removed conversions to double and - replaced them by conversions to float. */ - -#include "dfp-dbg.h" - -volatile float f = __builtin_inff (); -volatile _Decimal32 d32 = 1e40DF; - -int -main (void) -{ - if ((double) f == (double) d32) - FAILURE - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/convert-bfp-13.c b/gcc/testsuite/gcc.dg/dfp/convert-bfp-13.c deleted file mode 100644 index 259cc745ce3..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/convert-bfp-13.c +++ /dev/null @@ -1,18 +0,0 @@ -/* Test for bug where fold changed binary operation to decimal - depending on typedefs. */ - -#include "dfp-dbg.h" - -volatile double d = 1.2345675; - -typedef const volatile _Decimal32 d32; - -int -main (void) -{ - _Decimal32 a = (d * d); - d32 b = (d * d); - if (a != b) - FAILURE - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/convert-bfp-14.c b/gcc/testsuite/gcc.dg/dfp/convert-bfp-14.c deleted file mode 100644 index 858c92980b5..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/convert-bfp-14.c +++ /dev/null @@ -1,15 +0,0 @@ -/* Test for bug where fold narrowed decimal floating-point - operations. */ - -#include "dfp-dbg.h" - -volatile _Decimal32 f = 1.23456DF; -volatile _Decimal64 d = 1.23456DD; - -int -main (void) -{ - if ((double)((_Decimal64)f * (_Decimal64)f) != (double)(d * d)) - FAILURE - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/convert-bfp-2.c b/gcc/testsuite/gcc.dg/dfp/convert-bfp-2.c deleted file mode 100644 index 463d27f355f..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/convert-bfp-2.c +++ /dev/null @@ -1,33 +0,0 @@ -/* This test assumes IEEE float and double. It also tests long double - but makes no assumption about its size or range of values. */ - -#include "convert.h" - -volatile _Decimal32 sd; -volatile _Decimal64 dd; -volatile _Decimal128 td; -volatile float sf; -volatile double df; -volatile long double tf; /* might actually be df or xf, doesn't matter */ - -CONVERT_VALID_ALL (t1, 0.0, 0.) -CONVERT_VALID_ALL (t2, 1.0, 0.) -CONVERT_VALID_ALL (t3, -11.5, 0.) -CONVERT_VALID_ALL (t4, 7.0, 0.1e-14) -CONVERT_VALID_ALL (t5, -7.0, 0.1e-14) -CONVERT_VALID_ALL (t6, 999999., 0.) -CONVERT_VALID_ALL (t7, -999999., 0.) - -int -main () -{ - CALL_VALID_ALL (t1) - CALL_VALID_ALL (t2) - CALL_VALID_ALL (t3) - CALL_VALID_ALL (t4) - CALL_VALID_ALL (t5) - CALL_VALID_ALL (t6) - CALL_VALID_ALL (t7) - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/convert-bfp-3.c b/gcc/testsuite/gcc.dg/dfp/convert-bfp-3.c deleted file mode 100644 index 3e1d9d57a77..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/convert-bfp-3.c +++ /dev/null @@ -1,21 +0,0 @@ -/* This test assumes IEEE float and double. It also tests long double - but makes no assumption about its size or range of values. */ - -#include "convert.h" - -volatile _Decimal32 sd; -volatile _Decimal64 dd; -volatile _Decimal128 td; -volatile float sf; -volatile double df; -volatile long double tf; /* might actually be df or xf, doesn't matter */ - -CONVERT_ZEROES_ALL (t); - -int -main () -{ - CALL_ZEROES_ALL (t) - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/convert-bfp-4.c b/gcc/testsuite/gcc.dg/dfp/convert-bfp-4.c deleted file mode 100644 index b97b9c6cb08..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/convert-bfp-4.c +++ /dev/null @@ -1,21 +0,0 @@ -/* This test assumes IEEE float and double. It also tests long double - but makes no assumption about its size or range of values. */ - -#include "convert.h" - -volatile _Decimal32 sd; -volatile _Decimal64 dd; -volatile _Decimal128 td; -volatile float sf; -volatile double df; -volatile long double tf; /* might actually be df or xf, doesn't matter */ - -CONVERT_INF_ALL (t); - -int -main () -{ - CALL_INF_ALL (t) - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/convert-bfp-5.c b/gcc/testsuite/gcc.dg/dfp/convert-bfp-5.c deleted file mode 100644 index ada2d352cca..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/convert-bfp-5.c +++ /dev/null @@ -1,21 +0,0 @@ -/* This test assumes IEEE float and double. It also tests long double - but makes no assumption about its size or range of values. */ - -#include "convert.h" - -volatile _Decimal32 sd; -volatile _Decimal64 dd; -volatile _Decimal128 td; -volatile float sf; -volatile double df; -volatile long double tf; /* might actually be df or xf, doesn't matter */ - -CONVERT_NAN_ALL (t); - -int -main () -{ - CALL_NAN_ALL (t) - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/convert-bfp-6.c b/gcc/testsuite/gcc.dg/dfp/convert-bfp-6.c deleted file mode 100644 index 64198a95f2a..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/convert-bfp-6.c +++ /dev/null @@ -1,178 +0,0 @@ -/* { dg-xfail-run-if "" { lax_strtofp } "*" "" } */ -/* { dg-options "-w" } */ - -/* This test assumes IEEE float and double. */ - -#define __STDC_WANT_DEC_FP__ -#include - -#include "convert.h" - -volatile _Decimal32 sd; -volatile _Decimal64 dd; -volatile _Decimal128 td; -volatile float sf; -volatile double df; -volatile long double tf; - -CONVERT_VALID (101, td, sf, 0.000488281251dl, 0.00048828125f, 0.f) - -/* 2**(-25) = 0.298023223876953125E-7. */ -CONVERT_VALID (102, td, sf, 2.98023223876953125e-8dl, 2.9802322387695312e-08f, - 01.e-13f) - -/* Fractional part doesn't fit. */ -CONVERT_VALID (103, df, sd, 1.0e-20, 1.0e-20df, 0.df) - -/* Exact power of 2. */ -CONVERT_VALID (104, df, sd, 0.00048828125, 0.00048828125df, 0.df) -CONVERT_VALID (105, df, sd, 1.0e-96, 0.dd, DEC32_MIN) - -/* A value slightly less than FLT_MAX can be converted in both directions. */ -CONVERT_VALID (201, sf, sd, 3.402819e+38f, 3.402819e+38df, 0.df) -CONVERT_VALID (202, sd, sf, 3.402819e+38df, 3.402819e+38f, 0.f) -CONVERT_VALID (203, sf, dd, 3.402819e+38f, 3.402819e+38dd, 1.e+30dd) -CONVERT_VALID (204, dd, sf, 3.402819e+38dd, 3.402819e+38f, 0.f) -CONVERT_VALID (205, sf, td, 3.402819e+38f, 3.402819e+38dl, 1.e+30dl) -CONVERT_VALID (206, td, sf, 3.402819e+38dl, 3.402819e+38f, 0.f) - -/* A value slightly less than DEC32_MAX can be converted in both directions. */ -CONVERT_VALID (211, sd, df, 9.999998e96df, 9.999998e96, 0.) -CONVERT_VALID (212, df, sd, 9.999998e96, 9.999998e96df, 0.df) - -/* A value slightly less than DBL_MAX can be converted in both directions. */ -CONVERT_VALID (221, df, dd, 1.79768e+308, 1.79768e+308dd, 0.dd) -CONVERT_VALID (222, dd, df, 1.79768e+308dd, 1.79768e+308, 0.) -CONVERT_VALID (223, df, td, 1.79768e+308, 1.79768e+308dl, 1.e292dl) -CONVERT_VALID (224, td, df, 1.79768e+308dl, 1.79768e+308, 0.) - -/* An integral value with 6 digits (FLT_DIG) can be converted between float - and _Decimal32 in both directions. */ -CONVERT_VALID (301, sd, sf, 100000.DF, 100000.F, 0.F) -CONVERT_VALID (302, sf, sd, 100000.F, 100000.DF, 0.DF) -CONVERT_VALID (303, sd, sf, 999999.DF, 999999.F, 0.F) -CONVERT_VALID (304, sf, sd, 999999.F, 999999.DF, 0.DF) - -/* An integral value with 7 digits (DEC32_MANT_DIG) can be converted between - _Decimal32 and double in both directions. */ -CONVERT_VALID (311, sd, df, 1000000.DF, 1000000., 0.) -CONVERT_VALID (312, df, sd, 1000000., 1000000.DF, 0.DF) -CONVERT_VALID (313, sd, df, 9999999.DF, 9999999., 0.) -CONVERT_VALID (314, df, sd, 9999999., 9999999.DF, 0.DF) - -/* An integral value with 15 digits (DBL_DIG) can be converted between - double and _Decimal64 in both directions. */ -CONVERT_VALID (321, dd, df, 100000000000000.DD, 100000000000000., 0.) -CONVERT_VALID (322, df, dd, 100000000000000., 100000000000000.DD, 0.DD); -CONVERT_VALID (323, dd, df, 999999999999999.DD, 999999999999999., 0.); -CONVERT_VALID (324, df, dd, 999999999999999., 999999999999999.DD, 0.DD); - -/* If LDBL_DIG is at least 16, an integral value with 16 digits can be - converted between _Decimal64 and long double in both directions. */ -CONVERT_VALID (331, dd, tf, 1000000000000000.DD, 1000000000000000.L, 0.L) -CONVERT_VALID (332, td, dd, 1000000000000000.L, 1000000000000000.DD, 0.DD) -CONVERT_VALID (333, dd, tf, 9999999999999999.DD, 9999999999999999.L, 0.L) -CONVERT_VALID (334, td, dd, 9999999999999999.L, 9999999999999999.DD, 0.DD) - -/* If LDBL_DIG is at least 18, an integral value with 18 digits can be - converted between long double and _Decimal128 in both directions. */ -CONVERT_VALID (341, td, tf, 100000000000000000.DL, 100000000000000000.L, 0.L) -CONVERT_VALID (342, tf, td, 100000000000000000.L, 100000000000000000.DL, 0.DL) -CONVERT_VALID (343, td, tf, 999999999999999999.DL, 999999999999999999.L, 0.L) -CONVERT_VALID (344, tf, td, 999999999999999999.L, 999999999999999999.DL, 0.DL) - -/* If LDBL_DIG is at least 31, an integral value with 31 digits can be - converted between long double and _Decimal128 in both directions. */ -CONVERT_VALID (351, td, tf, 1000000000000000000000000000000.DL, - 1000000000000000000000000000000.L, 0.L) -CONVERT_VALID (352, tf, td, 1000000000000000000000000000000.L, - 1000000000000000000000000000000.DL, 0.DL) -CONVERT_VALID (353, td, tf, 9999999999999999999999999999999.DL, - 9999999999999999999999999999999.L, 0.L) -CONVERT_VALID (354, tf, td, 9999999999999999999999999999999.L, - 9999999999999999999999999999999.DL, 0.DL) - -/* If LDBL_DIG is at least 33, an integral value with 33 digits can be - converted between long double and _Decimal128 in both directions. */ -CONVERT_VALID (361, td, tf, 100000000000000000000000000000000.DL, - 100000000000000000000000000000000.L, 0.L) -CONVERT_VALID (362, tf, td, 100000000000000000000000000000000.L, - 100000000000000000000000000000000.DL, 0.DL) -CONVERT_VALID (363, td, tf, 999999999999999999999999999999999.DL, - 999999999999999999999999999999999.L, 0.L) -CONVERT_VALID (364, tf, td, 999999999999999999999999999999999.L, - 999999999999999999999999999999999.DL, 0.DL) - -int -main () -{ - convert_101 (); - convert_102 (); - convert_103 (); - convert_104 (); - convert_105 (); - - convert_201 (); - convert_202 (); - convert_203 (); - convert_204 (); - convert_205 (); - convert_206 (); - - convert_211 (); - convert_212 (); - - convert_221 (); - convert_222 (); - convert_223 (); - convert_224 (); - - convert_301 (); - convert_302 (); - convert_303 (); - convert_304 (); - - convert_311 (); - convert_312 (); - convert_313 (); - convert_314 (); - - convert_321 (); - convert_322 (); - convert_323 (); - convert_324 (); - - if (LDBL_DIG >= 16) - { - convert_331 (); - convert_332 (); - convert_333 (); - convert_334 (); - } - - if (LDBL_DIG >= 18) - { - convert_341 (); - convert_342 (); - convert_343 (); - convert_344 (); - } - - if (LDBL_DIG >= 31) - { - convert_351 (); - convert_352 (); - convert_353 (); - convert_354 (); - } - - if (LDBL_DIG >= 33) - { - convert_361 (); - convert_362 (); - convert_363 (); - convert_364 (); - } - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/convert-bfp-7.c b/gcc/testsuite/gcc.dg/dfp/convert-bfp-7.c deleted file mode 100644 index f51d696cee6..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/convert-bfp-7.c +++ /dev/null @@ -1,83 +0,0 @@ -/* { dg-options "-w" } */ - -/* This test assumes IEEE float and double. */ - -#define __STDC_WANT_DEC_FP__ -#include - -#include "convert.h" - -volatile _Decimal32 sd; -volatile _Decimal64 dd; -volatile _Decimal128 td; -volatile float sf; -volatile double df; - -/* Check values that are too large for the result type. */ -CONVERT_TO_PINF (301, sd, sf, 4.e+38df, f) -CONVERT_TO_PINF (303, dd, sf, 4.e+38dd, f) -CONVERT_TO_PINF (302, sd, sf, 9.9e+384df, f) -CONVERT_TO_PINF (304, dd, sf, 9.9e+384dd, f) -CONVERT_TO_PINF (305, td, sf, 4.e+38dl, f) -CONVERT_TO_PINF (306, td, sf, 1.e+39dl, f) -CONVERT_TO_MINF (311, sd, sf, -4.e+38df, f) -CONVERT_TO_MINF (312, dd, sf, -4.e+38dd, f) -CONVERT_TO_MINF (313, sd, sf, -9.9e+384df, f) -CONVERT_TO_MINF (314, dd, sf, -9.9e+384dd, f) -CONVERT_TO_MINF (315, td, sf, -4.e+38dl, f) -CONVERT_TO_MINF (316, td, sf, -1.e+39dl, f) - -CONVERT_TO_PINF (321, dd, df, 1.8e+308dd,) -CONVERT_TO_PINF (322, dd, df, 9.9e+384dd,) -CONVERT_TO_PINF (323, td, df, 1.8e+308dl,) -CONVERT_TO_PINF (324, td, df, 9.9e+384dl,) -CONVERT_TO_PINF (325, dd, df, 1.e309dd,) -CONVERT_TO_PINF (326, td, df, 1.e309dl,) -CONVERT_TO_MINF (331, dd, df, -1.8e+308dd,) -CONVERT_TO_MINF (332, dd, df, -9.9e+384dd,) -CONVERT_TO_MINF (333, td, df, -1.8e+308dl,) -CONVERT_TO_MINF (334, td, df, -9.9e+384dl,) -CONVERT_TO_MINF (335, dd, df, -1.e309dd,) -CONVERT_TO_MINF (336, td, df, -1.e309dl,) - -CONVERT_TO_PINF (341, df, sd, 1.0e+97, d32) -CONVERT_TO_PINF (342, df, sd, 1.6e+308, d32) -CONVERT_TO_MINF (351, df, sd, -1.0e+97, d32) -CONVERT_TO_MINF (352, df, sd, -1.6e+308, d32) - -int -main () -{ - convert_301 (); - convert_302 (); - convert_303 (); - convert_304 (); - convert_305 (); - convert_306 (); - convert_311 (); - convert_312 (); - convert_313 (); - convert_314 (); - convert_315 (); - convert_316 (); - - convert_321 (); - convert_322 (); - convert_323 (); - convert_324 (); - convert_325 (); - convert_326 (); - convert_331 (); - convert_332 (); - convert_333 (); - convert_334 (); - convert_335 (); - convert_336 (); - - convert_341 (); - convert_342 (); - convert_351 (); - convert_352 (); - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/convert-bfp-8.c b/gcc/testsuite/gcc.dg/dfp/convert-bfp-8.c deleted file mode 100644 index 532bd861314..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/convert-bfp-8.c +++ /dev/null @@ -1,71 +0,0 @@ -/* { dg-options "-w" } */ - -/* This test assumes IEEE float and double. */ - -#define __STDC_WANT_DEC_FP__ -#include - -#include "convert.h" - -volatile _Decimal32 sd; -volatile _Decimal64 dd; -volatile _Decimal128 td; -volatile float sf; -volatile double df; - -/* Values slightly smaller than minimum (closest to zero) for result type. */ -CONVERT_VALID (401, sd, sf, 1.e-39df, 0.f, FLT_MIN) -CONVERT_VALID (402, sd, sf, -1.e-39df, 0.f, FLT_MIN) -CONVERT_VALID (403, sd, sf, 1.1e-38df, 0.f, FLT_MIN) -CONVERT_VALID (404, sd, sf, -1.1e-38df, 0.f, FLT_MIN) - -CONVERT_VALID (411, dd, sf, 1.e-39dd, 0.f, FLT_MIN) -CONVERT_VALID (412, dd, sf, -1.e-39dd, 0.f, FLT_MIN) -CONVERT_VALID (413, dd, sf, 1.1e-38dd, 0.f, FLT_MIN) -CONVERT_VALID (414, dd, sf, -1.1e-38dd, 0.f, FLT_MIN) - -CONVERT_VALID (421, dd, df, 3.e-309dd, 0., DBL_MIN) -CONVERT_VALID (422, dd, df, -3.e-309dd, 0., DBL_MIN) -CONVERT_VALID (423, dd, df, 2.e-308dd, 0., DBL_MIN) -CONVERT_VALID (424, dd, df, -2.e-308dd, 0., DBL_MIN) - -CONVERT_VALID (431, td, sf, 1.e-39dl, 0.f, FLT_MIN) -CONVERT_VALID (432, td, sf, -1.e-39dl, 0.f, FLT_MIN) -CONVERT_VALID (433, td, sf, 1.1e-38dl, 0.f, FLT_MIN) -CONVERT_VALID (434, td, sf, -1.1e-38dl, 0.f, FLT_MIN) - -CONVERT_VALID (441, td, df, 3.e-309dl, 0., DBL_MIN) -CONVERT_VALID (442, td, df, -3.e-309dl, 0., DBL_MIN) -CONVERT_VALID (443, td, df, 2.e-308dl, 0., DBL_MIN) -CONVERT_VALID (444, td, df, -2.e-308dl, 0., DBL_MIN) - -int -main () -{ - convert_401 (); - convert_402 (); - convert_403 (); - convert_404 (); - - convert_411 (); - convert_412 (); - convert_413 (); - convert_414 (); - - convert_421 (); - convert_422 (); - convert_423 (); - convert_424 (); - - convert_431 (); - convert_432 (); - convert_433 (); - convert_434 (); - - convert_441 (); - convert_442 (); - convert_443 (); - convert_444 (); - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/convert-bfp-9.c b/gcc/testsuite/gcc.dg/dfp/convert-bfp-9.c deleted file mode 100644 index e609087525a..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/convert-bfp-9.c +++ /dev/null @@ -1,192 +0,0 @@ -/* { dg-xfail-run-if "" { lax_strtofp } "*" "" } */ -/* { dg-options "-w" } */ - -/* This test assumes IEEE float and double. */ - -#define __STDC_WANT_DEC_FP__ -#include - -#include "convert.h" - -volatile _Decimal32 sd; -volatile _Decimal64 dd; -volatile _Decimal128 td; -volatile float sf; -volatile double df; - -/* Exponent values that might cause problems with a particular - implementation. */ - -CONVERT_VALID (101, dd, df, 1.e309dd, 1.e309, 0.) -CONVERT_VALID (102, dd, df, 1.e308dd, 1.e308, 0.) -CONVERT_VALID (103, dd, df, 1.e307dd, 1.e307, 0.) -CONVERT_VALID (104, dd, df, 1.e306dd, 1.e306, 0.) -CONVERT_VALID (105, dd, df, 1.e305dd, 1.e305, 0.) -CONVERT_VALID (106, dd, df, 1.e304dd, 1.e304, 0.) -CONVERT_VALID (107, dd, df, 1.e303dd, 1.e303, 0.) -CONVERT_VALID (108, dd, df, 1.e302dd, 1.e302, 0.) -CONVERT_VALID (109, dd, df, 1.e301dd, 1.e301, 0.) -CONVERT_VALID (110, dd, df, 1.e300dd, 1.e300, 0.) -CONVERT_VALID (111, dd, df, 1.e299dd, 1.e299, 0.) -CONVERT_VALID (112, dd, df, 1.e298dd, 1.e298, 0.) -CONVERT_VALID (113, dd, df, 1.e297dd, 1.e297, 0.) -CONVERT_VALID (114, dd, df, 1.e296dd, 1.e296, 0.) -CONVERT_VALID (115, dd, df, 1.e295dd, 1.e295, 0.) -CONVERT_VALID (116, dd, df, 1.e294dd, 1.e294, 0.) -CONVERT_VALID (117, dd, df, 1.e293dd, 1.e293, 0.) -CONVERT_VALID (118, dd, df, 1.e292dd, 1.e292, 0.) -CONVERT_VALID (119, dd, df, 1.e291dd, 1.e291, 0.) -CONVERT_VALID (120, dd, df, 1.e290dd, 1.e290, 0.) - -CONVERT_VALID (201, dd, df, 1.e-309dd, 1.e-309, 0.) -CONVERT_VALID (202, dd, df, 1.e-308dd, 1.e-308, 0.) -CONVERT_VALID (203, dd, df, 1.e-307dd, 1.e-307, 0.) -CONVERT_VALID (204, dd, df, 1.e-306dd, 1.e-306, 0.) -CONVERT_VALID (205, dd, df, 1.e-305dd, 1.e-305, 0.) -CONVERT_VALID (206, dd, df, 1.e-304dd, 1.e-304, 0.) -CONVERT_VALID (207, dd, df, 1.e-303dd, 1.e-303, 0.) -CONVERT_VALID (208, dd, df, 1.e-302dd, 1.e-302, 0.) -CONVERT_VALID (209, dd, df, 1.e-301dd, 1.e-301, 0.) -CONVERT_VALID (210, dd, df, 1.e-300dd, 1.e-300, 0.) -CONVERT_VALID (211, dd, df, 1.e-299dd, 1.e-299, 0.) -CONVERT_VALID (212, dd, df, 1.e-298dd, 1.e-298, 0.) -CONVERT_VALID (213, dd, df, 1.e-297dd, 1.e-297, 0.) -CONVERT_VALID (214, dd, df, 1.e-296dd, 1.e-296, 0.) -CONVERT_VALID (215, dd, df, 1.e-295dd, 1.e-295, 0.) -CONVERT_VALID (216, dd, df, 1.e-294dd, 1.e-294, 0.) -CONVERT_VALID (217, dd, df, 1.e-293dd, 1.e-293, 0.) -CONVERT_VALID (218, dd, df, 1.e-292dd, 1.e-292, 0.) -CONVERT_VALID (219, dd, df, 1.e-291dd, 1.e-291, 0.) -CONVERT_VALID (220, dd, df, 1.e-290dd, 1.e-290, 0.) - -CONVERT_VALID (301, td, df, 1.e309dl, 1.e309, 0.) -CONVERT_VALID (302, td, df, 1.e308dl, 1.e308, 0.) -CONVERT_VALID (303, td, df, 1.e307dl, 1.e307, 0.) -CONVERT_VALID (304, td, df, 1.e306dl, 1.e306, 0.) -CONVERT_VALID (305, td, df, 1.e305dl, 1.e305, 0.) -CONVERT_VALID (306, td, df, 1.e304dl, 1.e304, 0.) -CONVERT_VALID (307, td, df, 1.e303dl, 1.e303, 0.) -CONVERT_VALID (308, td, df, 1.e302dl, 1.e302, 0.) -CONVERT_VALID (309, td, df, 1.e301dl, 1.e301, 0.) -CONVERT_VALID (310, td, df, 1.e300dl, 1.e300, 0.) -CONVERT_VALID (311, td, df, 1.e299dl, 1.e299, 0.) -CONVERT_VALID (312, td, df, 1.e298dl, 1.e298, 0.) -CONVERT_VALID (313, td, df, 1.e297dl, 1.e297, 0.) -CONVERT_VALID (314, td, df, 1.e296dl, 1.e296, 0.) -CONVERT_VALID (315, td, df, 1.e295dl, 1.e295, 0.) -CONVERT_VALID (316, td, df, 1.e294dl, 1.e294, 0.) -CONVERT_VALID (317, td, df, 1.e293dl, 1.e293, 0.) -CONVERT_VALID (318, td, df, 1.e292dl, 1.e292, 0.) -CONVERT_VALID (319, td, df, 1.e291dl, 1.e291, 0.) -CONVERT_VALID (320, td, df, 1.e290dl, 1.e290, 0.) - -CONVERT_VALID (401, td, df, 1.e-309dl, 1.e-309, 0.) -CONVERT_VALID (402, td, df, 1.e-308dl, 1.e-308, 0.) -CONVERT_VALID (403, td, df, 1.e-307dl, 1.e-307, 0.) -CONVERT_VALID (404, td, df, 1.e-306dl, 1.e-306, 0.) -CONVERT_VALID (405, td, df, 1.e-305dl, 1.e-305, 0.) -CONVERT_VALID (406, td, df, 1.e-304dl, 1.e-304, 0.) -CONVERT_VALID (407, td, df, 1.e-303dl, 1.e-303, 0.) -CONVERT_VALID (408, td, df, 1.e-302dl, 1.e-302, 0.) -CONVERT_VALID (409, td, df, 1.e-301dl, 1.e-301, 0.) -CONVERT_VALID (410, td, df, 1.e-300dl, 1.e-300, 0.) -CONVERT_VALID (411, td, df, 1.e-299dl, 1.e-299, 0.) -CONVERT_VALID (412, td, df, 1.e-298dl, 1.e-298, 0.) -CONVERT_VALID (413, td, df, 1.e-297dl, 1.e-297, 0.) -CONVERT_VALID (414, td, df, 1.e-296dl, 1.e-296, 0.) -CONVERT_VALID (415, td, df, 1.e-295dl, 1.e-295, 0.) -CONVERT_VALID (416, td, df, 1.e-294dl, 1.e-294, 0.) -CONVERT_VALID (417, td, df, 1.e-293dl, 1.e-293, 0.) -CONVERT_VALID (418, td, df, 1.e-292dl, 1.e-292, 0.) -CONVERT_VALID (419, td, df, 1.e-291dl, 1.e-291, 0.) -CONVERT_VALID (420, td, df, 1.e-290dl, 1.e-290, 0.) - -int -main () -{ - convert_101 (); - convert_102 (); - convert_103 (); - convert_104 (); - convert_105 (); - convert_106 (); - convert_107 (); - convert_108 (); - convert_109 (); - convert_110 (); - convert_111 (); - convert_112 (); - convert_113 (); - convert_114 (); - convert_115 (); - convert_116 (); - convert_117 (); - convert_118 (); - convert_119 (); - convert_120 (); - - convert_201 (); - convert_202 (); - convert_203 (); - convert_204 (); - convert_205 (); - convert_206 (); - convert_207 (); - convert_208 (); - convert_209 (); - convert_210 (); - convert_211 (); - convert_212 (); - convert_213 (); - convert_214 (); - convert_215 (); - convert_216 (); - convert_217 (); - convert_218 (); - convert_219 (); - convert_220 (); - - convert_301 (); - convert_302 (); - convert_303 (); - convert_304 (); - convert_305 (); - convert_306 (); - convert_307 (); - convert_308 (); - convert_309 (); - convert_310 (); - convert_311 (); - convert_312 (); - convert_313 (); - convert_314 (); - convert_315 (); - convert_316 (); - convert_317 (); - convert_318 (); - convert_319 (); - convert_320 (); - - convert_401 (); - convert_402 (); - convert_403 (); - convert_404 (); - convert_405 (); - convert_406 (); - convert_407 (); - convert_408 (); - convert_409 (); - convert_410 (); - convert_411 (); - convert_412 (); - convert_413 (); - convert_414 (); - convert_415 (); - convert_416 (); - convert_417 (); - convert_418 (); - convert_419 (); - convert_420 (); - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/convert-bfp-fold.c b/gcc/testsuite/gcc.dg/dfp/convert-bfp-fold.c deleted file mode 100644 index d62a7e4b21c..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/convert-bfp-fold.c +++ /dev/null @@ -1,118 +0,0 @@ -/* { dg-options "-O2" } */ - -/* N1150 5.2 Conversions among decimal floating types and between - decimal floating types and generic floating types. - C99 6.3.1.5(4) Conversions, arithmetic operands, real floating types. */ - -#include "dfp-dbg.h" - -_Decimal32 d32; -_Decimal64 d64; -_Decimal128 d128; -float sf; -double df; -long double tf; - -extern void link_error (void); - -int -main () -{ - /* Conversions from decimal float to binary float. */ - - /* Conversions from _Decimal32. */ - d32 = 2.0df; - sf = d32; - if (sf != 2.0f) - link_error (); - - df = d32; - if (df != 2.0) - link_error (); - - tf = d32; - if (tf != 2.0l) - link_error (); - - /* Conversions from _Decimal64. */ - d64 = -7.0dd; - sf = d64; - if (sf != -7.0f) - link_error (); - - df = d64; - if (df != -7.0) - link_error (); - - tf = d64; - if (tf != -7.0l) - link_error (); - - /* Conversions from _Decimal128. */ - d128 = 30.0dl; - sf = d128; - if (sf != 30.0f) - link_error (); - - df = d128; - if (df != 30.0) - link_error (); - - df = d128; - if (df != 30.0l) - link_error (); - - /* Conversions from binary float to decimal float. */ - sf = 30.0f; - d128 = sf; - if (d128 != 30.0dl) - link_error (); - - d64 = sf; - if (d64 != 30.0dd) - link_error (); - - d32 = sf; - if (d32 != 30.0df) - link_error (); - - df = -2.0; - d128 = df; - if (d128 != -2.0dl) - link_error (); - - d64 = df; - if (d64 != -2.0dd) - link_error (); - - d32 = df; - if (d32 != -2.0df) - link_error (); - - tf = -22.0l; - d128 = tf; - if (d128 != -22.0dl) - link_error (); - - d64 = tf; - if (d64 != -22.0dd) - link_error (); - - d32 = tf; - if (d32 != -22.0df) - link_error (); - - /* 2**(-11) = 0.00048828125. */ - d128 = 0.000488281251dl; - sf = d128; - if (sf != 0.00048828125f) - link_error (); - /* 2**(-25) = 0.298023223876953125E-7. */ - d128 = 2.98023223876953125E-8dl; - df = d128; - if (df < (2.9802322387695312e-08 - 0.00000000001) - || df > (2.9802322387695312e-08 + 0.00000000001)) - link_error (); - - return 0; -} diff --git a/gcc/testsuite/gcc.dg/dfp/convert-bfp.c b/gcc/testsuite/gcc.dg/dfp/convert-bfp.c deleted file mode 100644 index 710538d467b..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/convert-bfp.c +++ /dev/null @@ -1,131 +0,0 @@ -/* N1150 5.2 Conversions among decimal floating types and between - decimal floating types and generic floating types. - C99 6.3.1.5(4) Conversions, arithmetic operands, real floating types. */ - -/* Long double isn't supported yet at runtime, so disable those checks. */ - -#include "dfp-dbg.h" - -static int skip_long_double; - -volatile _Decimal32 d32; -volatile _Decimal64 d64; -volatile _Decimal128 d128; -volatile float sf; -volatile double df; -volatile long double tf; - -int -main () -{ - /* Conversions from decimal float to binary float. */ - - if (sizeof (long double) == sizeof (double)) - skip_long_double = 1; - - /* Conversions from _Decimal32. */ - d32 = 2.0df; - sf = d32; - if (sf != 2.0f) - FAILURE - - df = d32; - if (df != 2.0) - FAILURE - - if (skip_long_double == 0) - { - tf = d32; - if (tf != 2.0l) - FAILURE - } - - /* Conversions from _Decimal64. */ - d64 = -7.0dd; - sf = d64; - if (sf != -7.0f) - FAILURE - - df = d64; - if (df != -7.0) - FAILURE - - if (skip_long_double == 0) - { - tf = d64; - if (tf != -7.0l) - FAILURE - } - - /* Conversions from _Decimal128. */ - d128 = 30.0dl; - sf = d128; - if (sf != 30.0f) - FAILURE - - df = d128; - if (df != 30.0) - FAILURE - - df = d128; - if (df != 30.0l) - FAILURE - - /* Conversions from binary float to decimal float. */ - sf = 30.0f; - d32 = sf; - if (d32 != 30.0df) - FAILURE - - d64 = sf; - if (d64 != 30.0dd) - FAILURE - - df = -2.0; - d32 = df; - if (d32 != -2.0df) - FAILURE - - d64 = df; - if (d64 != -2.0dd) - FAILURE - - d128 = df; - if (d128 != -2.0dl) - FAILURE - - sf = 30.0f; - d128 = sf; - if (d128 != 30.0dl) - FAILURE - - if (skip_long_double == 0) - { - tf = -22.0l; - d32 = tf; - if (d32 != -22.0df) - FAILURE - - d64 = tf; - if (d64 != -22.0dd) - FAILURE - - d128 = tf; - if (d128 != -22.0dl) - FAILURE - } - - /* 2**(-11) = 0.00048828125. */ - d128 = 0.000488281251dl; - sf = d128; - if (sf != 0.00048828125f) - FAILURE - /* 2**(-25) = 0.298023223876953125E-7. */ - d128 = 2.98023223876953125E-8dl; - df = d128; - if (df < (2.9802322387695312e-08 - 0.00000000001) - || df > (2.9802322387695312e-08 + 0.00000000001)) - FAILURE - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/convert-dfp-fold-2.c b/gcc/testsuite/gcc.dg/dfp/convert-dfp-fold-2.c deleted file mode 100644 index 073f7abc4a6..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/convert-dfp-fold-2.c +++ /dev/null @@ -1,15 +0,0 @@ -/* Test for bug where fold narrowed decimal floating-point - operations. */ - -#include "dfp-dbg.h" - -volatile _Decimal32 f = 1.23456DF; -volatile _Decimal64 d = 1.23456DD; - -int -main (void) -{ - if ((_Decimal128)((_Decimal64)f * (_Decimal64)f) != (_Decimal128)(d * d)) - FAILURE - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/convert-dfp-fold.c b/gcc/testsuite/gcc.dg/dfp/convert-dfp-fold.c deleted file mode 100644 index 67c9d71c224..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/convert-dfp-fold.c +++ /dev/null @@ -1,47 +0,0 @@ -/* { dg-options "-O2" } */ - -/* N1150 5.2 Conversions among decimal floating types and between - decimal floating types and generic floating types. - C99 6.3.1.5(3) New. */ - -#include "dfp-dbg.h" - -extern void link_error (); - -int -main () -{ - _Decimal32 d32; - _Decimal64 d64; - _Decimal128 d128; - - /* Conversions to larger types. */ - d32 = 123.4df; - d64 = d32; - if (d64 != 123.4dd) - link_error (); - d128 = d32; - if (d128 != 123.4dl) - link_error (); - d64 = 345.678dd; - d128 = d64; - if (d128 != 345.678dl) - link_error (); - - /* Conversions to smaller types for which the value fits. */ - d64 = 3456.789dd; - d32 = d64; - if (d32 != 3456.789df) - link_error (); - d128 = 123.4567dl; - d32 = d128; - if (d32 != 123.4567dl) - link_error (); - - d128 = 1234567890.123456dl; - d64 = d128; - if (d64 != 1234567890.123456dd) - link_error (); - - return 0; -} diff --git a/gcc/testsuite/gcc.dg/dfp/convert-dfp.c b/gcc/testsuite/gcc.dg/dfp/convert-dfp.c deleted file mode 100644 index d52ba51b0be..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/convert-dfp.c +++ /dev/null @@ -1,94 +0,0 @@ -/* { dg-options "-O0" } */ - -/* N1150 5.2 Conversions among decimal floating types and between - decimal floating types and generic floating types. - C99 6.3.1.5(3) New. - - Test various conversions involving decimal floating types. */ - -#ifndef __STDC_WANT_DEC_FP__ -#define __STDC_WANT_DEC_FP__ 1 -#endif - -#include "dfp-dbg.h" -#include - -volatile _Decimal32 d32; -volatile _Decimal64 d64; -volatile _Decimal128 d128; - -int -main () -{ - /* Conversions to larger types. */ - d32 = 123.4df; - d64 = d32; - if (d64 != 123.4dd) - FAILURE - d128 = d32; - if (d128 != 123.4dl) - FAILURE - d64 = 345.678dd; - d128 = d64; - if (d128 != 345.678dl) - FAILURE - - /* Conversions to smaller types for which the value fits. */ - d64 = 3456.789dd; - d32 = d64; - if (d32 != 3456.789df) - FAILURE - d128 = 123.4567dl; - d32 = d128; - if (d32 != 123.4567df) - FAILURE - - d128 = 1234567890.123456dl; - d64 = d128; - if (d64 != 1234567890.123456dd) - FAILURE - - /* Test demotion to non-representable decimal floating type. */ - - /* Assumes a default rounding mode of 'near'. This uses the rules - describe in the 27 July 2005 draft of IEEE 754r, which are much - more clear that what's described in draft 5 of N1107. */ - - /* Rounds to what _Decimal32 can handle. */ - d64 = 9.99999949E96DD; - d32 = d64; - if (d32 != DEC32_MAX) - FAILURE - - /* Rounds to more than _Decimal32 can handle. */ - d64 = 9.9999995E96DD; - d32 = d64; - if (d32 != __builtin_infd32()) - FAILURE - - /* Rounds to what _Decimal32 can handle. */ - d128 = 9.99999949E96DD; - d32 = d128; - if (d32 != DEC32_MAX) - FAILURE - - /* Rounds to more than _Decimal32 can handle. */ - d128= 9.9999995E96DD; - d32 = d128; - if (d32 != __builtin_infd32()) - FAILURE - - /* Rounds to what _Decimal64 can handle. */ - d128 = 9.99999999999999949E384DL; - d64 = d128; - if (d64 != DEC64_MAX) - FAILURE - - /* Rounds to more than _Decimal64 can handle. */ - d128 = 9.9999999999999995E384DL; - d64 = d128; - if (d64 != __builtin_infd64()) - FAILURE - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/convert-int-fold.c b/gcc/testsuite/gcc.dg/dfp/convert-int-fold.c deleted file mode 100644 index 038559d41e4..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/convert-int-fold.c +++ /dev/null @@ -1,173 +0,0 @@ -/* { dg-options "-O2" } */ - -/* N1150 5.1 Conversion between decimal floating integer. - C99 6.3.1.4(1a) New. - These should all be folded at compile time. */ - -#include "dfp-dbg.h" - -#ifdef __cplusplus -#define BOOL bool -#else -#define BOOL _Bool -#endif - -extern void link_error (void); - -int -main () -{ - _Decimal32 d32; - _Decimal64 d64; - _Decimal128 d128; - unsigned int ui; - unsigned long ul; - unsigned long long ull; - int si; - long sl; - long long sll; - BOOL b; - - /* C99 Section 6.7.2 Type specifiers. Type _Bool is - mentioned in this section. Conversions between - BOOL and DFP types. */ - - /* Decimal float to unsigned integer. */ - d32 = 456.789df; - d64 = 23.456789dd; - d128 = 1234.5678dl; - - ui = d32; - if (ui != 456U) - link_error (); - ul = d32; - if (ul != 456UL) - link_error (); - ull = d32; - if (ull != 456ULL) - link_error (); - - ui = d64; - if (ui != 23U) - link_error (); - ul = d64; - if (ul != 23UL) - link_error (); - ull = d64; - if (ull != 23ULL) - link_error (); - - ui = d128; - if (ui != 1234U) - link_error (); - ul = d128; - if (ul != 1234UL) - link_error (); - ull = d128; - if (ull != 1234ULL) - link_error (); - - /* Decimal float to signed integer. */ - - /* Decimal float to BOOL. */ - d32 = 1.23df; - d64 = -3.4dd; - d128 = 0.00003dl; - - b = d32; - if (!b) - link_error (); - b = d64; - if (!b) - link_error (); - b = d128; - if (!b) - link_error (); - - /* Unsigned integer to decimal float. */ - ui = 987U; - ul = 345678UL; - ull = 1234567ULL; - - d32 = ui; - if (d32 != 987.0df) - link_error (); - d32 = ul; - if (d32 != 345678.0df) - link_error (); - d32 = ull; - if (d32 != 1234567.df) - link_error (); - - d64 = ui; - if (d64 != 987.0dd) - link_error (); - d64 = ul; - if (d64 != 345678.0dd) - link_error (); - d64 = ull; - if (d64 != 1234567.dd) - link_error (); - - d128 = ui; - if (d128 != 987.0dl) - link_error (); - d128 = ul; - if (d128 != 345678.0dl) - link_error (); - d128 = ull; - if (d128 != 1234567.dl) - link_error (); - - /* Signed integer to decimal float. */ - si = -987; - sl = -345678; - sll = -1234567; - - d32 = si; - if (d32 != -987.0df) - link_error (); - d32 = sl; - if (d32 != -345678.0df) - link_error (); - d32 = sll; - if (d32 != -1234567.df) - link_error (); - - d64 = si; - if (d64 != -987.0dd) - link_error (); - d64 = sl; - if (d64 != -345678.0dd) - link_error (); - d64 = sll; - if (d64 != -1234567.dd) - link_error (); - - d128 = si; - if (d128 != -987.0dl) - link_error (); - d128 = sl; - if (d128 != -345678.0dl) - link_error (); - d128 = sll; - if (d128 != -1234567.dl) - link_error (); - - /* BOOL to decimal float. */ - d32 = 0.0DF; - d64 = 0.0DD; - d128 = 0.0DL; - - b = d32; - if (b) - link_error (); - b = d64; - if (b) - link_error (); - b = d128; - if (b) - link_error (); - - return 0; -} diff --git a/gcc/testsuite/gcc.dg/dfp/convert-int-max-fold.c b/gcc/testsuite/gcc.dg/dfp/convert-int-max-fold.c deleted file mode 100644 index 3f6faae34cc..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/convert-int-max-fold.c +++ /dev/null @@ -1,148 +0,0 @@ -/* { dg-options "-O2 -w" } */ - -/* N1150 5.1 Conversions from decimal float to integer. */ - -/* Test decimal float to integer conversions for values at the limit of - what will fit into the destination type. This assumes 32-bit int and - 64-bit long long (there's a check for that below). This version tests - conversions during compilation. */ - -#include "dfp-dbg.h" - -extern void link_error (void); - -void -doit () -{ - _Decimal32 d32; - _Decimal64 d64; - _Decimal128 d128; - int si; - unsigned int ui; - long long sll; - unsigned long long ull; - - /* _Decimal32 to int. */ - - d32 = 2147483.E3DF; - si = d32; - if (si != 2147483000) - link_error (); - - d32 = -2147483.E3DF; - si = d32; - if (si != -2147483000) - link_error (); - - /* _Decimal32 to unsigned int. */ - - d32 = 4.294967E9DF; - ui = d32; - if (ui != 4294967000U) - link_error (); - - /* _Decimal32 to long long. */ - - d32 = 922.3372E16DF; - sll = d32; - if (sll != 9223372000000000000LL) - link_error (); - - d32 = -92233.72E14DF; - sll = d32; - if (sll != -9223372000000000000LL) - link_error (); - - /* _Decimal32 to unsigned long long. */ - - d32 = 0.1844674E20DF; - ull = d32; - if (ull != 18446740000000000000ULL) - link_error (); - - /* _Decimal64 to int. */ - - d64 = 2.147483647E9DD; - si = d64; - if (si != 2147483647) - link_error (); - - d64 = -2147483648.DD; - si = d64; - if (si != -2147483648) - link_error (); - - /* _Decimal64 to unsigned int. */ - - d64 = 42949.67295E5DD; - ui = d64; - if (ui != 4294967295) - link_error (); - - /* _Decimal64 to long long. */ - - d64 = 9.223372036854775E18DD; - sll = d64; - if (sll != 9223372036854775000LL) - link_error (); - - d64 = -92233720.36854775E11DD; - sll = d64; - if (sll != -9223372036854775000LL) - link_error (); - - /* _Decimal64 to unsigned long long. */ - d64 = 1844674407370955.E4DD; - ull = d64; - if (ull != 18446744073709550000ULL) - link_error (); - - /* _Decimal128 to int. */ - - d128 = 2.147483647E9DL; - si = d128; - if (si != 2147483647) - link_error (); - - d128 = -2147483648.DL; - si = d128; - if (si != -2147483648) - link_error (); - - /* _Decimal128 to unsigned int. */ - - d128 = 4294.967295E6DL; - ui = d128; - if (ui != 4294967295) - link_error (); - - /* _Decimal128 to long long. */ - - d128 = 9223372036854775807.DL; - sll = d128; - if (sll != 9223372036854775807LL) - link_error (); - - d128 = -9.223372036854775808E19DL; - sll = d128; - if (sll != -9223372036854775807LL - 1LL) - link_error (); - - /* _Decimal128 to unsigned long long. */ - d128 = 18446744073709551615.DL; - ull = d128; - if (ull != 18446744073709551615ULL) - link_error (); -} - -int -main () -{ - /* This test assumes 32-bit int and 64-bit long long. */ - - if (sizeof (int) != 4 || sizeof (long long) != 8) - return 0; - - doit (); - return 0; -} diff --git a/gcc/testsuite/gcc.dg/dfp/convert-int-max.c b/gcc/testsuite/gcc.dg/dfp/convert-int-max.c deleted file mode 100644 index 724627d3763..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/convert-int-max.c +++ /dev/null @@ -1,146 +0,0 @@ -/* { dg-options "-O0 -w" } */ - -/* N1150 5.1 Conversions from decimal float to integer. */ - -/* Test decimal float to integer conversions for values at the limit of - what will fit into the destination type. This assumes 32-bit int and - 64-bit long long (there's a check for that below). */ - -#include "dfp-dbg.h" - -volatile _Decimal32 d32; -volatile _Decimal64 d64; -volatile _Decimal128 d128; -volatile int si; -volatile unsigned int ui; -volatile long long sll; -volatile unsigned long long ull; - -void -doit () -{ - /* _Decimal32 to int. */ - - d32 = 2147483.E3DF; - si = d32; - if (si != 2147483000) - FAILURE - - d32 = -2147483.E3DF; - si = d32; - if (si != -2147483000) - FAILURE - - /* _Decimal32 to unsigned int. */ - - d32 = 4.294967E9DF; - ui = d32; - if (ui != 4294967000U) - FAILURE - - /* _Decimal32 to long long. */ - - d32 = 922.3372E16DF; - sll = d32; - if (sll != 9223372000000000000LL) - FAILURE - - d32 = -92233.72E14DF; - sll = d32; - if (sll != -9223372000000000000LL) - FAILURE - - /* _Decimal32 to unsigned long long. */ - - d32 = .1844674E20DF; - ull = d32; - if (ull != 18446740000000000000ULL) - FAILURE - - /* _Decimal64 to int. */ - - d64 = 2.147483647E9DD; - si = d64; - if (si != 2147483647) - FAILURE - - d64 = -2147483648.DD; - si = d64; - if (si != -2147483648) - FAILURE - - /* _Decimal64 to unsigned int. */ - - d64 = 42949.67295E5DD; - ui = d64; - if (ui != 4294967295) - FAILURE - - /* _Decimal64 to long long. */ - - d64 = 9.223372036854775E18DD; - sll = d64; - if (sll != 9223372036854775000LL) - FAILURE - - d64 = -92233720.36854775E11DD; - sll = d64; - if (sll != -9223372036854775000LL) - FAILURE - - /* _Decimal64 to unsigned long long. */ - d64 = 1844674407370955.E4DD; - ull = d64; - if (ull != 18446744073709550000ULL) - FAILURE - - /* _Decimal128 to int. */ - - d128 = 2.147483647E9DL; - si = d128; - if (si != 2147483647) - FAILURE - - d128 = -2147483648.DL; - si = d128; - if (si != -2147483648) - FAILURE - - /* _Decimal128 to unsigned int. */ - - d128 = 4294.967295E6DL; - ui = d128; - if (ui != 4294967295) - FAILURE - - /* _Decimal128 to long long. */ - - d128 = 9223372036854775807.DL; - sll = d128; - if (sll != 9223372036854775807LL) - FAILURE - - d128 = -9.223372036854775808E19DL; - sll = d128; - if (sll != -9223372036854775807LL - 1LL) - FAILURE - - /* _Decimal128 to unsigned long long. */ - d128 = 18446744073709551615.DL; - ull = d128; - if (ull != 18446744073709551615ULL) - FAILURE -} - -int -main () -{ - /* This test assumes 32-bit int and 64-bit long long. */ - - if (sizeof (int) != 4 || sizeof (long long) != 8) - return 0; - - doit (); - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/convert-int-saturate.c b/gcc/testsuite/gcc.dg/dfp/convert-int-saturate.c deleted file mode 100644 index c92502d56ad..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/convert-int-saturate.c +++ /dev/null @@ -1,64 +0,0 @@ -/* N1150 5.1 Conversion between decimal floating integer. - C99 6.3.1.4(1a) New. - Test integer saturation. */ - -#ifndef __STDC_WANT_DEC_FP__ -#define __STDC_WANT_DEC_FP__ 1 -#endif - -#include "dfp-dbg.h" -#include -#include - -volatile _Decimal32 d32; -volatile _Decimal64 d64; -volatile _Decimal128 d128; - -volatile signed int si; -volatile unsigned int usi; -volatile unsigned long long udi; - -int -main () -{ - - /* Unsigned. */ - usi = DEC32_MAX; /* { dg-warning "overflow in implicit constant conversion" } */ - if (usi != UINT_MAX) - FAILURE - - usi = DEC64_MAX; /* { dg-warning "overflow in implicit constant conversion" } */ - if (usi != UINT_MAX) - FAILURE - - usi = DEC128_MAX; /* { dg-warning "overflow in implicit constant conversion" } */ - if (usi != UINT_MAX) - FAILURE - - /* Signed. */ - si = DEC32_MAX; /* { dg-warning "overflow in implicit constant conversion" } */ - if (si != INT_MAX) - FAILURE - - si = DEC64_MAX; /* { dg-warning "overflow in implicit constant conversion" } */ - if (si != INT_MAX) - FAILURE - - si = DEC128_MAX; /* { dg-warning "overflow in implicit constant conversion" } */ - if (si != INT_MAX) - FAILURE - - si = - DEC32_MAX; /* { dg-warning "overflow in implicit constant conversion" } */ - if (si != INT_MIN) - FAILURE - - si = - DEC64_MAX; /* { dg-warning "overflow in implicit constant conversion" } */ - if (si != INT_MIN) - FAILURE - - si = - DEC128_MAX; /* { dg-warning "overflow in implicit constant conversion" } */ - if (si != INT_MIN) - FAILURE - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/convert-int.c b/gcc/testsuite/gcc.dg/dfp/convert-int.c deleted file mode 100644 index 1525d5760a4..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/convert-int.c +++ /dev/null @@ -1,199 +0,0 @@ -/* { dg-options "-O0" } */ - -/* N1150 5.1 Conversion between decimal floating types and integer. - C99 6.3.1.4(1a) New. */ - -#include "dfp-dbg.h" - -#ifdef __cplusplus -#define BOOL bool -#else -#define BOOL _Bool -#endif - -_Decimal32 d32; -_Decimal64 d64; -_Decimal128 d128; -unsigned int ui; -unsigned long ul; -unsigned long long ull; -int si; -long sl; -long long sll; -BOOL b; - -void -init_dfp_1 (void) -{ - d32 = 456.789df; - d64 = 23.456789dd; - d128 = 1234.5678dl; -} -void -init_dfp_2 (void) -{ - d32 = 1.23df; - d64 = -3.4dd; - d128 = 0.00003dl; -} - -void -init_dfp_3 (void) -{ - d32 = 0.0DF; - d64 = 0.0DD; - d128 = 0.0DL; -} - -void -init_unsigned_int (void) -{ - ui = 987U; - ul = 345678UL; - ull = 1234567ULL; -} - -void -init_signed_int (void) -{ - si = -987; - sl = -345678; - sll = -1234567; -} - -int -main () -{ - /* C99 Section 6.7.2 Type specifiers. Type _Bool is - mentioned in this section. Conversions between - BOOL and DFP types. */ - - /* Decimal float to unsigned integer. */ - init_dfp_1 (); - - ui = d32; - if (ui != 456U) - FAILURE - ul = d32; - if (ul != 456UL) - FAILURE - ull = d32; - if (ull != 456ULL) - FAILURE - - ui = d64; - if (ui != 23U) - FAILURE - ul = d64; - if (ul != 23UL) - FAILURE - ull = d64; - if (ull != 23ULL) - FAILURE - - ui = d128; - if (ui != 1234U) - FAILURE - ul = d128; - if (ul != 1234UL) - FAILURE - ull = d128; - if (ull != 1234ULL) - FAILURE - - /* Decimal float to signed integer. */ - - /* Decimal float to BOOL. */ - init_dfp_2 (); - - b = d32; - if (!b) - FAILURE - b = d64; - if (!b) - FAILURE - b = d128; - if (!b) - FAILURE - - /* Unsigned integer to decimal float. */ - init_unsigned_int (); - - d32 = ui; - if (d32 != 987.0df) - FAILURE - d32 = ul; - if (d32 != 345678.0df) - FAILURE - d32 = ull; - if (d32 != 1234567.df) - FAILURE - - d64 = ui; - if (d64 != 987.0dd) - FAILURE - d64 = ul; - if (d64 != 345678.0dd) - FAILURE - d64 = ull; - if (d64 != 1234567.dd) - FAILURE - - d128 = ui; - if (d128 != 987.0dl) - FAILURE - d128 = ul; - if (d128 != 345678.0dl) - FAILURE - d128 = ull; - if (d128 != 1234567.dl) - FAILURE - - /* Signed integer to decimal float. */ - init_signed_int (); - - d32 = si; - if (d32 != -987.0df) - FAILURE - d32 = sl; - if (d32 != -345678.0df) - FAILURE - d32 = sll; - if (d32 != -1234567.df) - FAILURE - - d64 = si; - if (d64 != -987.0dd) - FAILURE - d64 = sl; - if (d64 != -345678.0dd) - FAILURE - d64 = sll; - if (d64 != -1234567.dd) - FAILURE - - d128 = si; - if (d128 != -987.0dl) - FAILURE - d128 = sl; - if (d128 != -345678.0dl) - FAILURE - d128 = sll; - if (d128 != -1234567.dl) - FAILURE - - /* BOOL to decimal float. */ - init_dfp_3 (); - - b = d32; - if (b) - FAILURE - b = d64; - if (b) - FAILURE - b = d128; - if (b) - FAILURE - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/convert.h b/gcc/testsuite/gcc.dg/dfp/convert.h deleted file mode 100644 index 304164ff627..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/convert.h +++ /dev/null @@ -1,462 +0,0 @@ -#include "dfp-dbg.h" - -/* Macros are set up to skip using long double, which doesn't necessarily - map to TF mode. If there's a reason to skip those for a test, the - test itself can define USE_TF to be zero. */ -#ifndef USE_TF -#define USE_TF 1 -#endif - -/* Provide more information with FAILURE than what is available with - the version of that macro in dfp-dbg.h. */ - -#undef FAILURE -#if defined(DBG) || defined(DBG2) -#include -#define FAILURE(NUM) \ - { printf ("failed for test %s\n", NUM); failures++; } -#else -#define FAILURE(N) __builtin_abort (); -#endif - -/* This is useful when modifying the test to make sure that tests are - actually run. */ -#if defined(DBG2) -#define REPORT(NUM) \ - { printf ("%s\n", NUM); } -#else -#define REPORT(N) ; -#endif - -#define CONVERT_VALID(NUM,FROM,TO,FROMVAL,TOVAL,DIFF) \ -void \ -convert_##NUM (void) \ -{ \ - REPORT(#NUM " " #FROMVAL) \ - FROM = FROMVAL; \ - TO = FROM; \ - if (TO < (TOVAL - DIFF) || TO > (TOVAL + DIFF)) \ - FAILURE (#NUM); \ -} - -#define CONVERT_TO_PINF(NUM,FROM,TO,FROMVAL,TOSUFFIX) \ -void \ -convert_##NUM (void) \ -{ \ - REPORT(#NUM " " #FROMVAL) \ - FROM = FROMVAL; \ - TO = FROM; \ - if (__builtin_isinf##TOSUFFIX (TO) == 0) \ - FAILURE (#NUM " pinf: isinf"); \ - if (__builtin_signbit##TOSUFFIX (TO) != 0) \ - FAILURE (#NUM " pinf: sign"); \ -} - -#define CONVERT_TO_MINF(NUM,FROM,TO,FROMVAL,TOSUFFIX) \ -void \ -convert_##NUM (void) \ -{ \ - REPORT(#NUM " " #FROMVAL) \ - FROM = FROMVAL; \ - TO = FROM; \ - if (__builtin_isinf##TOSUFFIX (TO) == 0) \ - FAILURE (#NUM " pinf: isinf"); \ - if (__builtin_signbit##TOSUFFIX (TO) == 0) \ - FAILURE (#NUM " pinf: sign"); \ -} - -#define CONVERT_TO_PZERO(NUM,FROM,TO,FROMVAL,TOVAL,TOSUFFIX) \ -void \ -convert_##NUM (void) \ -{ \ - REPORT(#NUM " " #FROMVAL) \ - FROM = FROMVAL; \ - TO = FROM; \ - if (TO != TOVAL) \ - FAILURE (#NUM "_pzero: zero") \ - if (__builtin_signbit##TOSUFFIX (TO) != 0) \ - FAILURE (#NUM " _pzero: sign"); \ -} - -#define CONVERT_TO_MZERO(NUM,FROM,TO,FROMVAL,TOVAL,TOSUFFIX) \ -void \ -convert_##NUM (void) \ -{ \ - REPORT(#NUM " " #FROMVAL) \ - FROM = FROMVAL; \ - TO = FROM; \ - if (TO != TOVAL) \ - FAILURE (#NUM "_mzero: zero") \ - if (__builtin_signbit##TOSUFFIX (TO) == 0) \ - FAILURE (#NUM " _mzero: sign"); \ -} - -#define CONVERT_NAN(NUM,FROM,TO,FROMSUFFIX,TOSUFFIX) \ -void \ -convert_##NUM##_nan (void) \ -{ \ - REPORT(#NUM "_nan") \ - FROM = __builtin_nan##FROMSUFFIX (""); \ - TO = FROM; \ - if (__builtin_isnan##TOSUFFIX (TO) == 0) \ - FAILURE (#NUM " nan"); \ -} - -#define CONVERT_PINF(NUM,FROM,TO,FROMSUFFIX,TOSUFFIX) \ -void \ -convert_##NUM##_pinf (void) \ -{ \ - REPORT (#NUM "_pinf") \ - FROM = __builtin_inf##FROMSUFFIX (); \ - TO = FROM; \ - if (__builtin_isinf##TOSUFFIX (TO) == 0) \ - FAILURE (#NUM " pinf: isinf"); \ - if (__builtin_signbit##TOSUFFIX (TO) != 0) \ - FAILURE (#NUM " pinf: sign"); \ -} - -#define CONVERT_MINF(NUM,FROM,TO,FROMSUFFIX,TOSUFFIX) \ -void \ -convert_##NUM##_minf (void) \ -{ \ - REPORT (#NUM "_minf") \ - FROM = -__builtin_inf##FROMSUFFIX (); \ - TO = FROM; \ - if (__builtin_isinf##TOSUFFIX (TO) == 0) \ - FAILURE (#NUM " minf: isinf"); \ - if (__builtin_signbit##TOSUFFIX (TO) == 0) \ - FAILURE (#NUM " minf: sign"); \ -} - -#define CONVERT_PZERO(NUM,FROM,TO,FROMVALUE,TOVALUE,TOSUFFIX) \ -void \ -convert_##NUM##_pzero (void) \ -{ \ - REPORT (#NUM "_pzero") \ - FROM = FROMVALUE; \ - TO = FROM; \ - if (TO != TOVALUE) \ - FAILURE (#NUM "pzero: zero") \ - if (__builtin_signbit##TOSUFFIX (TO) != 0) \ - FAILURE (#NUM " pzero: sign"); \ -} - -#define CONVERT_MZERO(NUM,FROM,TO,FROMVALUE,TOVALUE,TOSUFFIX) \ -void \ -convert_##NUM##_mzero (void) \ -{ \ - REPORT (#NUM "_mzero") \ - FROM = FROMVALUE; \ - TO = FROM; \ - if (TO != TOVALUE) \ - FAILURE (#NUM "mzero: zero") \ - if (__builtin_signbit##TOSUFFIX (TO) == 0) \ - FAILURE (#NUM " mzero: sign"); \ -} - -#define CONVERT_VALID_NOTF(NUM,VAL,DIFF) \ -CONVERT_VALID (NUM##_sdsf, sd, sf, VAL##df, VAL##f, DIFF##f) \ -CONVERT_VALID (NUM##_sddf, sd, df, VAL##df, VAL, DIFF) \ -CONVERT_VALID (NUM##_ddsf, dd, sf, VAL##dd, VAL##f, DIFF##f) \ -CONVERT_VALID (NUM##_dddf, dd, df, VAL##dd, VAL, DIFF) \ -CONVERT_VALID (NUM##_tdsf, td, sf, VAL##dl, VAL##f, DIFF##f) \ -CONVERT_VALID (NUM##_tddf, td, df, VAL##dl, VAL, DIFF) \ -CONVERT_VALID (NUM##_sfsd, sf, sd, VAL##f, VAL##df, DIFF##df) \ -CONVERT_VALID (NUM##_sfdd, sf, dd, VAL##f, VAL##dd, DIFF##dd) \ -CONVERT_VALID (NUM##_sftd, sf, td, VAL##f, VAL##dl, DIFF##dl) \ -CONVERT_VALID (NUM##_dfsd, df, sd, VAL, VAL##df, DIFF##df) \ -CONVERT_VALID (NUM##_dfdd, df, dd, VAL, VAL##dd, DIFF##dd) \ -CONVERT_VALID (NUM##_dftd, df, td, VAL, VAL##dl, DIFF##dl) \ -CONVERT_VALID (NUM##_sddd, sd, dd, VAL##df, VAL##dd, DIFF##dd) \ -CONVERT_VALID (NUM##_sdtd, sd, dd, VAL##df, VAL##dd, DIFF##dd) \ -CONVERT_VALID (NUM##_ddsd, dd, sd, VAL##dd, VAL##df, DIFF##dd) \ -CONVERT_VALID (NUM##_ddtd, dd, td, VAL##dd, VAL##dl, DIFF##dl) \ -CONVERT_VALID (NUM##_tdsd, td, sd, VAL##dl, VAL##df, DIFF##df) \ -CONVERT_VALID (NUM##_tddd, td, dd, VAL##dl, VAL##dd, DIFF##dd) - -#if USE_TF == 0 -#define CONVERT_VALID_TF(NUM,VAL,DIFF) -#else -#define CONVERT_VALID_TF(NUM,VAL,DIFF) \ -CONVERT_VALID (NUM##_sdtf, sd, tf, VAL##df, VAL##l, DIFF##l) \ -CONVERT_VALID (NUM##_tdtf, td, tf, VAL##dl, VAL##l, DIFF##l) \ -CONVERT_VALID (NUM##_ddtf, dd, tf, VAL##dd, VAL##l, DIFF##l) \ -CONVERT_VALID (NUM##_tfsd, tf, sd, VAL##l, VAL##df, DIFF##df) \ -CONVERT_VALID (NUM##_tfdd, tf, dd, VAL##l, VAL##dd, DIFF##dd) \ -CONVERT_VALID (NUM##_tftd, tf, td, VAL##l, VAL##dl, DIFF##dl) -#endif - -#define CONVERT_VALID_ALL(NUM,VAL,DIFF) \ - CONVERT_VALID_NOTF(NUM,VAL,DIFF) \ - CONVERT_VALID_TF(NUM,VAL,DIFF) - -#define CALL_VALID_NOTF(NUM) \ - convert_##NUM##_sdsf (); \ - convert_##NUM##_sddf (); \ - convert_##NUM##_ddsf (); \ - convert_##NUM##_dddf (); \ - convert_##NUM##_tdsf (); \ - convert_##NUM##_tddf (); \ - convert_##NUM##_sfsd (); \ - convert_##NUM##_sfdd (); \ - convert_##NUM##_sftd (); \ - convert_##NUM##_dfsd (); \ - convert_##NUM##_dfdd (); \ - convert_##NUM##_dftd (); \ - convert_##NUM##_sddd (); \ - convert_##NUM##_sdtd (); \ - convert_##NUM##_ddsd (); \ - convert_##NUM##_ddtd (); \ - convert_##NUM##_tdsd (); \ - convert_##NUM##_tddd (); - -#if USE_TF == 0 -#define CALL_VALID_TF(NUM) -#else -#define CALL_VALID_TF(NUM) \ - convert_##NUM##_sdtf (); \ - convert_##NUM##_ddtf (); \ - convert_##NUM##_tdtf (); \ - convert_##NUM##_tfsd (); \ - convert_##NUM##_tfdd (); \ - convert_##NUM##_tftd (); -#endif - -#define CALL_VALID_ALL(NUM) \ - CALL_VALID_NOTF(NUM) \ - CALL_VALID_TF(NUM) - -#define CONVERT_ZEROES(NUM,FROM,TO,FROMVALUE,TOVALUE,TOSUFFIX) \ -CONVERT_PZERO(NUM, FROM, TO, FROMVALUE, TOVALUE, TOSUFFIX) \ -CONVERT_MZERO(NUM, FROM, TO, -FROMVALUE, -TOVALUE, TOSUFFIX) - -#define CONVERT_ZEROES_NOTF(NUM) \ -CONVERT_ZEROES (NUM##_sdsf, sd, sf, 0.0df, 0.0f, f) \ -CONVERT_ZEROES (NUM##_sddf, sd, df, 0.0df, 0.0, ) \ -CONVERT_ZEROES (NUM##_ddsf, dd, sf, 0.0dd, 0.0f, f) \ -CONVERT_ZEROES (NUM##_dddf, dd, df, 0.0dd, 0.0, ) \ -CONVERT_ZEROES (NUM##_tdsf, td, sf, 0.0dl, 0.0f, f) \ -CONVERT_ZEROES (NUM##_tddf, td, df, 0.0dl, 0.0, ) \ -CONVERT_ZEROES (NUM##_sfsd, sf, sd, 0.0f, 0.0df, d32) \ -CONVERT_ZEROES (NUM##_sfdd, sf, dd, 0.0f, 0.0dd, d64) \ -CONVERT_ZEROES (NUM##_sftd, sf, td, 0.0f, 0.0dl, d128) \ -CONVERT_ZEROES (NUM##_dfsd, df, sd, 0.0, 0.0df, d32) \ -CONVERT_ZEROES (NUM##_dfdd, df, dd, 0.0, 0.0dd, d64) \ -CONVERT_ZEROES (NUM##_dftd, df, td, 0.0, 0.0dl, d128) \ -CONVERT_ZEROES (NUM##_sddd, sd, dd, 0.0df, 0.0dd, d64) \ -CONVERT_ZEROES (NUM##_sdtd, sd, td, 0.0dl, 0.0dl, d128) \ -CONVERT_ZEROES (NUM##_ddsd, dd, sd, 0.0dd, 0.0df, d32) \ -CONVERT_ZEROES (NUM##_ddtd, dd, td, 0.0dd, 0.0dl, d128) \ -CONVERT_ZEROES (NUM##_tdsd, td, sd, 0.0dl, 0.0df, d32) \ -CONVERT_ZEROES (NUM##_tddd, td, dd, 0.0dl, 0.0dd, d64) - -#if USE_TF == 0 -#define CONVERT_ZEROES_TF(NUM) -#else -#define CONVERT_ZEROES_TF(NUM) \ -CONVERT_ZEROES (NUM##_sdtf, sd, tf, 0.0df, 0.0l, l) \ -CONVERT_ZEROES (NUM##_ddtf, dd, tf, 0.0dd, 0.0l, l) \ -CONVERT_ZEROES (NUM##_tdtf, td, tf, 0.0dl, 0.0l, l) \ -CONVERT_ZEROES (NUM##_tfsd, tf, sd, 0.0l, 0.0df, d32) \ -CONVERT_ZEROES (NUM##_tfdd, tf, dd, 0.0l, 0.0dd, d64) \ -CONVERT_ZEROES (NUM##_tftd, tf, td, 0.0l, 0.0dl, d128) -#endif - -#define CONVERT_ZEROES_ALL(NUM) \ - CONVERT_ZEROES_NOTF(NUM) \ - CONVERT_ZEROES_TF(NUM) - -#define CALL_ZEROES(NUM) \ - convert_##NUM##_pzero (); \ - convert_##NUM##_mzero (); - -#define CALL_ZEROES_NOTF(NUM) \ - CALL_ZEROES (NUM##_sdsf) \ - CALL_ZEROES (NUM##_sddf) \ - CALL_ZEROES (NUM##_ddsf) \ - CALL_ZEROES (NUM##_dddf) \ - CALL_ZEROES (NUM##_tdsf) \ - CALL_ZEROES (NUM##_tddf) \ - CALL_ZEROES (NUM##_sfsd) \ - CALL_ZEROES (NUM##_sfdd) \ - CALL_ZEROES (NUM##_sftd) \ - CALL_ZEROES (NUM##_dfsd) \ - CALL_ZEROES (NUM##_dfdd) \ - CALL_ZEROES (NUM##_dftd) \ - CALL_ZEROES (NUM##_sddd) \ - CALL_ZEROES (NUM##_sdtd) \ - CALL_ZEROES (NUM##_ddsd) \ - CALL_ZEROES (NUM##_ddtd) \ - CALL_ZEROES (NUM##_tdsd) \ - CALL_ZEROES (NUM##_tddd) - -#if USE_TF == 0 -#define CALL_ZEROES_TF(NUM) -#else -#define CALL_ZEROES_TF(NUM) \ - CALL_ZEROES (NUM##_sdtf) \ - CALL_ZEROES (NUM##_ddtf) \ - CALL_ZEROES (NUM##_tdtf) \ - CALL_ZEROES (NUM##_tfsd) \ - CALL_ZEROES (NUM##_tfdd) \ - CALL_ZEROES (NUM##_tftd) -#endif - -#define CALL_ZEROES_ALL(NUM) \ - CALL_ZEROES_NOTF(NUM) \ - CALL_ZEROES_TF(NUM) - -#define CONVERT_INF(NUM,FROM,TO,FROMSUFFIX,TOSUFFIX) \ -CONVERT_PINF (NUM, FROM, TO, FROMSUFFIX, TOSUFFIX) \ -CONVERT_MINF (NUM, FROM, TO, FROMSUFFIX, TOSUFFIX) - -#define CONVERT_INF_NOTF(NUM) \ -CONVERT_INF (NUM##_sdsf, sd, sf, d32, f) \ -CONVERT_INF (NUM##_sddf, sd, df, d32, ) \ -CONVERT_INF (NUM##_ddsf, dd, sf, d64, f) \ -CONVERT_INF (NUM##_dddf, dd, df, d64, ) \ -CONVERT_INF (NUM##_tdsf, td, sf, d128, f) \ -CONVERT_INF (NUM##_tddf, td, df, d128, ) \ -CONVERT_INF (NUM##_sfsd, sf, sd, f, d32) \ -CONVERT_INF (NUM##_sfdd, sf, dd, f, d64) \ -CONVERT_INF (NUM##_sftd, sf, td, f, d128) \ -CONVERT_INF (NUM##_dfsd, df, sd, , d32) \ -CONVERT_INF (NUM##_dfdd, df, dd, , d64) \ -CONVERT_INF (NUM##_dftd, df, td, , d128) \ -CONVERT_INF (NUM##_sddd, sd, dd, d32, d64) \ -CONVERT_INF (NUM##_sdtd, sd, td, d32, d128) \ -CONVERT_INF (NUM##_ddsd, dd, sd, d64, d32) \ -CONVERT_INF (NUM##_ddtd, dd, td, d64, d128) \ -CONVERT_INF (NUM##_tdsd, td, sd, d128, d32) \ -CONVERT_INF (NUM##_tddd, td, dd, d128, d64) - -#if USE_TF == 0 -#define CONVERT_INF_TF(NUM) -#else -#define CONVERT_INF_TF(NUM) \ -CONVERT_INF (NUM##_sdtf, sd, tf, d32, l) \ -CONVERT_INF (NUM##_ddtf, dd, tf, d64, l) \ -CONVERT_INF (NUM##_tdtf, td, tf, d128, l) \ -CONVERT_INF (NUM##_tfsd, tf, sd, l, d32) \ -CONVERT_INF (NUM##_tfdd, tf, dd, l, d64) \ -CONVERT_INF (NUM##_tftd, tf, td, l, d128) -#endif - -#define CONVERT_INF_ALL(NUM) \ - CONVERT_INF_NOTF(NUM) \ - CONVERT_INF_TF(NUM) - -#define CALL_INF(NUM) \ - convert_##NUM##_pinf (); \ - convert_##NUM##_minf (); - -#define CALL_INF_NOTF(NUM) \ - CALL_INF (NUM##_sdsf) \ - CALL_INF (NUM##_sddf) \ - CALL_INF (NUM##_ddsf) \ - CALL_INF (NUM##_dddf) \ - CALL_INF (NUM##_tdsf) \ - CALL_INF (NUM##_tddf) \ - CALL_INF (NUM##_sfsd) \ - CALL_INF (NUM##_sfdd) \ - CALL_INF (NUM##_sftd) \ - CALL_INF (NUM##_dfsd) \ - CALL_INF (NUM##_dfdd) \ - CALL_INF (NUM##_dftd) \ - CALL_INF (NUM##_sddd) \ - CALL_INF (NUM##_sdtd) \ - CALL_INF (NUM##_ddsd) \ - CALL_INF (NUM##_ddtd) \ - CALL_INF (NUM##_tdsd) \ - CALL_INF (NUM##_tddd) - -#if USE_TF == 0 -#define CALL_INF_TF(NUM) -#else -#define CALL_INF_TF(NUM) \ - CALL_INF (NUM##_sdtf) \ - CALL_INF (NUM##_ddtf) \ - CALL_INF (NUM##_tdtf) \ - CALL_INF (NUM##_tfsd) \ - CALL_INF (NUM##_tfdd) \ - CALL_INF (NUM##_tftd) -#endif - -#define CALL_INF_ALL(NUM) \ - CALL_INF_NOTF(NUM) \ - CALL_INF_TF(NUM) - -#define CONVERT_NAN_NOTF(NUM) \ -CONVERT_NAN (NUM##_sdsf, sd, sf, d32, f) \ -CONVERT_NAN (NUM##_sddf, sd, df, d32, ) \ -CONVERT_NAN (NUM##_ddsf, dd, sf, d64, f) \ -CONVERT_NAN (NUM##_dddf, dd, df, d64, ) \ -CONVERT_NAN (NUM##_tdsf, td, sf, d128, f) \ -CONVERT_NAN (NUM##_tddf, td, df, d128, ) \ -CONVERT_NAN (NUM##_sfsd, sf, sd, f, d32) \ -CONVERT_NAN (NUM##_sfdd, sf, dd, f, d64) \ -CONVERT_NAN (NUM##_sftd, sf, td, f, d128) \ -CONVERT_NAN (NUM##_dfsd, df, sd, , d32) \ -CONVERT_NAN (NUM##_dfdd, df, dd, , d64) \ -CONVERT_NAN (NUM##_dftd, df, td, , d128) \ -CONVERT_NAN (NUM##_sddd, sd, dd, d32, d64) \ -CONVERT_NAN (NUM##_sdtd, sd, td, d32, d128) \ -CONVERT_NAN (NUM##_ddsd, dd, sd, d64, d32) \ -CONVERT_NAN (NUM##_ddtd, dd, td, d64, d128) \ -CONVERT_NAN (NUM##_tdsd, td, sd, d128, d32) \ -CONVERT_NAN (NUM##_tddd, td, dd, d128, d64) - -#if USE_TF == 0 -#define CONVERT_NAN_TF(NUM) -#else -#define CONVERT_NAN_TF(NUM) \ -CONVERT_NAN (NUM##_sdtf, sd, tf, d32, l) \ -CONVERT_NAN (NUM##_ddtf, dd, tf, d64, l) \ -CONVERT_NAN (NUM##_tdtf, td, tf, d128, l) \ -CONVERT_NAN (NUM##_tfsd, tf, sd, l, d32) \ -CONVERT_NAN (NUM##_tfdd, tf, dd, l, d64) \ -CONVERT_NAN (NUM##_tftd, tf, td, l, d128) -#endif - -#define CONVERT_NAN_ALL(NUM) \ - CONVERT_NAN_NOTF(NUM) \ - CONVERT_NAN_TF(NUM) - -#define CALL_NAN(NUM) \ - convert_##NUM##_nan (); - -#define CALL_NAN_NOTF(NUM) \ - CALL_NAN (NUM##_sdsf) \ - CALL_NAN (NUM##_sddf) \ - CALL_NAN (NUM##_ddsf) \ - CALL_NAN (NUM##_dddf) \ - CALL_NAN (NUM##_tdsf) \ - CALL_NAN (NUM##_tddf) \ - CALL_NAN (NUM##_sfsd) \ - CALL_NAN (NUM##_sfdd) \ - CALL_NAN (NUM##_sftd) \ - CALL_NAN (NUM##_dfsd) \ - CALL_NAN (NUM##_dfdd) \ - CALL_NAN (NUM##_dftd) \ - CALL_NAN (NUM##_sddd) \ - CALL_NAN (NUM##_sdtd) \ - CALL_NAN (NUM##_ddsd) \ - CALL_NAN (NUM##_ddtd) \ - CALL_NAN (NUM##_tdsd) \ - CALL_NAN (NUM##_tddd) - -#if USE_TF == 0 -#define CALL_NAN_TF(NUM) -#else -#define CALL_NAN_TF(NUM) \ - CALL_NAN (NUM##_sdtf) \ - CALL_NAN (NUM##_ddtf) \ - CALL_NAN (NUM##_tdtf) \ - CALL_NAN (NUM##_tfsd) \ - CALL_NAN (NUM##_tfdd) \ - CALL_NAN (NUM##_tftd) -#endif - -#define CALL_NAN_ALL(NUM) \ - CALL_NAN_NOTF(NUM) \ - CALL_NAN_TF(NUM) diff --git a/gcc/testsuite/gcc.dg/dfp/dfp.exp b/gcc/testsuite/gcc.dg/dfp/dfp.exp index ce6668fb66f..73edb7fc13e 100644 --- a/gcc/testsuite/gcc.dg/dfp/dfp.exp +++ b/gcc/testsuite/gcc.dg/dfp/dfp.exp @@ -48,9 +48,12 @@ set DEFAULT_CFLAGS "-std=gnu99" # Initialize `dg'. dg-init -# Main loop. +# Main loop; run the C-only tests. dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] \ "" $DEFAULT_CFLAGS +# Run the tests that are shared with C++ testing. +dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/dfp/*c]] \ + "" $DEFAULT_CFLAGS # All done. dg-finish diff --git a/gcc/testsuite/gcc.dg/dfp/func-array.c b/gcc/testsuite/gcc.dg/dfp/func-array.c deleted file mode 100644 index 6d158f35523..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/func-array.c +++ /dev/null @@ -1,157 +0,0 @@ -/* C99 6.5.2.2 Function calls. - Test passing array elements involving decimal floating point types. */ - -#include "dfp-dbg.h" - -/* A handful of functions that return the Nth _Decimal32 argument of - an incoming array. */ - -_Decimal32 -arg0_32 (_Decimal32 args[]) -{ - return args[0]; -} - -_Decimal32 -arg1_32 (_Decimal32 args[]) -{ - return args[1]; -} - -_Decimal32 -arg2_32 (_Decimal32 args[]) -{ - return args[2]; -} - -_Decimal32 -arg3_32 (_Decimal32 args[]) -{ - return args[3]; -} - -_Decimal32 -arg4_32 (_Decimal32 args[]) -{ - return args[4]; -} - -_Decimal32 -arg5_32 (_Decimal32 args[]) -{ - return args[5]; -} - - -/* A handful of functions that return the Nth _Decimal64 argument of - an incoming array. */ - -_Decimal64 -arg0_64 (_Decimal64 args[]) -{ - return args[0]; -} - -_Decimal64 -arg1_64 (_Decimal64 args[]) -{ - return args[1]; -} - -_Decimal64 -arg2_64 (_Decimal64 args[]) -{ - return args[2]; -} - -_Decimal64 -arg3_64 (_Decimal64 args[]) -{ - return args[3]; -} - -_Decimal64 -arg4_64 (_Decimal64 args[]) -{ - return args[4]; -} - -_Decimal64 -arg5_64 (_Decimal64 args[]) -{ - return args[5]; -} - - -/* A handful of functions that return the Nth _Decimal128 argument of - an incoming array. */ - -_Decimal128 -arg0_128 (_Decimal128 args[]) -{ - return args[0]; -} - -_Decimal128 -arg1_128 (_Decimal128 args[]) -{ - return args[1]; -} - -_Decimal128 -arg2_128 (_Decimal128 args[]) -{ - return args[2]; -} - -_Decimal128 -arg3_128 (_Decimal128 args[]) -{ - return args[3]; -} - -_Decimal128 -arg4_128 (_Decimal128 args[]) -{ - return args[4]; -} - -_Decimal128 -arg5_128 (_Decimal128 args[]) -{ - return args[5]; -} - - -int main() -{ - _Decimal32 d32[] = { 0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df }; - _Decimal64 d64[] = { 0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd }; - _Decimal128 d128[] = { 0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl }; - - /* _Decimal32 variants. */ - if (arg0_32 (d32) != 0.0df) FAILURE - if (arg1_32 (d32) != 1.0df) FAILURE - if (arg2_32 (d32) != 2.0df) FAILURE - if (arg3_32 (d32) != 3.0df) FAILURE - if (arg4_32 (d32) != 4.0df) FAILURE - if (arg5_32 (d32) != 5.0df) FAILURE - - /* _Decimal64 variants. */ - if (arg0_64 (d64) != 0.0dd) FAILURE - if (arg1_64 (d64) != 1.0dd) FAILURE - if (arg2_64 (d64) != 2.0dd) FAILURE - if (arg3_64 (d64) != 3.0dd) FAILURE - if (arg4_64 (d64) != 4.0dd) FAILURE - if (arg5_64 (d64) != 5.0dd) FAILURE - - /* _Decimal128 variants. */ - if (arg0_128 (d128) != 0.0dl) FAILURE - if (arg1_128 (d128) != 1.0dl) FAILURE - if (arg2_128 (d128) != 2.0dl) FAILURE - if (arg3_128 (d128) != 3.0dl) FAILURE - if (arg4_128 (d128) != 4.0dl) FAILURE - if (arg5_128 (d128) != 5.0dl) FAILURE - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/func-deref.c b/gcc/testsuite/gcc.dg/dfp/func-deref.c deleted file mode 100644 index 81a48a9f8e8..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/func-deref.c +++ /dev/null @@ -1,205 +0,0 @@ -/* C99 6.5.2.2 Function calls. - Test scalar passing and return values involving decimal floating - point types and dereferenced pointers. */ - -#include "dfp-dbg.h" - -/* A handful of functions that return their Nth _Decimal32 - argument. */ - -_Decimal32 __attribute__((noinline)) -arg0_32 (_Decimal32 arg0, _Decimal32 arg1, _Decimal32 arg2, - _Decimal32 arg3, _Decimal32 arg4, _Decimal32 arg5) -{ - return arg0; -} - -_Decimal32 __attribute__((noinline)) -arg1_32 (_Decimal32 arg0, _Decimal32 arg1, _Decimal32 arg2, - _Decimal32 arg3, _Decimal32 arg4, _Decimal32 arg5) -{ - return arg1; -} - -_Decimal32 __attribute__((noinline)) -arg2_32 (_Decimal32 arg0, _Decimal32 arg1, _Decimal32 arg2, - _Decimal32 arg3, _Decimal32 arg4, _Decimal32 arg5) -{ - return arg2; -} - -_Decimal32 __attribute__((noinline)) -arg3_32 (_Decimal32 arg0, _Decimal32 arg1, _Decimal32 arg2, - _Decimal32 arg3, _Decimal32 arg4, _Decimal32 arg5) -{ - return arg3; -} - -_Decimal32 __attribute__((noinline)) -arg4_32 (_Decimal32 arg0, _Decimal32 arg1, _Decimal32 arg2, - _Decimal32 arg3, _Decimal32 arg4, _Decimal32 arg5) -{ - return arg4; -} - -_Decimal32 __attribute__((noinline)) -arg5_32 (_Decimal32 arg0, _Decimal32 arg1, _Decimal32 arg2, - _Decimal32 arg3, _Decimal32 arg4, _Decimal32 arg5) -{ - return arg5; -} - - -/* A handful of functions that return their Nth _Decimal64 - argument. */ - -_Decimal64 __attribute__((noinline)) -arg0_64 (_Decimal64 arg0, _Decimal64 arg1, _Decimal64 arg2, - _Decimal64 arg3, _Decimal64 arg4, _Decimal64 arg5) -{ - return arg0; -} - -_Decimal64 __attribute__((noinline)) -arg1_64 (_Decimal64 arg0, _Decimal64 arg1, _Decimal64 arg2, - _Decimal64 arg3, _Decimal64 arg4, _Decimal64 arg5) -{ - return arg1; -} - -_Decimal64 __attribute__((noinline)) -arg2_64 (_Decimal64 arg0, _Decimal64 arg1, _Decimal64 arg2, - _Decimal64 arg3, _Decimal64 arg4, _Decimal64 arg5) -{ - return arg2; -} - -_Decimal64 __attribute__((noinline)) -arg3_64 (_Decimal64 arg0, _Decimal64 arg1, _Decimal64 arg2, - _Decimal64 arg3, _Decimal64 arg4, _Decimal64 arg5) -{ - return arg3; -} - -_Decimal64 __attribute__((noinline)) -arg4_64 (_Decimal64 arg0, _Decimal64 arg1, _Decimal64 arg2, - _Decimal64 arg3, _Decimal64 arg4, _Decimal64 arg5) -{ - return arg4; -} - -_Decimal64 __attribute__((noinline)) -arg5_64 (_Decimal64 arg0, _Decimal64 arg1, _Decimal64 arg2, - _Decimal64 arg3, _Decimal64 arg4, _Decimal64 arg5) -{ - return arg5; -} - - -/* A handful of functions that return their Nth _Decimal128 - argument. */ - -_Decimal128 __attribute__((noinline)) -arg0_128 (_Decimal128 arg0, _Decimal128 arg1, _Decimal128 arg2, - _Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5) -{ - return arg0; -} - -_Decimal128 __attribute__((noinline)) -arg1_128 (_Decimal128 arg0, _Decimal128 arg1, _Decimal128 arg2, - _Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5) -{ - return arg1; -} - -_Decimal128 __attribute__((noinline)) -arg2_128 (_Decimal128 arg0, _Decimal128 arg1, _Decimal128 arg2, - _Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5) -{ - return arg2; -} - -_Decimal128 __attribute__((noinline)) -arg3_128 (_Decimal128 arg0, _Decimal128 arg1, _Decimal128 arg2, - _Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5) -{ - return arg3; -} - -_Decimal128 __attribute__((noinline)) -arg4_128 (_Decimal128 arg0, _Decimal128 arg1, _Decimal128 arg2, - _Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5) -{ - return arg4; -} - -_Decimal128 __attribute__((noinline)) -arg5_128 (_Decimal128 arg0, _Decimal128 arg1, _Decimal128 arg2, - _Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5) -{ - return arg5; -} - - - -_Decimal32 df0 = 0.0df, df1 = 1.0df, df2 = 2.0df, - df3 = 3.0df, df4 = 4.0df, df5 = 5.0df; -_Decimal32 *pdf0 = &df0, *pdf1 = &df1, *pdf2 = &df2, - *pdf3 = &df3, *pdf4 = &df4, *pdf5 = &df5; -_Decimal64 dd0 = 0.0dd, dd1 = 1.0dd, dd2 = 2.0dd, - dd3 = 3.0dd, dd4 = 4.0dd, dd5 = 5.0dd; -_Decimal64 *pdd0 = &dd0, *pdd1 = &dd1, *pdd2 = &dd2, - *pdd3 = &dd3, *pdd4 = &dd4, *pdd5 = &dd5; -_Decimal128 dl0 = 0.0dl, dl1 = 1.0dl, dl2 = 2.0dl, - dl3 = 3.0dl, dl4 = 4.0dl, dl5 = 5.0dl; -_Decimal128 *pdl0 = &dl0, *pdl1 = &dl1, *pdl2 = &dl2, - *pdl3 = &dl3, *pdl4 = &dl4, *pdl5 = &dl5; - -int -main () -{ - /* _Decimal32 variants. */ - if (arg0_32 (*pdf0, *pdf1, *pdf2, *pdf3, *pdf4, *pdf5) != 0.0df) - FAILURE - if (arg1_32 (*pdf0, *pdf1, *pdf2, *pdf3, *pdf4, *pdf5) != 1.0df) - FAILURE - if (arg2_32 (*pdf0, *pdf1, *pdf2, *pdf3, *pdf4, *pdf5) != 2.0df) - FAILURE - if (arg3_32 (*pdf0, *pdf1, *pdf2, *pdf3, *pdf4, *pdf5) != 3.0df) - FAILURE - if (arg4_32 (*pdf0, *pdf1, *pdf2, *pdf3, *pdf4, *pdf5) != 4.0df) - FAILURE - if (arg5_32 (*pdf0, *pdf1, *pdf2, *pdf3, *pdf4, *pdf5) != 5.0df) - FAILURE - - /* _Decimal64 variants. */ - if (arg0_64 (*pdd0, *pdd1, *pdd2, *pdd3, *pdd4, *pdd5) != 0.0dd) - FAILURE - if (arg1_64 (*pdd0, *pdd1, *pdd2, *pdd3, *pdd4, *pdd5) != 1.0dd) - FAILURE - if (arg2_64 (*pdd0, *pdd1, *pdd2, *pdd3, *pdd4, *pdd5) != 2.0dd) - FAILURE - if (arg3_64 (*pdd0, *pdd1, *pdd2, *pdd3, *pdd4, *pdd5) != 3.0dd) - FAILURE - if (arg4_64 (*pdd0, *pdd1, *pdd2, *pdd3, *pdd4, *pdd5) != 4.0dd) - FAILURE - if (arg5_64 (*pdd0, *pdd1, *pdd2, *pdd3, *pdd4, *pdd5) != 5.0dd) - FAILURE - - /* _Decimal128 variants. */ - if (arg0_128 (*pdl0, *pdl1, *pdl2, *pdl3, *pdl4, *pdl5) != 0.0dl) - FAILURE - if (arg1_128 (*pdl0, *pdl1, *pdl2, *pdl3, *pdl4, *pdl5) != 1.0dl) - FAILURE - if (arg2_128 (*pdl0, *pdl1, *pdl2, *pdl3, *pdl4, *pdl5) != 2.0dl) - FAILURE - if (arg3_128 (*pdl0, *pdl1, *pdl2, *pdl3, *pdl4, *pdl5) != 3.0dl) - FAILURE - if (arg4_128 (*pdl0, *pdl1, *pdl2, *pdl3, *pdl4, *pdl5) != 4.0dl) - FAILURE - if (arg5_128 (*pdl0, *pdl1, *pdl2, *pdl3, *pdl4, *pdl5) != 5.0dl) - FAILURE - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/func-mixed.c b/gcc/testsuite/gcc.dg/dfp/func-mixed.c deleted file mode 100644 index 6f7e2eb4157..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/func-mixed.c +++ /dev/null @@ -1,174 +0,0 @@ -/* { dg-options "-Wall" } */ - -/* C99 6.5.2.2 Function calls. - Test scalar passing and return values involving decimal floating - point types. */ - -#include "dfp-dbg.h" - -/* A handful of functions that return their Nth _Decimal32 - argument with mixed types in parameter list. */ - -_Decimal32 -arg0_32 (_Decimal32 arg0, int arg1, unsigned int arg2, - float arg3, double arg4, long double arg5) -{ - return arg0; -} - -_Decimal32 -arg1_32 (int arg0, _Decimal32 arg1, unsigned int arg2, - float arg3, double arg4, long double arg5) -{ - return arg1; -} - -_Decimal32 -arg2_32 (int arg0, unsigned int arg1, _Decimal32 arg2, - float arg3, double arg4, long double arg5) -{ - return arg2; -} - - -_Decimal32 -arg3_32 (int arg0, unsigned int arg1, float arg2, - _Decimal32 arg3, double arg4, long double arg5) -{ - return arg3; -} - -_Decimal32 -arg4_32 (int arg0, unsigned int arg1, float arg2, - double arg3, _Decimal32 arg4, long double arg5) -{ - return arg4; -} - -_Decimal32 -arg5_32 (int arg0, unsigned int arg1, float arg2, - double arg3, long double arg4, _Decimal32 arg5) -{ - return arg5; -} - -/* A handful of functions that return their Nth _Decimal64 - argument with mixed types in parameter list. */ - -_Decimal64 -arg0_64 (_Decimal64 arg0, int arg1, unsigned int arg2, - float arg3, double arg4, long double arg5) -{ - return arg0; -} - -_Decimal64 -arg1_64 (int arg0, _Decimal64 arg1, unsigned int arg2, - float arg3, double arg4, long double arg5) -{ - return arg1; -} - -_Decimal64 -arg2_64 (int arg0, unsigned int arg1, _Decimal64 arg2, - float arg3, double arg4, long double arg5) -{ - return arg2; -} - -_Decimal64 -arg3_64 (int arg0, unsigned int arg1, float arg2, - _Decimal64 arg3, double arg4, long double arg5) -{ - return arg3; -} - -_Decimal64 -arg4_64 (int arg0, unsigned int arg1, float arg2, - float arg3, _Decimal64 arg4, long double arg5) -{ - return arg4; -} - -_Decimal64 -arg5_64 (int arg0, unsigned int arg1, float arg2, - double arg3, long double arg4, _Decimal64 arg5) -{ - return arg5; -} - -/* A handful of functions that return their Nth _Decimal128 - argument with mixed types in parameter list. */ - -_Decimal128 -arg0_128 (_Decimal128 arg0, int arg1, unsigned int arg2, - float arg3, double arg4, long double arg5) -{ - return arg0; -} -_Decimal128 -arg1_128 (int arg0, _Decimal128 arg1, unsigned int arg2, - float arg3, double arg4, long double arg5) -{ - return arg1; -} - -_Decimal128 -arg2_128 (int arg0, unsigned int arg1, _Decimal128 arg2, - float arg3, double arg4, long double arg5) -{ - return arg2; -} - -_Decimal128 -arg3_128 (int arg0, unsigned int arg1, float arg2, - _Decimal128 arg3, double arg4, long double arg5) -{ - return arg3; -} - -_Decimal128 -arg4_128 (int arg0, unsigned int arg1, float arg2, - float arg3, _Decimal32 arg4, long double arg5) -{ - return arg4; -} - -_Decimal128 -arg5_128 (int arg0, unsigned int arg1, float arg2, - double arg3, long double arg4, _Decimal128 arg5) -{ - return arg5; -} - - - -int -main () -{ - /* _Decimal32 variants. */ - if (arg0_32 (0.0df, -1, 2, 3.0f, 4.0, 5.0l) != 0.0df) FAILURE - if (arg1_32 (0, 1.0df, 2, 3.0f, 4.0, 5.0l) != 1.0df) FAILURE - if (arg2_32 (0, -1, 2.0df, 3.0f, 4.0, 5.0l) != 2.0df) FAILURE - if (arg3_32 (0, -1, 2.0f, 3.0df, 4.0, 5.0l) != 3.0df) FAILURE - if (arg4_32 (0, -1, 2.0f, 3.0, 4.0df, 5.0l) != 4.0df) FAILURE - if (arg5_32 (0, -1, 2.0f, 3.0, 4.0l, 5.0df) != 5.0df) FAILURE - - /* _Decimal64 variants. */ - if (arg0_64 (0.0dd, -1, 2, 3.0f, 4.0, 5.0l) != 0.0dd) FAILURE - if (arg1_64 (0, 1.0dd, 2, 3.0f, 4.0, 5.0l) != 1.0dd) FAILURE - if (arg2_64 (0, -1, 2.0dd, 3.0f, 4.0, 5.0l) != 2.0dd) FAILURE - if (arg3_64 (0, -1, 2.0f, 3.0dd, 4.0, 5.0l) != 3.0dd) FAILURE - if (arg4_64 (0, -1, 2.0f, 3.0, 4.0dd, 5.0l) != 4.0dd) FAILURE - if (arg5_64 (0, -1, 2.0f, 3.0, 4.0l, 5.0dd) != 5.0dd) FAILURE - - /* _Decimal128 variants. */ - if (arg0_128 (0.0dl, -1, 2, 3.0f, 4.0, 5.0l) != 0.0dl) FAILURE - if (arg1_128 (0, 1.0dl, 2, 3.0f, 4.0, 5.0l) != 1.0dl) FAILURE - if (arg2_128 (0, -1, 2.0dl, 3.0f, 4.0, 5.0l) != 2.0dl) FAILURE - if (arg3_128 (0, -1, 2.0f, 3.0dl, 4.0, 5.0l) != 3.0dl) FAILURE - if (arg4_128 (0, -1, 2.0f, 3.0, 4.0dl, 5.0l) != 4.0dl) FAILURE - if (arg5_128 (0, -1, 2.0f, 3.0, 4.0l, 5.0dl) != 5.0dl) FAILURE - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/func-pointer.c b/gcc/testsuite/gcc.dg/dfp/func-pointer.c deleted file mode 100644 index cfdf2356c9d..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/func-pointer.c +++ /dev/null @@ -1,205 +0,0 @@ -/* C99 6.5.2.2 Function calls. - Test pointer argument passing and return values involving decimal floating - point types. */ - -#include "dfp-dbg.h" - -/* A handful of functions that return their Nth pointer to Decimal32 - argument. */ - -_Decimal32 * -arg0_32 (_Decimal32 *arg0, _Decimal32 *arg1, _Decimal32 *arg2, - _Decimal32 *arg3, _Decimal32 *arg4, _Decimal32 *arg5) -{ - return arg0; -} - -_Decimal32 * -arg1_32 (_Decimal32 *arg0, _Decimal32 *arg1, _Decimal32 *arg2, - _Decimal32 *arg3, _Decimal32 *arg4, _Decimal32 *arg5) -{ - return arg1; -} - -_Decimal32 * -arg2_32 (_Decimal32 *arg0, _Decimal32 *arg1, _Decimal32 *arg2, - _Decimal32 *arg3, _Decimal32 *arg4, _Decimal32 *arg5) -{ - return arg2; -} - -_Decimal32 * -arg3_32 (_Decimal32 *arg0, _Decimal32 *arg1, _Decimal32 *arg2, - _Decimal32 *arg3, _Decimal32 *arg4, _Decimal32 *arg5) -{ - return arg3; -} - -_Decimal32 * -arg4_32 (_Decimal32 *arg0, _Decimal32 *arg1, _Decimal32 *arg2, - _Decimal32 *arg3, _Decimal32 *arg4, _Decimal32 *arg5) -{ - return arg4; -} - -_Decimal32 * -arg5_32 (_Decimal32 *arg0, _Decimal32 *arg1, _Decimal32 *arg2, - _Decimal32 *arg3, _Decimal32 *arg4, _Decimal32 *arg5) -{ - return arg5; -} - - -/* A handful of functions that return their Nth pointer to _Decimal64 - argument. */ - -_Decimal64 * -arg0_64 (_Decimal64 *arg0, _Decimal64 *arg1, _Decimal64 *arg2, - _Decimal64 *arg3, _Decimal64 *arg4, _Decimal64 *arg5) -{ - return arg0; -} - -_Decimal64 * -arg1_64 (_Decimal64 *arg0, _Decimal64 *arg1, _Decimal64 *arg2, - _Decimal64 *arg3, _Decimal64 *arg4, _Decimal64 *arg5) -{ - return arg1; -} - -_Decimal64 * -arg2_64 (_Decimal64 *arg0, _Decimal64 *arg1, _Decimal64 *arg2, - _Decimal64 *arg3, _Decimal64 *arg4, _Decimal64 *arg5) -{ - return arg2; -} - -_Decimal64 * -arg3_64 (_Decimal64 *arg0, _Decimal64 *arg1, _Decimal64 *arg2, - _Decimal64 *arg3, _Decimal64 *arg4, _Decimal64 *arg5) -{ - return arg3; -} - -_Decimal64 * -arg4_64 (_Decimal64 *arg0, _Decimal64 *arg1, _Decimal64 *arg2, - _Decimal64 *arg3, _Decimal64 *arg4, _Decimal64 *arg5) -{ - return arg4; -} - -_Decimal64 * -arg5_64 (_Decimal64 *arg0, _Decimal64 *arg1, _Decimal64 *arg2, - _Decimal64 *arg3, _Decimal64 *arg4, _Decimal64 *arg5) -{ - return arg5; -} - - -/* A handful of functions that return their Nth _Decimal128 - argument. */ - -_Decimal128 * -arg0_128 (_Decimal128 *arg0, _Decimal128 *arg1, _Decimal128 *arg2, - _Decimal128 *arg3, _Decimal128 *arg4, _Decimal128 *arg5) -{ - return arg0; -} - -_Decimal128 * -arg1_128 (_Decimal128 *arg0, _Decimal128 *arg1, _Decimal128 *arg2, - _Decimal128 *arg3, _Decimal128 *arg4, _Decimal128 *arg5) -{ - return arg1; -} - -_Decimal128 * -arg2_128 (_Decimal128 *arg0, _Decimal128 *arg1, _Decimal128 *arg2, - _Decimal128 *arg3, _Decimal128 *arg4, _Decimal128 *arg5) -{ - return arg2; -} - -_Decimal128 * -arg3_128 (_Decimal128 *arg0, _Decimal128 *arg1, _Decimal128 *arg2, - _Decimal128 *arg3, _Decimal128 *arg4, _Decimal128 *arg5) -{ - return arg3; -} - -_Decimal128 * -arg4_128 (_Decimal128 *arg0, _Decimal128 *arg1, _Decimal128 *arg2, - _Decimal128 *arg3, _Decimal128 *arg4, _Decimal128 *arg5) -{ - return arg4; -} - -_Decimal128 * -arg5_128 (_Decimal128 *arg0, _Decimal128 *arg1, _Decimal128 *arg2, - _Decimal128 *arg3, _Decimal128 *arg4, _Decimal128 *arg5) -{ - return arg5; -} - - - -_Decimal32 df0 = 0.0df, df1 = 1.0df, df2 = 2.0df, - df3 = 3.0df, df4 = 4.0df, df5 = 5.0df; -_Decimal32 *pdf0 = &df0, *pdf1 = &df1, *pdf2 = &df2, - *pdf3 = &df3, *pdf4 = &df4, *pdf5 = &df5; -_Decimal64 dd0 = 0.0dd, dd1 = 1.0dd, dd2 = 2.0dd, - dd3 = 3.0dd, dd4 = 4.0dd, dd5 = 5.0dd; -_Decimal64 *pdd0 = &dd0, *pdd1 = &dd1, *pdd2 = &dd2, - *pdd3 = &dd3, *pdd4 = &dd4, *pdd5 = &dd5; -_Decimal128 dl0 = 0.0dl, dl1 = 1.0dl, dl2 = 2.0dl, - dl3 = 3.0dl, dl4 = 4.0dl, dl5 = 5.0dl; -_Decimal128 *pdl0 = &dl0, *pdl1 = &dl1, *pdl2 = &dl2, - *pdl3 = &dl3, *pdl4 = &dl4, *pdl5 = &dl5; - -int -main () -{ - /* _Decimal32 variants. */ - if (*arg0_32 (pdf0, pdf1, pdf2, pdf3, pdf4, pdf5) != 0.0df) - FAILURE - if (*arg1_32 (pdf0, pdf1, pdf2, pdf3, pdf4, pdf5) != 1.0df) - FAILURE - if (*arg2_32 (pdf0, pdf1, pdf2, pdf3, pdf4, pdf5) != 2.0df) - FAILURE - if (*arg3_32 (pdf0, pdf1, pdf2, pdf3, pdf4, pdf5) != 3.0df) - FAILURE - if (*arg4_32 (pdf0, pdf1, pdf2, pdf3, pdf4, pdf5) != 4.0df) - FAILURE - if (*arg5_32 (pdf0, pdf1, pdf2, pdf3, pdf4, pdf5) != 5.0df) - FAILURE - - /* _Decimal64 variants. */ - if (*arg0_64 (pdd0, pdd1, pdd2, pdd3, pdd4, pdd5) != 0.0dd) - FAILURE - if (*arg1_64 (pdd0, pdd1, pdd2, pdd3, pdd4, pdd5) != 1.0dd) - FAILURE - if (*arg2_64 (pdd0, pdd1, pdd2, pdd3, pdd4, pdd5) != 2.0dd) - FAILURE - if (*arg3_64 (pdd0, pdd1, pdd2, pdd3, pdd4, pdd5) != 3.0dd) - FAILURE - if (*arg4_64 (pdd0, pdd1, pdd2, pdd3, pdd4, pdd5) != 4.0dd) - FAILURE - if (*arg5_64 (pdd0, pdd1, pdd2, pdd3, pdd4, pdd5) != 5.0dd) - FAILURE - - /* _Decimal128 variants. */ - if (*arg0_128 (pdl0, pdl1, pdl2, pdl3, pdl4, pdl5) != 0.0dl) - FAILURE - if (*arg1_128 (pdl0, pdl1, pdl2, pdl3, pdl4, pdl5) != 1.0dl) - FAILURE - if (*arg2_128 (pdl0, pdl1, pdl2, pdl3, pdl4, pdl5) != 2.0dl) - FAILURE - if (*arg3_128 (pdl0, pdl1, pdl2, pdl3, pdl4, pdl5) != 3.0dl) - FAILURE - if (*arg4_128 (pdl0, pdl1, pdl2, pdl3, pdl4, pdl5) != 4.0dl) - FAILURE - if (*arg5_128 (pdl0, pdl1, pdl2, pdl3, pdl4, pdl5) != 5.0dl) - FAILURE - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/func-scalar.c b/gcc/testsuite/gcc.dg/dfp/func-scalar.c deleted file mode 100644 index 370c21b20e2..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/func-scalar.c +++ /dev/null @@ -1,192 +0,0 @@ -/* C99 6.5.2.2 Function calls. - Test scalar passing and return values involving decimal floating - point types. */ - -#include "dfp-dbg.h" - -/* A handful of functions that return their Nth _Decimal32 - argument. */ - -_Decimal32 -arg0_32 (_Decimal32 arg0, _Decimal32 arg1, _Decimal32 arg2, - _Decimal32 arg3, _Decimal32 arg4, _Decimal32 arg5) -{ - return arg0; -} - -_Decimal32 -arg1_32 (_Decimal32 arg0, _Decimal32 arg1, _Decimal32 arg2, - _Decimal32 arg3, _Decimal32 arg4, _Decimal32 arg5) -{ - return arg1; -} - -_Decimal32 -arg2_32 (_Decimal32 arg0, _Decimal32 arg1, _Decimal32 arg2, - _Decimal32 arg3, _Decimal32 arg4, _Decimal32 arg5) -{ - return arg2; -} - -_Decimal32 -arg3_32 (_Decimal32 arg0, _Decimal32 arg1, _Decimal32 arg2, - _Decimal32 arg3, _Decimal32 arg4, _Decimal32 arg5) -{ - return arg3; -} - -_Decimal32 -arg4_32 (_Decimal32 arg0, _Decimal32 arg1, _Decimal32 arg2, - _Decimal32 arg3, _Decimal32 arg4, _Decimal32 arg5) -{ - return arg4; -} - -_Decimal32 -arg5_32 (_Decimal32 arg0, _Decimal32 arg1, _Decimal32 arg2, - _Decimal32 arg3, _Decimal32 arg4, _Decimal32 arg5) -{ - return arg5; -} - - -/* A handful of functions that return their Nth _Decimal64 - argument. */ - -_Decimal64 -arg0_64 (_Decimal64 arg0, _Decimal64 arg1, _Decimal64 arg2, - _Decimal64 arg3, _Decimal64 arg4, _Decimal64 arg5) -{ - return arg0; -} - -_Decimal64 -arg1_64 (_Decimal64 arg0, _Decimal64 arg1, _Decimal64 arg2, - _Decimal64 arg3, _Decimal64 arg4, _Decimal64 arg5) -{ - return arg1; -} - -_Decimal64 -arg2_64 (_Decimal64 arg0, _Decimal64 arg1, _Decimal64 arg2, - _Decimal64 arg3, _Decimal64 arg4, _Decimal64 arg5) -{ - return arg2; -} - -_Decimal64 -arg3_64 (_Decimal64 arg0, _Decimal64 arg1, _Decimal64 arg2, - _Decimal64 arg3, _Decimal64 arg4, _Decimal64 arg5) -{ - return arg3; -} - -_Decimal64 -arg4_64 (_Decimal64 arg0, _Decimal64 arg1, _Decimal64 arg2, - _Decimal64 arg3, _Decimal64 arg4, _Decimal64 arg5) -{ - return arg4; -} - -_Decimal64 -arg5_64 (_Decimal64 arg0, _Decimal64 arg1, _Decimal64 arg2, - _Decimal64 arg3, _Decimal64 arg4, _Decimal64 arg5) -{ - return arg5; -} - - -/* A handful of functions that return their Nth _Decimal128 - argument. */ - -_Decimal128 -arg0_128 (_Decimal128 arg0, _Decimal128 arg1, _Decimal128 arg2, - _Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5) -{ - return arg0; -} - -_Decimal128 -arg1_128 (_Decimal128 arg0, _Decimal128 arg1, _Decimal128 arg2, - _Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5) -{ - return arg1; -} - -_Decimal128 -arg2_128 (_Decimal128 arg0, _Decimal128 arg1, _Decimal128 arg2, - _Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5) -{ - return arg2; -} - -_Decimal128 -arg3_128 (_Decimal128 arg0, _Decimal128 arg1, _Decimal128 arg2, - _Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5) -{ - return arg3; -} - -_Decimal128 -arg4_128 (_Decimal128 arg0, _Decimal128 arg1, _Decimal128 arg2, - _Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5) -{ - return arg4; -} - -_Decimal128 -arg5_128 (_Decimal128 arg0, _Decimal128 arg1, _Decimal128 arg2, - _Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5) -{ - return arg5; -} - - - -int -main () -{ - /* _Decimal32 variants. */ - if (arg0_32 (0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 0.0df) - FAILURE - if (arg1_32 (0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 1.0df) - FAILURE - if (arg2_32 (0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 2.0df) - FAILURE - if (arg3_32 (0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 3.0df) - FAILURE - if (arg4_32 (0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 4.0df) - FAILURE - if (arg5_32 (0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 5.0df) - FAILURE - - /* _Decimal64 variants. */ - if (arg0_64 (0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 0.0dd) - FAILURE - if (arg1_64 (0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 1.0dd) - FAILURE - if (arg2_64 (0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 2.0dd) - FAILURE - if (arg3_64 (0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 3.0dd) - FAILURE - if (arg4_64 (0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 4.0dd) - FAILURE - if (arg5_64 (0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 5.0dd) - FAILURE - - /* _Decimal128 variants. */ - if (arg0_128 (0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 0.0dl) - FAILURE - if (arg1_128 (0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 1.0dl) - FAILURE - if (arg2_128 (0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 2.0dl) - FAILURE - if (arg3_128 (0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 3.0dl) - FAILURE - if (arg4_128 (0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 4.0dl) - FAILURE - if (arg5_128 (0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 5.0dl) - FAILURE - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/func-struct.c b/gcc/testsuite/gcc.dg/dfp/func-struct.c deleted file mode 100644 index ad0224d6cad..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/func-struct.c +++ /dev/null @@ -1,93 +0,0 @@ -/* C99 6.5.2.2 Function calls. - Test structure passing and return values involving decimal floating - point types. */ - -#include "dfp-dbg.h" - -struct example -{ - _Decimal128 d128; - char dummy1; - _Decimal64 d64; - char dummy2; - _Decimal32 d32; -} nums = { 1.0dl, 'a', 2.0dd, 'b', 3.0df }; - -_Decimal32 -d32_field (struct example s) -{ - return s.d32; -} - -_Decimal64 -d64_field (struct example s) -{ - return s.d64; -} - -_Decimal128 -d128_field (struct example s) -{ - return s.d128; -} - -char -dummy1_field (struct example s) -{ - return s.dummy1; -} - -char -dummy2_field (struct example s) -{ - return s.dummy2; -} - -_Decimal32 -ptr_d32_field (struct example *s) -{ - return s->d32; -} - -_Decimal64 -ptr_d64_field (struct example *s) -{ - return s->d64; -} - -_Decimal128 -ptr_d128_field (struct example *s) -{ - return s->d128; -} - -char -ptr_dummy1_field (struct example *s) -{ - return s->dummy1; -} - -char -ptr_dummy2_field (struct example *s) -{ - return s->dummy2; -} - - -int -main () -{ - if (d32_field (nums) != 3.0df) FAILURE - if (d64_field (nums) != 2.0dd) FAILURE - if (d128_field (nums) != 1.0dl) FAILURE - if (dummy1_field (nums) != 'a') FAILURE - if (dummy2_field (nums) != 'b') FAILURE - - if (ptr_d32_field (&nums) != 3.0df) FAILURE - if (ptr_d64_field (&nums) != 2.0dd) FAILURE - if (ptr_d128_field (&nums) != 1.0dl) FAILURE - if (ptr_dummy1_field (&nums) != 'a') FAILURE - if (ptr_dummy2_field (&nums) != 'b') FAILURE - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/func-vararg-alternate-d128-2.c b/gcc/testsuite/gcc.dg/dfp/func-vararg-alternate-d128-2.c deleted file mode 100644 index 2960c357ade..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/func-vararg-alternate-d128-2.c +++ /dev/null @@ -1,22 +0,0 @@ -/* { dg-do run { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ -/* { dg-options "-mpreferred-stack-boundary=2" } */ - -/* Simple test of vararg passing for problematic types with and without - double values passed between them. */ - -#define DTYPE _Decimal128 -#define ONE 1.0dl -#define THREE 3.0dl -#define SEVEN 7.0dl -#define ELEVEN 11.0dl -#define INTS 4 - -#include "func-vararg-alternate.h" - -int -main () -{ - doit (); - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/func-vararg-alternate-d128.c b/gcc/testsuite/gcc.dg/dfp/func-vararg-alternate-d128.c deleted file mode 100644 index 8d452eadc38..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/func-vararg-alternate-d128.c +++ /dev/null @@ -1,19 +0,0 @@ -/* Simple test of vararg passing for problematic types with and without - double values passed between them. */ - -#define DTYPE _Decimal128 -#define ONE 1.0dl -#define THREE 3.0dl -#define SEVEN 7.0dl -#define ELEVEN 11.0dl -#define INTS 4 - -#include "func-vararg-alternate.h" - -int -main () -{ - doit (); - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/func-vararg-alternate-d32.c b/gcc/testsuite/gcc.dg/dfp/func-vararg-alternate-d32.c deleted file mode 100644 index 651b7e8c50f..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/func-vararg-alternate-d32.c +++ /dev/null @@ -1,19 +0,0 @@ -/* Simple test of vararg passing for problematic types with and without - double values passed between them. */ - -#define DTYPE _Decimal32 -#define ONE 1.0df -#define THREE 3.0df -#define SEVEN 7.0df -#define ELEVEN 11.0df -#define INTS 1 - -#include "func-vararg-alternate.h" - -int -main () -{ - doit (); - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/func-vararg-alternate-d64.c b/gcc/testsuite/gcc.dg/dfp/func-vararg-alternate-d64.c deleted file mode 100644 index 86b475d2ada..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/func-vararg-alternate-d64.c +++ /dev/null @@ -1,19 +0,0 @@ -/* Simple test of vararg passing for problematic types with and without - double values passed between them. */ - -#define DTYPE _Decimal64 -#define ONE 1.0dd -#define THREE 3.0dd -#define SEVEN 7.0dd -#define ELEVEN 11.0dd -#define INTS 2 - -#include "func-vararg-alternate.h" - -int -main () -{ - doit (); - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/func-vararg-alternate.h b/gcc/testsuite/gcc.dg/dfp/func-vararg-alternate.h deleted file mode 100644 index 5ba0ab0dc1f..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/func-vararg-alternate.h +++ /dev/null @@ -1,143 +0,0 @@ -/* Simple test of vararg passing for problematic types with and without - double values passed between them. */ - -#include "dfp-dbg.h" -#include - -DTYPE a[10]; -double b[10]; - -union U { - DTYPE d; - unsigned int i[INTS]; -}; - -void -compare (double r, double s, unsigned int *p, unsigned int *q, int n, int line) -{ - int i; - - for (i = 0; i < n; i++) - if (r != s || p[i] != q[i]) -#ifdef DBG - { - int j; - - failures++; - printf ("line %-3d", line); - for (j = 0; j < n; j++) - printf (" %08x", p[j]); - printf (" %10.2g\n ", r); - for (j = 0; j < n; j++) - printf (" %08x", q[j]); - printf (" %10.2g\n\n", s); - - return; - } -#else - __builtin_abort (); -#endif -} - -void -bar0 (int n, ...) -{ - union U u; - int j; - va_list ap; - - va_start (ap, n); - for (j = 0; j < n; j++) - a[j] = va_arg (ap, DTYPE); - va_end (ap); -} - -void -bar1 (int n, ...) -{ - union U u; - int j; - va_list ap; - - va_start (ap, n); - for (j = 0; j < n; j++) - { - a[j] = va_arg (ap, DTYPE); - b[j] = va_arg (ap, double); - } - va_end (ap); -} - -void -bar2 (int n, ...) -{ - union U u; - int j; - va_list ap; - - va_start (ap, n); - for (j = 0; j < n; j++) - { - b[j] = va_arg (ap, double); - a[j] = va_arg (ap, DTYPE); - } - va_end (ap); -} - -void -doit () -{ - DTYPE x, y, z; - union U u1, u2; - - /* Sanity check that test setup is right, especially for long double - which can be changed by command line option. */ - if (INTS * 4 != sizeof (DTYPE)) - { -#ifdef DBG - printf ("test error: INTS = %d, sizeof (DTYPE) = %d\n", - INTS, sizeof (DTYPE)); -#endif - __builtin_abort (); - } - - x = ONE / THREE; - y = ONE / SEVEN; - z = ONE / ELEVEN; - - bar0 (1, x); - u1.d = x; u2.d = a[0]; compare (0.0, 0.0, u1.i, u2.i, INTS, __LINE__); - - bar0 (2, x, y); - u1.d = x; u2.d = a[0]; compare (0.0, 0.0, u1.i, u2.i, INTS, __LINE__); - u1.d = y; u2.d = a[1]; compare (0.0, 0.0, u1.i, u2.i, INTS, __LINE__); - - bar0 (3, x, y, z); - u1.d = x; u2.d = a[0]; compare (0.0, 0.0, u1.i, u2.i, INTS, __LINE__); - u1.d = y; u2.d = a[1]; compare (0.0, 0.0, u1.i, u2.i, INTS, __LINE__); - u1.d = z; u2.d = a[2]; compare (0.0, 0.0, u1.i, u2.i, INTS, __LINE__); - - bar1 (1, x, 1.5); - u1.d = x; u2.d = a[0]; compare (1.5, b[0], u1.i, u2.i, INTS, __LINE__); - - bar1 (2, x, 1.5, y, 2.5); - u1.d = x; u2.d = a[0]; compare (1.5, b[0], u1.i, u2.i, INTS, __LINE__); - u1.d = y; u2.d = a[1]; compare (2.5, b[1], u1.i, u2.i, INTS, __LINE__); - - bar1 (3, x, 1.5, y, 2.5, z, 3.5); - u1.d = x; u2.d = a[0]; compare (1.5, b[0], u1.i, u2.i, INTS, __LINE__); - u1.d = y; u2.d = a[1]; compare (2.5, b[1], u1.i, u2.i, INTS, __LINE__); - u1.d = z; u2.d = a[2]; compare (3.5, b[2], u1.i, u2.i, INTS, __LINE__); - - bar2 (1, 1.5, x); - u1.d = x; u2.d = a[0]; compare (1.5, b[0], u1.i, u2.i, INTS, __LINE__); - - bar2 (2, 1.5, x, 2.5, y); - u1.d = x; u2.d = a[0]; compare (1.5, b[0], u1.i, u2.i, INTS, __LINE__); - u1.d = y; u2.d = a[1]; compare (2.5, b[1], u1.i, u2.i, INTS, __LINE__); - - bar2 (3, 1.5, x, 2.5, y, 3.5, z); - u1.d = x; u2.d = a[0]; compare (1.5, b[0], u1.i, u2.i, INTS, __LINE__); - u1.d = y; u2.d = a[1]; compare (2.5, b[1], u1.i, u2.i, INTS, __LINE__); - u1.d = z; u2.d = a[2]; compare (3.5, b[2], u1.i, u2.i, INTS, __LINE__); -} diff --git a/gcc/testsuite/gcc.dg/dfp/func-vararg-dfp.c b/gcc/testsuite/gcc.dg/dfp/func-vararg-dfp.c deleted file mode 100644 index 5add1f7fd38..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/func-vararg-dfp.c +++ /dev/null @@ -1,95 +0,0 @@ -/* C99 6.5.2.2 Function calls. - Test passing varargs of the decimal float types. */ - -#include -#include "dfp-dbg.h" - -static _Decimal32 -vararg32 (unsigned arg, ...) -{ - int i; - va_list ap; - _Decimal32 result; - - va_start (ap, arg); - for (i = 0; i <= arg; i++) - result = va_arg (ap, _Decimal32); - va_end (ap); - return result; -} - -static _Decimal64 -vararg64 (unsigned arg, ...) -{ - int i; - va_list ap; - _Decimal64 result; - - va_start (ap, arg); - for (i = 0; i <= arg; i++) - result = va_arg (ap, _Decimal64); - va_end (ap); - return result; -} - -static _Decimal128 -vararg128 (unsigned arg, ...) -{ - int i; - va_list ap; - _Decimal128 result; - - va_start (ap, arg); - for (i = 0; i <= arg; i++) - result = va_arg (ap, _Decimal128); - va_end (ap); - return result; -} - - -int main() -{ - /* _Decimal32 variants. */ - if (vararg32 (0, 0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 0.0df) - FAILURE - if (vararg32 (1, 0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 1.0df) - FAILURE - if (vararg32 (2, 0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 2.0df) - FAILURE - if (vararg32 (3, 0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 3.0df) - FAILURE - if (vararg32 (4, 0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 4.0df) - FAILURE - if (vararg32 (5, 0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 5.0df) - FAILURE - - /* _Decimal64 variants. */ - if (vararg64 (0, 0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 0.0dd) - FAILURE - if (vararg64 (1, 0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 1.0dd) - FAILURE - if (vararg64 (2, 0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 2.0dd) - FAILURE - if (vararg64 (3, 0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 3.0dd) - FAILURE - if (vararg64 (4, 0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 4.0dd) - FAILURE - if (vararg64 (5, 0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 5.0dd) - FAILURE - - /* _Decimal128 variants. */ - if (vararg128 (0, 0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 0.0dl) - FAILURE - if (vararg128 (1, 0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 1.0dl) - FAILURE - if (vararg128 (2, 0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 2.0dl) - FAILURE - if (vararg128 (3, 0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 3.0dl) - FAILURE - if (vararg128 (4, 0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 4.0dl) - FAILURE - if (vararg128 (5, 0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 5.0dl) - FAILURE - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/func-vararg-mixed-2.c b/gcc/testsuite/gcc.dg/dfp/func-vararg-mixed-2.c deleted file mode 100644 index 893cdae27ff..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/func-vararg-mixed-2.c +++ /dev/null @@ -1,105 +0,0 @@ -/* { dg-do run { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ -/* { dg-options "-mpreferred-stack-boundary=2" } */ - -/* C99 6.5.2.2 Function calls. - Test passing varargs of the combination of decimal float types and - other types. */ - -#include -#include "dfp-dbg.h" - -/* Supposing the list of varying number of arguments is: - unsigned int, _Decimal128, double, _Decimal32, _Decimal64. */ - -static _Decimal32 -vararg_d32 (unsigned arg, ...) -{ - va_list ap; - _Decimal32 result; - - va_start (ap, arg); - - va_arg (ap, unsigned int); - va_arg (ap, _Decimal128); - va_arg (ap, double); - result = va_arg (ap, _Decimal32); - - va_end (ap); - return result; -} - -static _Decimal32 -vararg_d64 (unsigned arg, ...) -{ - va_list ap; - _Decimal64 result; - - va_start (ap, arg); - - va_arg (ap, unsigned int); - va_arg (ap, _Decimal128); - va_arg (ap, double); - va_arg (ap, _Decimal32); - result = va_arg (ap, _Decimal64); - - va_end (ap); - return result; -} - -static _Decimal128 -vararg_d128 (unsigned arg, ...) -{ - va_list ap; - _Decimal128 result; - - va_start (ap, arg); - - va_arg (ap, unsigned int); - result = va_arg (ap, _Decimal128); - - va_end (ap); - return result; -} - -static unsigned int -vararg_int (unsigned arg, ...) -{ - va_list ap; - unsigned int result; - - va_start (ap, arg); - - result = va_arg (ap, unsigned int); - - va_end (ap); - return result; -} - -static double -vararg_double (unsigned arg, ...) -{ - va_list ap; - float result; - - va_start (ap, arg); - - va_arg (ap, unsigned int); - va_arg (ap, _Decimal128); - result = va_arg (ap, double); - - va_end (ap); - return result; -} - - -int -main () -{ - if (vararg_d32 (3, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 3.0df) FAILURE - if (vararg_d64 (4, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 4.0dd) FAILURE - if (vararg_d128 (1, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 1.0dl) FAILURE - if (vararg_int (0, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 0) FAILURE - if (vararg_double (2, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 2.0) FAILURE - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/func-vararg-mixed.c b/gcc/testsuite/gcc.dg/dfp/func-vararg-mixed.c deleted file mode 100644 index 1669eaf959a..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/func-vararg-mixed.c +++ /dev/null @@ -1,102 +0,0 @@ -/* C99 6.5.2.2 Function calls. - Test passing varargs of the combination of decimal float types and - other types. */ - -#include -#include "dfp-dbg.h" - -/* Supposing the list of varying number of arguments is: - unsigned int, _Decimal128, double, _Decimal32, _Decimal64. */ - -static _Decimal32 -vararg_d32 (unsigned arg, ...) -{ - va_list ap; - _Decimal32 result; - - va_start (ap, arg); - - va_arg (ap, unsigned int); - va_arg (ap, _Decimal128); - va_arg (ap, double); - result = va_arg (ap, _Decimal32); - - va_end (ap); - return result; -} - -static _Decimal32 -vararg_d64 (unsigned arg, ...) -{ - va_list ap; - _Decimal64 result; - - va_start (ap, arg); - - va_arg (ap, unsigned int); - va_arg (ap, _Decimal128); - va_arg (ap, double); - va_arg (ap, _Decimal32); - result = va_arg (ap, _Decimal64); - - va_end (ap); - return result; -} - -static _Decimal128 -vararg_d128 (unsigned arg, ...) -{ - va_list ap; - _Decimal128 result; - - va_start (ap, arg); - - va_arg (ap, unsigned int); - result = va_arg (ap, _Decimal128); - - va_end (ap); - return result; -} - -static unsigned int -vararg_int (unsigned arg, ...) -{ - va_list ap; - unsigned int result; - - va_start (ap, arg); - - result = va_arg (ap, unsigned int); - - va_end (ap); - return result; -} - -static double -vararg_double (unsigned arg, ...) -{ - va_list ap; - float result; - - va_start (ap, arg); - - va_arg (ap, unsigned int); - va_arg (ap, _Decimal128); - result = va_arg (ap, double); - - va_end (ap); - return result; -} - - -int -main () -{ - if (vararg_d32 (3, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 3.0df) FAILURE - if (vararg_d64 (4, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 4.0dd) FAILURE - if (vararg_d128 (1, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 1.0dl) FAILURE - if (vararg_int (0, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 0) FAILURE - if (vararg_double (2, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 2.0) FAILURE - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/func-vararg-size0.c b/gcc/testsuite/gcc.dg/dfp/func-vararg-size0.c deleted file mode 100644 index bc8b20fd484..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/func-vararg-size0.c +++ /dev/null @@ -1,41 +0,0 @@ -/* C99 6.5.2.2 Function calls. */ - -#include -#include "dfp-dbg.h" - -struct S1 -{ - struct - { - _Decimal64 e; - } b[0]; -}; - -/* Test handling vararg parameters whose size is 0. */ - -int check_var(int z,...) -{ - double d; - struct S1 s1; - long long result; - va_list ap; - va_start (ap, z); - d = va_arg (ap, double); - s1 = va_arg (ap, struct S1); - result = va_arg (ap, long long); - va_end (ap); - return (result == 2LL); - -} - -int -main () -{ - struct S1 s1; - struct S1 a1[5]; - - if (check_var(5, 1.0, s1, 2LL, a1[2], a1[2]) == 0) - FAILURE - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/inf-1.c b/gcc/testsuite/gcc.dg/dfp/inf-1.c deleted file mode 100644 index c4f8cd79610..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/inf-1.c +++ /dev/null @@ -1,61 +0,0 @@ -/* N1150 4: Characteristics of decimal floating types (not explicit) - C99 5.2.4.2.2: Characteristics of floating types. - A few simple checks on arithmetic operations. */ - -#include "dfp-dbg.h" - -int main() -{ - /* Assumes rounding mode. */ - if (9999999.E90DF + 1.E90df != __builtin_infd32 ()) - FAILURE - - if (!__builtin_isinfd32 (9999999.E90DF + 1.E90df)) - FAILURE - - if (9.999999999999999E384dd + .000000000000001e384dd - != __builtin_infd32 ()) - FAILURE - - if (-9999999.E90DF - 1.E90df != -__builtin_infd32 ()) - FAILURE - - if (!__builtin_isinfd32 (9.999999999999999E384dd + .000000000000001e384dd)) - FAILURE - - if (7.999999999999999999999999999999999E6144dl + 3.0E6144dl - != __builtin_infd32 ()) - FAILURE - - if (__builtin_infd32 () * __builtin_infd32 () != __builtin_infd32 ()) - FAILURE - - if (__builtin_infd32 () * 2 != __builtin_infd32 ()) - FAILURE - - if (__builtin_infd64 () * -5 != -__builtin_infd32 ()) - FAILURE - - if (!__builtin_isinfd128 (__builtin_infd32 () / 4)) - FAILURE - - if (__builtin_infd64 () != __builtin_infd128 ()) - FAILURE - - if (!__builtin_isinfd64 (__builtin_infd128 ())) - FAILURE - - if (__builtin_finited64 (__builtin_infd32 () * 4)) - FAILURE - - if (!__builtin_finited128 (9.999999E90DL - 1.E90dd)) - FAILURE - - if (__builtin_finited128 (__builtin_infd32 () *__builtin_infd128 ())) - FAILURE - - if (__builtin_finited32 (__builtin_nand32 (""))) - FAILURE - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/loop-index.c b/gcc/testsuite/gcc.dg/dfp/loop-index.c deleted file mode 100644 index a944042a79b..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/loop-index.c +++ /dev/null @@ -1,57 +0,0 @@ -/* C99 6.8.5.2: The for statement. */ - -#include -#include -#include "dfp-dbg.h" - -void -f32 (void) -{ - _Decimal32 d; - int i; - - for (d = 1.1df, i=0; d <= 1.5df; d += 0.1df) - i++; - - if (i != 5) - FAILURE -} - -void -f64 (void) -{ - _Decimal64 d; - int i; - - for (d = 1.1dd, i=0; d <= 1.5dd; d += 0.1dd) - i++; - - if (i != 5) - FAILURE -} - -void -f128 (void) -{ - _Decimal128 d; - int i; - - for (d = 1.1dl, i=0; d <= 1.5dl; d += 0.1dl) - i++; - - if (i != 5) - FAILURE -} - -int -main () -{ - int i; - - f32 (); - f64 (); - f128 (); - - FINISH - return (0); -} diff --git a/gcc/testsuite/gcc.dg/dfp/modes.c b/gcc/testsuite/gcc.dg/dfp/modes.c deleted file mode 100644 index 09d4a15c264..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/modes.c +++ /dev/null @@ -1,14 +0,0 @@ -/* { dg-do compile } */ - -typedef float decimal32 __attribute__ ((mode (SD))); -typedef float decimal64 __attribute__ ((mode (DD))); -typedef float decimal128 __attribute__ ((mode (TD))); - -int ssize[sizeof (decimal32) == 4 ? 1 : -1]; -int dsize[sizeof (decimal64) == 8 ? 1 : -1]; -int tsize[sizeof (decimal128) == 16 ? 1 : -1]; - -int salign = __alignof (decimal32); -int dalign = __alignof (decimal64); -int talign = __alignof (decimal128); - diff --git a/gcc/testsuite/gcc.dg/dfp/nan-1.c b/gcc/testsuite/gcc.dg/dfp/nan-1.c deleted file mode 100644 index 8961777c79b..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/nan-1.c +++ /dev/null @@ -1,106 +0,0 @@ -/* N1150 4: Characteristics of decimal floating types (not explicit) - C99 5.2.4.2.2: Characteristics of floating types. - A few simple checks on arithmetic operations. */ - -#include "dfp-dbg.h" - -int main() -{ - /* Some possibly non-obvious tests, but most logical - operations on NaN return false, including NaN == NaN. */ - if (__builtin_nand32("") == __builtin_nand32("")) - FAILURE - - if (__builtin_nand64("") == __builtin_nand64("")) - FAILURE - - if (__builtin_nand128("") == __builtin_nand128("")) - FAILURE - - if (!(__builtin_nand32("") != __builtin_nand32(""))) - FAILURE - - if (!(__builtin_nand64("") != __builtin_nand64(""))) - FAILURE - - if (!(__builtin_nand128("") != __builtin_nand128(""))) - FAILURE - - if (__builtin_nand32("") > __builtin_nand32("")) - FAILURE - - if (__builtin_nand64("") >= __builtin_nand64("")) - FAILURE - - if (__builtin_nand128("") < __builtin_nand128("")) - FAILURE - - if (-__builtin_nand128("") < +__builtin_nand128("")) - FAILURE - - /* 0.0/0.0 => NaN, but NaN != NaN. */ - if (0.0df/0.0dl == __builtin_nand32("")) - FAILURE - - /* 0.0 * INF => NaN. */ - if (!__builtin_isnand32 (0.0df * __builtin_infd32())) - FAILURE - - if (!__builtin_isnand64 (0.0dd * __builtin_infd64())) - FAILURE - - if (!__builtin_isnand128 (0.0dd * __builtin_infd128())) - FAILURE - - /* INF - INF => NaN. */ - if (!__builtin_isnand32 (__builtin_infd32() - __builtin_infd32())) - FAILURE - - if (!__builtin_isnand64 (__builtin_infd64() - __builtin_infd64())) - FAILURE - - if (!__builtin_isnand128 (__builtin_infd128() - __builtin_infd128())) - FAILURE - - /* INF/INF => NaN. */ - if (!__builtin_isnand32 (__builtin_infd32()/__builtin_infd32()) ) - FAILURE - - if (!__builtin_isnand64 (__builtin_infd64()/__builtin_infd64()) ) - FAILURE - - if (!__builtin_isnand128 (__builtin_infd128()/__builtin_infd128()) ) - FAILURE - - /* 0.0/0.0 => NaN, but NaN != NaN. */ - if ((0.0dd/0.0df) == (0.0dd/0.0df)) - FAILURE - - if (__builtin_nand32("") < __builtin_infd32()) - FAILURE - - if (__builtin_nand32("") >= __builtin_infd32()) - FAILURE - - /* Fixme: Add sqrtdf(-x.df) test when sqrt is supported. */ - - if (!__builtin_isnand32(__builtin_nand32(""))) - FAILURE - - if (!__builtin_isnand64(__builtin_nand64(""))) - FAILURE - - if (!__builtin_isnand128(__builtin_nand128(""))) - FAILURE - - if (!__builtin_isnand128(8.0df * __builtin_nand128(""))) - FAILURE - - if (!__builtin_isnand32(8.1dl - __builtin_nand32(""))) - FAILURE - - if (!__builtin_isnand128(__builtin_nand64("") + __builtin_nand128(""))) - FAILURE - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/nan-2.c b/gcc/testsuite/gcc.dg/dfp/nan-2.c deleted file mode 100644 index ec9d18e1000..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/nan-2.c +++ /dev/null @@ -1,53 +0,0 @@ -/* N1150 4: Characteristics of decimal floating types (not explicit) - C99 5.2.4.2.2: Characteristics of floating types. - A few simple checks on arithmetic operations. Based on nan-1.c with - the consideration of negative zero. */ - -#include "dfp-dbg.h" - -int main() -{ - _Decimal32 d32; - _Decimal64 d64; - _Decimal128 d128; - - /* Verify that division by negative zero produces a negative infinity - result. */ - d32 = 123.45f; - if (d32/-0.0df != -__builtin_infd32()) - FAILURE - if (123.45df/-0.0df != -__builtin_infd32()) - FAILURE - - d64 = 123.45f; - if (d64/-0.0dd != -__builtin_infd64()) - FAILURE - if (123.45dd/-0.0dd != -__builtin_infd64()) - FAILURE - - d128 = 123.45f; - if (d128/-0.0dl != -__builtin_infd64()) - FAILURE - if (123.45dl/-0.0dl != -__builtin_infd128()) - FAILURE - - d32 = 0.0df; - if (!__builtin_isnand32(-(d32/-0.0df))) - FAILURE - if (!__builtin_isnand32(-(0.0df/-0.0df))) - FAILURE - - d64 = 0.0dd; - if (!__builtin_isnand64(-(d64/-0.0dd))) - FAILURE - if (!__builtin_isnand64(-(0.0dd/-0.0dd))) - FAILURE - - d128 = 0.0dl; - if (!__builtin_isnand128(-(d128/-0.0dl))) - FAILURE - if (!__builtin_isnand128(-(0.0dl/-0.0dl))) - FAILURE - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/operator-arith-fold.c b/gcc/testsuite/gcc.dg/dfp/operator-arith-fold.c deleted file mode 100644 index c4aa4cbb27e..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/operator-arith-fold.c +++ /dev/null @@ -1,45 +0,0 @@ -/* { dg-options "-O2" } */ - -/* C99 6.5.5: Multiplicative operators. - C99 6.5.6: Additive operators. */ - -#include "dfp-dbg.h" - -extern void link_error (void); - -int -main () -{ - _Decimal32 d32_1, d32_2; - - /* Compare like-typed positive constants. */ - if (2.99df + 5.1df != 8.09df) - link_error (); - - if (5.77df - 2.22dd != 3.55df) - link_error (); - - if (2.0dl * 3.7dd * -2 != -14.8df) - link_error (); - - if (.18df / -.2df + 1 != 1.e-1dd) - link_error (); - - d32_1 = 3.0df; - d32_2 = 1.0df; - - if (!__builtin_constant_p (d32_1 + 0.2df)) - link_error (); - - if (!__builtin_constant_p (1.0df / 3.0df)) - link_error (); - - if (!__builtin_constant_p (d32_2 / d32_1)) - link_error (); - - d32_2 = 2.0df; - if (!__builtin_constant_p (d32_2 / d32_1)) - link_error (); - - return 0; -} diff --git a/gcc/testsuite/gcc.dg/dfp/operator-assignment.c b/gcc/testsuite/gcc.dg/dfp/operator-assignment.c deleted file mode 100644 index faadf1e8650..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/operator-assignment.c +++ /dev/null @@ -1,56 +0,0 @@ -/* 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 -} diff --git a/gcc/testsuite/gcc.dg/dfp/operator-comma.c b/gcc/testsuite/gcc.dg/dfp/operator-comma.c deleted file mode 100644 index be6bf6f8cd1..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/operator-comma.c +++ /dev/null @@ -1,47 +0,0 @@ -/* { dg-options "-O0" } */ - -/* C99 6.5.17: Comma operator. - Test with decimal float operands. */ - -#include "dfp-dbg.h" - -volatile _Decimal32 d32a, d32b, d32c; -volatile _Decimal64 d64a, d64b, d64c; -volatile _Decimal128 d128a, d128b, d128c; - -void -init () -{ - d32b = 123.456e94df; - d64b = 12.3456789012345e383dd; - d128b = 12345.6789012345678901e4000dl; - - d32c = 1.3df; - d64c = 1.2dd; - d128c = 1.1dl; -} - -int -main () -{ - d32a = (d32b, d32c); - if (d32a != d32c) - FAILURE - d64a = (d64b, 7.89dd, d64c); - if (d64a != d64c) - FAILURE - d128a = (45678.987654dl, d128c, d128b); - if (d128a != d128b) - FAILURE - d128a = (d32b, d64b, d128b); - if (d128a != d128b) - FAILURE - d32a = (d32b, 12, d64c); - if (d32a != d64c) - FAILURE; - d64a = (d64b, d32b, 12); - if (d64a != 12.0dd) - FAILURE; - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/operator-cond.c b/gcc/testsuite/gcc.dg/dfp/operator-cond.c deleted file mode 100644 index 140dd95074a..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/operator-cond.c +++ /dev/null @@ -1,57 +0,0 @@ -/* { dg-options "-O0" } */ - -/* C99 6.5.15 Conditional operator. - Test with decimal float operands. */ - -#include "dfp-dbg.h" - -volatile _Decimal32 d32a, d32b, d32c; -volatile _Decimal64 d64a, d64b, d64c; -volatile _Decimal128 d128a, d128b, d128c; -volatile int i, yes, no; - -void -init () -{ - d32b = 123.456e94df; - d64b = 12.3456789012345e383dd; - d128b = 12345.6789012345678901e4000dl; - - d32c = 1.3df; - d64c = 1.2dd; - d128c = 1.1dl; - - i = 2; - yes = 1; - no = 0; -} - -int -main () -{ - init (); - - /* Operands and the result are all the same decimal float type. */ - d32a = yes ? d32b : d32c; - if (d32a != d32b) - FAILURE - d64a = no ? d64b : d64c; - if (d64a != d64c) - FAILURE - d128a = yes ? d128b : d128c; - if (d128a != d128b) - FAILURE - - /* Operand types are different. */ - d128a = yes ? d32b : d64b; - if (d128a != d32b) - FAILURE - d128a = yes ? d128b : d64b; - if (d128a != d128b) - FAILURE - d128a = no ? d32b : d128b; - if (d128a != d128b) - FAILURE - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/operator-logical.c b/gcc/testsuite/gcc.dg/dfp/operator-logical.c deleted file mode 100644 index c784468c77a..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/operator-logical.c +++ /dev/null @@ -1,63 +0,0 @@ -/* C99 Logical AND operator. - C99 Logical OR operator. - Test with decimal float operands. */ - -#include "dfp-dbg.h" - -#define OPERATE(OPRD1,OPRT,OPRD2,RLT) \ -do \ -{ \ - if (( (OPRD1) OPRT (OPRD2) )!= RLT) \ - __builtin_abort (); \ -} while (0) - -#define DECIMAL_LOGICAL_OR(OPRD) \ -do \ -{ \ - OPRD = 1.0; \ - OPERATE(1,||,OPRD,1); \ - OPERATE(0,||,OPRD,1); \ - OPERATE(OPRD,||,1,1); \ - OPERATE(OPRD,||,0,1); \ - OPRD = 0.0; \ - OPERATE(1,||,OPRD,1); \ - OPERATE(0,||,OPRD,0); \ - OPERATE(OPRD,||,1,1); \ - OPERATE(OPRD,||,0,0); \ -} while (0) - -#define DECIMAL_LOGICAL_AND(OPRD) \ -do \ -{ \ - OPRD = 1.0; \ - OPERATE(1,&&,OPRD,1); \ - OPERATE(0,&&,OPRD,0); \ - OPERATE(OPRD,&&,1,1); \ - OPERATE(OPRD,&&,0,0); \ - OPRD = 0.0; \ - OPERATE(1,&&,OPRD,0); \ - OPERATE(0,&&,OPRD,0); \ - OPERATE(OPRD,&&,1,0); \ - OPERATE(OPRD,&&,0,0); \ -} while (0) - -int -main () -{ - _Decimal32 d32; - _Decimal64 d64; - _Decimal128 d128; - - /* C99 Section 6.5.{13,14} Logical operator. Constraints Each of the - operands shall have scalar type. DFP types would obey this. */ - DECIMAL_LOGICAL_OR (d32); - DECIMAL_LOGICAL_AND (d32); - - DECIMAL_LOGICAL_OR (d64); - DECIMAL_LOGICAL_AND (d64); - - DECIMAL_LOGICAL_OR (d128); - DECIMAL_LOGICAL_AND (d128); - - return 0; -} diff --git a/gcc/testsuite/gcc.dg/dfp/operator-unary.c b/gcc/testsuite/gcc.dg/dfp/operator-unary.c deleted file mode 100644 index 65f0be074d9..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/operator-unary.c +++ /dev/null @@ -1,52 +0,0 @@ -/* C99 6.5.3 Unary operators. */ - -#include "dfp-dbg.h" - -#define AUTO_INCREASE_DECREASE(TYPE,SUFFIX) \ -do \ -{ \ - _Decimal##TYPE in_de_d##TYPE = 0.0##SUFFIX; \ - if (in_de_d##TYPE++) FAILURE \ - if (--in_de_d##TYPE) FAILURE \ - if (++in_de_d##TYPE == 0.0##SUFFIX) FAILURE \ - if (in_de_d##TYPE-- == 0.0##SUFFIX) FAILURE \ -} while(0) - -#define UNARY_OPERATOR(TYPE,SUFFIX) \ -do \ -{ \ - _Decimal##TYPE unary_d##TYPE = 1.0##SUFFIX; \ - _Decimal##TYPE* unary_dp##TYPE; \ - /* & operator. */ \ - unary_dp##TYPE = &(unary_d##TYPE); \ - /* * operator. */ \ - unary_d##TYPE = *(unary_dp##TYPE); \ - /* - operator. */ \ - unary_d##TYPE = -unary_d##TYPE; \ - if (unary_d##TYPE != -1.0##SUFFIX) FAILURE \ - /* + operator. */ \ - unary_d##TYPE = +unary_d##TYPE; \ - if (unary_d##TYPE != -1.0##SUFFIX) FAILURE \ - if (!unary_d##TYPE) FAILURE /*! operator. */ \ -} while (0) - -int -main () -{ - /* C99 6.5.3.1 Prefix increment and decrement operators. */ - AUTO_INCREASE_DECREASE(32, DF); - AUTO_INCREASE_DECREASE(64, DD); - AUTO_INCREASE_DECREASE(128, DL); - - /* C99 6.5.3 Unary operators. */ - UNARY_OPERATOR(32, DF); - UNARY_OPERATOR(64, DD); - UNARY_OPERATOR(128, DL); - - /* C99 6.5.3 Unary operators for zero values. */ - if (- +0.df != -0.df) FAILURE - if (+ -0.df != -0.df) FAILURE - if (- -0.df != +0.df) FAILURE - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/pr31385.c b/gcc/testsuite/gcc.dg/dfp/pr31385.c deleted file mode 100644 index fc024a3e6b8..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/pr31385.c +++ /dev/null @@ -1,30 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-O2" } */ - -typedef float fp_t __attribute__((mode(SD))); - -extern fp_t g(fp_t); - -fp_t -bug(fp_t x) -{ - fp_t result; - int n; - fp_t f, f3, y, z; - - n = 0; - y = 1.DF; - f = g(x); - - if (f < 0.DF) - f = -f; - - f3 = 2.DF; - - z = (y + y + f / (y * y)); - y = (z + z) / (9.DF) + f3 / (z * z); - - result = y; - - return (result); -} diff --git a/gcc/testsuite/gcc.dg/dfp/pr33466.c b/gcc/testsuite/gcc.dg/dfp/pr33466.c deleted file mode 100644 index e1cd76b74ff..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/pr33466.c +++ /dev/null @@ -1,13 +0,0 @@ -/* { dg-do compile } */ - -/* The suffix for a decimal float constant must use a single case. - - These are invalid for all targets, not just those that support - decimal float. */ - -long double dF = 4.5dF; /* { dg-error "invalid suffix" } */ -long double Df = 4.5Df; /* { dg-error "invalid suffix" } */ -long double dD = 4.5dD; /* { dg-error "invalid suffix" } */ -long double Dd = 4.5Dd; /* { dg-error "invalid suffix" } */ -long double dL = 4.5dL; /* { dg-error "invalid suffix" } */ -long double Dl = 4.5Dl; /* { dg-error "invalid suffix" } */ diff --git a/gcc/testsuite/gcc.dg/dfp/pr35620.c b/gcc/testsuite/gcc.dg/dfp/pr35620.c deleted file mode 100644 index 37a9c4044ed..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/pr35620.c +++ /dev/null @@ -1,27 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-O2" } */ - -#ifdef __cplusplus -typedef float _Decimal32 __attribute__((mode(SD))); -#endif - -extern void foo (_Decimal32); -_Decimal32 *p; - -extern int i; -union { _Decimal32 a; int b; } u; - -void -blatz (void) -{ - _Decimal32 d; - u.b = i; - d = u.a; - foo (d); -} - -void -bar (void) -{ - foo (*p); -} diff --git a/gcc/testsuite/gcc.dg/dfp/pr36800.c b/gcc/testsuite/gcc.dg/dfp/pr36800.c deleted file mode 100644 index 76ff28c9815..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/pr36800.c +++ /dev/null @@ -1,32 +0,0 @@ -/* { dg-do run } */ - -#include -#include "dfp-dbg.h" - -void -f (int a, ...) -{ - va_list ap; - if (a != 0) - FAILURE - va_start (ap, a); - if (va_arg (ap, _Decimal128) != 1.2DL) - FAILURE - if (va_arg (ap, _Decimal128) != 2.34DL) - FAILURE - if (va_arg (ap, _Decimal128) != 3.456DL) - FAILURE - if (va_arg (ap, _Decimal128) != 4.567DL) - FAILURE - if (va_arg (ap, double) != 5.125) - FAILURE - va_end (ap); -} - -int -main (void) -{ - f (0, 1.2DL, 2.34DL, 3.456DL, 4.567DL, 5.125); - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/pr39034.c b/gcc/testsuite/gcc.dg/dfp/pr39034.c deleted file mode 100644 index 2a7eedbdbe2..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/pr39034.c +++ /dev/null @@ -1,100 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-O" } */ - -/* DFP TR 24732 == WG14 / N1176, N1312 */ -/* Based on a test from Fred Tydeman. */ - -#include "dfp-dbg.h" - -/* Test runtime computations. */ - -void -runtime32 (void) -{ - volatile float v1 = 28.f, v2 = 3.f, v3 = 9.f, v4 = 31.f, v5 = 3.f, v6 = 10.f; - float b32 = (float)((v1/v2-v3) - (v4/v5-v6)); - _Decimal32 d32 = (float)((v1/v2-v3) - (v4/v5-v6)); - - if (b32) - FAILURE - if (d32) - FAILURE -} - -void -runtime64 (void) -{ - volatile double v1 = 28., v2 = 3., v3 = 9., v4 = 31., v5 = 3., v6 = 10.; - double b64 = (double)((v1/v2-v3) - (v4/v5-v6)); - _Decimal64 d64 = (double)((v1/v2-v3) - (v4/v5-v6)); - - if (b64) - FAILURE - if (d64) - FAILURE -} - -void -runtime128 (void) -{ - volatile long double v1 = 28.l, v2 = 3.l, v3 = 9.l, - v4 = 31.l, v5 = 3.l, v6 = 10.l; - long double b128 = (long double)((v1/v2-v3) - (v4/v5-v6)); - _Decimal128 d128 = (long double)((v1/v2-v3) - (v4/v5-v6)); - - if (b128) - FAILURE - if (d128) - FAILURE -} - -/* Test constant folding. */ - -void -fold32 (void) -{ - double d32 = (float)((28.f/3.f-9.f) - (31.f/3.f-10.f)); - _Decimal32 b32 = (float)((28.f/3.f-9.f) - (31.f/3.f-10.f)); - - if (b32) - FAILURE - if (d32) - FAILURE -} - -void -fold64 (void) -{ - double b64 = (double)((28./3.-9.) - (31./3.-10.)); - _Decimal64 d64 = (double)((28./3.-9.) - (31./3.-10.)); - - if (b64) - FAILURE - if (d64) - FAILURE -} - -void -fold128 (void) -{ - long double b128 = (long double)((28./3.-9.) - (31./3.-10.)); - _Decimal128 d128 = (long double)((28./3.-9.) - (31./3.-10.)); - - if (b128) - FAILURE - if (d128) - FAILURE -} - -int -main () -{ - runtime32 (); - runtime64 (); - runtime128 (); - fold32 (); - fold64 (); - fold128 (); - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/pr39035.c b/gcc/testsuite/gcc.dg/dfp/pr39035.c deleted file mode 100644 index 2c9e8b386ed..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/pr39035.c +++ /dev/null @@ -1,71 +0,0 @@ -/* { dg-do run } */ -/* { dg-options "-O" } */ - -/* DFP TR 24732 == WG14 / N1176, N1312 */ -/* Based on a test from Fred Tydeman. */ - -#include "dfp-dbg.h" - -/* Test runtime computations. */ - -void -runtime32 (void) -{ - volatile _Decimal32 d; - d = 0.0DF; - if (d) - FAILURE -} - -void -runtime64 (void) -{ - volatile _Decimal64 d; - d = 0.0DD; - if (d) - FAILURE -} - -void -runtime128 (void) -{ - volatile _Decimal128 d; - d = 0.0DL; - if (d) - FAILURE -} - -void -fold32 (void) -{ - if (0.0DF) - FAILURE -} - -void -fold64 (void) -{ - if (0.0DD) - FAILURE -} - -void -fold128 (void) -{ - if (0.0DL) - FAILURE -} - -int -main(void) -{ - runtime32 (); - runtime64 (); - runtime128 (); - - fold32 (); - fold64 (); - fold128 (); - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/pr39902.c b/gcc/testsuite/gcc.dg/dfp/pr39902.c deleted file mode 100644 index 847069966e3..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/pr39902.c +++ /dev/null @@ -1,226 +0,0 @@ -/* Check that optimizations like (x * 1) to x, or (x * -1) to -x, - do not apply to decimal float computations where trailing zeroes - are significant. */ - -#include "dfp-dbg.h" - -#define COMPARE32(A,B) \ - A.i == B.i - -#define COMPARE64(A,B) \ - A.i[0] == B.i[0] && A.i[1] == B.i[1] - -#define COMPARE128(A,B) \ - A.i[0] == B.i[0] && A.i[1] == B.i[1] && A.i[2] == B.i[2] && A.i[3] == B.i[3] - -typedef union { - _Decimal32 d; - unsigned int i; -} u32; - -typedef union { - _Decimal64 d; - unsigned int i[2]; -} u64; - -typedef union { - _Decimal128 d; - unsigned int i[4]; -} u128; - -volatile u32 p32_1; -volatile u32 p32_1_0; -volatile u32 p32_2_0; -volatile u32 m32_1; -volatile u32 m32_1_0; -volatile u32 m32_2_0; -volatile u32 a32; - -volatile u64 p64_1; -volatile u64 p64_1_0; -volatile u64 p64_2_0; -volatile u64 m64_1; -volatile u64 m64_1_0; -volatile u64 m64_2_0; -volatile u64 a64; - -volatile u128 p128_1; -volatile u128 p128_1_0; -volatile u128 p128_2_0; -volatile u128 m128_1; -volatile u128 m128_1_0; -volatile u128 m128_2_0; -volatile u128 a128; - -void -init32 (void) -{ - p32_1.d = 1.DF; - p32_1_0.d = 1.0DF; - p32_2_0.d = 2.0DF; - m32_1.d = -1.DF; - m32_1_0.d = -1.0DF; - m32_2_0.d = -2.0DF; -} - -void -init64 (void) -{ - p64_1.d = 1.DD; - p64_1_0.d = 1.0DD; - p64_2_0.d = 2.0DD; - m64_1.d = -1.DD; - m64_1_0.d = -1.0DD; - m64_2_0.d = -2.0DD; -} - -void -init128 (void) -{ - p128_1.d = 1.DL; - p128_1_0.d = 1.0DL; - p128_2_0.d = 2.0DL; - m128_1.d = -1.DL; - m128_1_0.d = -1.0DL; - m128_2_0.d = -2.0DL; -} - -void -doit32 (void) -{ - /* Multiplying by a value with no trailing zero should not change the - quantum exponent. */ - - a32.d = p32_2_0.d * p32_1.d; - if (! (COMPARE32 (a32, p32_2_0))) - FAILURE - - a32.d = p32_2_0.d * 1.DF; - if (! (COMPARE32 (a32, p32_2_0))) - FAILURE - - a32.d = p32_2_0.d * m32_1.d; - if (! (COMPARE32 (a32, m32_2_0))) - FAILURE - - a32.d = p32_2_0.d * -1.DF; - if (! (COMPARE32 (a32, m32_2_0))) - FAILURE - - /* Multiplying by a value with a trailing zero should change the - quantum exponent. */ - - a32.d = p32_2_0.d * p32_1_0.d; - if (COMPARE32 (a32, p32_2_0)) - FAILURE - - a32.d = p32_2_0.d * 1.0DF; - if (COMPARE32 (a32, p32_2_0)) - FAILURE - - a32.d = p32_2_0.d * m32_1_0.d; - if (COMPARE32 (a32, m32_2_0)) - FAILURE - - a32.d = p32_2_0.d * -1.0DF; - if (COMPARE32 (a32, m32_2_0)) - FAILURE -} - -void -doit64 (void) -{ - /* Multiplying by a value with no trailing zero should not change the - quantum exponent. */ - - a64.d = p64_2_0.d * p64_1.d; - if (! (COMPARE64 (a64, p64_2_0))) - FAILURE - - a64.d = p64_2_0.d * 1.DD; - if (! (COMPARE64 (a64, p64_2_0))) - FAILURE - - a64.d = p64_2_0.d * m64_1.d; - if (! (COMPARE64 (a64, m64_2_0))) - FAILURE - - a64.d = p64_2_0.d * -1.DD; - if (! (COMPARE64 (a64, m64_2_0))) - FAILURE - - /* Multiplying by a value with a trailing zero should change the - quantum exponent. */ - - a64.d = p64_2_0.d * p64_1_0.d; - if (COMPARE64 (a64, p64_2_0)) - FAILURE - - a64.d = p64_2_0.d * 1.0DD; - if (COMPARE64 (a64, p64_2_0)) - FAILURE - - a64.d = p64_2_0.d * m64_1_0.d; - if (COMPARE64 (a64, m64_2_0)) - FAILURE - - a64.d = p64_2_0.d * -1.0DD; - if (COMPARE64 (a64, m64_2_0)) - FAILURE -} - -void -doit128 (void) -{ - /* Multiplying by a value with no trailing zero should not change the - quantum exponent. */ - - a128.d = p128_2_0.d * p128_1_0.d; - if (COMPARE128 (a128, p128_2_0)) - FAILURE - - a128.d = p128_2_0.d * 1.0DL; - if (COMPARE128 (a128, p128_2_0)) - FAILURE - - a128.d = p128_2_0.d * m128_1_0.d; - if (COMPARE128 (a128, m128_2_0)) - FAILURE - - a128.d = p128_2_0.d * -1.0DL; - if (COMPARE128 (a128, m128_2_0)) - FAILURE - - /* Multiplying by a value with a trailing zero should change the - quantum exponent. */ - - a128.d = p128_2_0.d * p128_1.d; - if (! (COMPARE128 (a128, p128_2_0))) - FAILURE - - a128.d = p128_2_0.d * 1.DL; - if (! (COMPARE128 (a128, p128_2_0))) - FAILURE - - a128.d = p128_2_0.d * m128_1.d; - if (! (COMPARE128 (a128, m128_2_0))) - FAILURE - - a128.d = p128_2_0.d * -1.DL; - if (! (COMPARE128 (a128, m128_2_0))) - FAILURE -} - -int -main (void) -{ - init32 (); - init64 (); - init128 (); - - doit32 (); - doit64 (); - doit128 (); - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/pr39986.c b/gcc/testsuite/gcc.dg/dfp/pr39986.c deleted file mode 100644 index e7c9ce98283..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/pr39986.c +++ /dev/null @@ -1,32 +0,0 @@ -/* { dg-do compile } */ - -#include "dfp-dbg.h" - -/* Check that the compiler generates the correct decimal float constants. */ - -_Decimal32 a = 100.223df; -_Decimal32 b = -2.3df; -_Decimal64 c = 3.4e-4dd; -_Decimal64 d = -4.500dd; -_Decimal128 e = 5678901234567.89e+200dl; -_Decimal128 f = -678901.234e-6dl; - -/* The first value is DPD, the second is BID. The order differs depending - on whether the target is big-endian or little-endian. */ - -/* { dg-final { scan-assembler ".long\t(572653859|822183807)\n" } } */ - -/* { dg-final { scan-assembler ".long\t(-1572863965|-1308622825)\n" } } */ - -/* { dg-final { scan-assembler ".long\t(52|34)\n" } } */ -/* { dg-final { scan-assembler ".long\t(572784640|824180736)\n" } } */ - -/* { dg-final { scan-assembler ".long\t(4736|4500)\n" } } */ -/* { dg-final { scan-assembler ".long\t(-1574174720|-1319108608)\n" } } */ - -/* { dg-final { scan-assembler ".long\t(-1975952433|957645077)\n" } } */ -/* { dg-final { scan-assembler ".long\t(190215|132222)\n" } } */ -/* { dg-final { scan-assembler ".long\t(574193664|835452928)\n" } } */ - -/* { dg-final { scan-assembler ".long\t(931280180|678901234)\n" } } */ -/* { dg-final { scan-assembler ".long\t(-1576681472|-1339162624)\n" } } */ diff --git a/gcc/testsuite/gcc.dg/dfp/signbit-1.c b/gcc/testsuite/gcc.dg/dfp/signbit-1.c deleted file mode 100644 index d83d2a48ed7..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/signbit-1.c +++ /dev/null @@ -1,40 +0,0 @@ -/* { dg-options "-O0" } */ - -/* Decimal float versions of __builtin_signbit. */ - -#include "dfp-dbg.h" - -#define CHECK32(D,I) \ - if ((__builtin_signbitd32 (D) != 0) != I) FAILURE - -#define CHECK64(D,I) \ - if ((__builtin_signbitd64 (D) != 0) != I) FAILURE - -#define CHECK128(D,I) \ - if ((__builtin_signbitd128 (D) != 0) != I) FAILURE - -/* Prevent the compiler from folding the calls at compile time. */ -volatile _Decimal32 sd; -volatile _Decimal64 dd; -volatile _Decimal128 td; - -int -main () -{ - sd = 1.9df; CHECK32 (sd, 0) - sd = -5.3df; CHECK32 (sd, 1) - sd = 0.0df; CHECK32 (sd, 0) - sd = -0.0df; CHECK32 (sd, 1) - - dd = 1.9dd; CHECK64 (dd, 0) - dd = -5.3dd; CHECK64 (dd, 1) - dd = 0.0dd; CHECK64 (dd, 0) - dd = -0.0dd; CHECK64 (dd, 1) - - td = 1.9dl; CHECK128 (td, 0) - td = -5.3dl; CHECK128 (td, 1) - td = 0.0dl; CHECK128 (td, 0) - td = -0.0dl; CHECK128 (td, 1) - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/signbit-2.c b/gcc/testsuite/gcc.dg/dfp/signbit-2.c deleted file mode 100644 index e51bf918bf4..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/signbit-2.c +++ /dev/null @@ -1,33 +0,0 @@ -/* { dg-options "-O0" } */ - -/* Check that the compiler uses builtins for signbit; if not the link - will fail because library functions are in libm. */ - -#include "dfp-dbg.h" - -volatile _Decimal32 sd = 2.3df; -volatile _Decimal64 dd = -4.5dd; -volatile _Decimal128 tf = 5.3dl; -volatile float f = 1.2f; -volatile double d = -7.8; -volatile long double ld = 3.4L; - -EXTERN int signbitf (float); -EXTERN int signbit (double); -EXTERN int signbitl (long double); -EXTERN int signbitd32 (_Decimal32); -EXTERN int signbitd64 (_Decimal64); -EXTERN int signbitd128 (_Decimal128); - -int -main () -{ - if (signbitf (f) != 0) FAILURE - if (signbit (d) == 0) FAILURE - if (signbitl (ld) != 0) FAILURE - if (signbitd32 (sd) != 0) FAILURE - if (signbitd64 (dd) == 0) FAILURE - if (signbitd128 (tf) != 0) FAILURE - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/struct-layout-1.c b/gcc/testsuite/gcc.dg/dfp/struct-layout-1.c deleted file mode 100644 index 2a9d7304fd1..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/struct-layout-1.c +++ /dev/null @@ -1,71 +0,0 @@ -#include -#include "dfp-dbg.h" - -struct S1 -{ - _Decimal64 a[0]; -}; - -struct S2 -{ - struct - { - _Decimal64 e; - } b[0]; -}; - -struct S3 -{ - union - { - _Decimal64 c; - } a[0]; -}; - -struct S4 -{ - int a[0]; - _Decimal64 b[0]; -}; - -struct S5 -{ - union - { - _Decimal64 c[0]; - } a; -}; - -int check_var (int z, ...) -{ - long long result; - va_list ap; - va_start (ap, z); - va_arg (ap, struct S1); - result = va_arg (ap, long long); - va_end (ap); - - return (result == 2LL); -} - -int main () -{ - struct S1 s1; - struct S2 s2; - struct S3 s3; - struct S4 s4; - struct S5 s5; - - if (check_var (2, s1, 2LL) == 0) - FAILURE; - if (check_var (2, s2, 2LL) == 0) - FAILURE; - if (check_var (2, s3, 2LL) == 0) - FAILURE; - if (check_var (2, s4, 2LL) == 0) - FAILURE; - if (check_var (2, s5, 2LL) == 0) - FAILURE; - - FINISH -} diff --git a/gcc/testsuite/gcc.dg/dfp/usual-arith-conv-const.c b/gcc/testsuite/gcc.dg/dfp/usual-arith-conv-const.c deleted file mode 100644 index 2d72bba4235..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/usual-arith-conv-const.c +++ /dev/null @@ -1,32 +0,0 @@ -/* { dg-do compile } */ - -/* Test various conversions involving decimal floating types. */ - -#include "dfp-dbg.h" - -/* Assertion that constant C is of type T. */ -#define ASSERT_CONST_TYPE(C, T) \ - do { \ - typedef T type; \ - typedef type **typepp; \ - typedef __typeof__((C)) ctype; \ - typedef ctype **ctypepp; \ - typepp x = 0; \ - ctypepp y = 0; \ - x = y; \ - y = x; \ - } while (0) - -int -main () -{ - ASSERT_CONST_TYPE (3 + 2.1df, _Decimal32); /* { dg-bogus "assignment from incompatible pointer type" } */ - ASSERT_CONST_TYPE (1.3df + 2, _Decimal32); /* { dg-bogus "assignment from incompatible pointer type" } */ - ASSERT_CONST_TYPE (56U - 55.0dd, _Decimal64); /* { dg-bogus "assignment from incompatible pointer type" } */ - ASSERT_CONST_TYPE (5 * .2DL, _Decimal128); /* { dg-bogus "assignment from incompatible pointer type" } */ - ASSERT_CONST_TYPE (.88dl / 2L, _Decimal128); /* { dg-bogus "assignment from incompatible pointer type" } */ - ASSERT_CONST_TYPE (.114df - 1.6dd, _Decimal64); /* { dg-bogus "assignment from incompatible pointer type" } */ - ASSERT_CONST_TYPE (3L - 1 + .55df, _Decimal32); /* { dg-bogus "assignment from incompatible pointer type" } */ - - return 0; -} diff --git a/gcc/testsuite/gcc.dg/dfp/usual-arith-conv.c b/gcc/testsuite/gcc.dg/dfp/usual-arith-conv.c deleted file mode 100644 index baff06bc175..00000000000 --- a/gcc/testsuite/gcc.dg/dfp/usual-arith-conv.c +++ /dev/null @@ -1,117 +0,0 @@ -/* { dg-options "-O0" } */ - -/* N1150 5.4: Usual arithmetic conversions. - C99 6.3.1.8[1] (New). - - Test arithmetic operators with different decimal float types, and - between decimal float types and integer types. */ - -#include "dfp-dbg.h" - -volatile _Decimal32 d32a, d32b, d32c; -volatile _Decimal64 d64a, d64b, d64c; -volatile _Decimal128 d128a, d128b, d128c; -volatile int i; - -void -init () -{ - d32b = 123.456e94df; - d64b = 12.3456789012345e383dd; - d128b = 12345.6789012345678901e4000dl; - - d32c = 1.3df; - d64c = 1.2dd; - d128c = 1.1dl; - - i = 2; -} - -int -main () -{ - init (); - - /* Usual arithmetic conversions between decimal float types; addition. */ - d128a = d128b + d32b; - if (d128a < d128b) - FAILURE - d128a = d32b + d128b; - if (d128a < d128b) - FAILURE - d128a = d128b + d64b; - if (d128a < d128b) - FAILURE - d128a = d64b + d128b; - if (d128a < d128b) - FAILURE - d64a = d64b + d32b; - if (d64a < d64b) - FAILURE - d64a = d32b + d64b; - if (d64a < d64b) - FAILURE - - /* Usual arithmetic conversions between decimal float types; - multiplication. */ - d128a = d128b * d32c; - if (d128a < d128b) - FAILURE - d128a = d32c * d128b; - if (d128a < d128b) - FAILURE - d128a = d128b * d64c; - if (d128a < d128b) - FAILURE - d128a = d64c * d128b; - if (d128a < d128b) - FAILURE - d64a = d64b * d32c; - if (d64a < d64b) - FAILURE - d64a = d32c * d64b; - if (d64a < d64b) - FAILURE - - /* Usual arithmetic conversions between decimal float and integer types. */ - d32a = d32c + i; - if (d32a != d32c + 2.0df) - FAILURE - d32a = d32c - i; - if (d32a != d32c - 2.0df) - FAILURE - d32a = i * d32c; - if (d32a != d32c + d32c) - FAILURE - d32a = d32c / i; - if (d32a != d32c / 2.0df) - FAILURE - - d64a = i + d64c; - if (d64a != d64c + 2.0dd) - FAILURE - d64a = d64c - i; - if (d64a != d64c - 2.0dd) - FAILURE - d64a = d64c * i; - if (d64a != d64c + d64c) - FAILURE - d64a = d64c / i; - if (d64a != d64c / 2.0dd) - FAILURE - - d128a = d128c + i; - if (d128a != d128c + 2.0dl) - FAILURE - d128a = d128c - i; - if (d128a != d128c - 2.0dl) - FAILURE - d128a = i * d128c; - if (d128a != d128c + d128c) - FAILURE - d128a = d128c / i; - if (d128a != d128c / 2.0dl) - FAILURE - - FINISH -}