From 8d3586e4e2426a2ae77c082134be67fe036c87a7 Mon Sep 17 00:00:00 2001 From: Jerry DeLisle Date: Tue, 15 Dec 2015 03:16:26 +0000 Subject: [PATCH] PR libfortran/pr68867 2015-12-14 Jerry DeLisle PR libfortran/pr68867 * io/write.c (set_fnode_default): For kind=16, set the decimal precision depending on the platform binary precision, 106 or 113. From-SVN: r231639 --- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gfortran.dg/quad_2.f90 | 11 ++++++----- libgfortran/ChangeLog | 6 ++++++ libgfortran/io/write.c | 7 +++++++ 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a4d593b217a..c2a5d8e1bf2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2015-12-14svn commit Jerry DeLisle + + * gfortran.dg/quad_2.f90: Update test. + 2015-12-14 Steve Ellcey * gcc.dg/tree-ssa/ssa-fre-4.c: Remove mips*-*-* target. diff --git a/gcc/testsuite/gfortran.dg/quad_2.f90 b/gcc/testsuite/gfortran.dg/quad_2.f90 index 1b3f918f83a..f7a8a469861 100644 --- a/gcc/testsuite/gfortran.dg/quad_2.f90 +++ b/gcc/testsuite/gfortran.dg/quad_2.f90 @@ -49,18 +49,19 @@ program test_qp if (str4 /= "1.41421356237309504876") call abort() case (16) - if (str1 /= " 1.00000000000000000000000000000000000") call abort() - if (str2 /= "1.00000000000000000000000000000000000") call abort() - if (digits(1.0_qp) == 113) then ! IEEE 754 binary 128 format ! e.g. libquadmath/__float128 on i686/x86_64/ia64 + if (str1 /= " 1.00000000000000000000000000000000000") call abort() + if (str2 /= "1.00000000000000000000000000000000000") call abort() if (str3 /= " 1.41421356237309504880168872420969798") call abort() if (str4 /= "1.41421356237309504880168872420969798") call abort() else if (digits(1.0_qp) == 106) then ! IBM binary 128 format - if (str3(1:37) /= " 1.41421356237309504880168872420969") call abort() - if (str4(1:34) /= "1.41421356237309504880168872420969") call abort() + if (str1 /= " 1.0000000000000000000000000000000") call abort() + if (str2 /= "1.0000000000000000000000000000000") call abort() + if (str3(1:37) /= " 1.4142135623730950488016887242097") call abort() + if (str4(1:34) /= "1.4142135623730950488016887242097") call abort() end if ! Do a libm run-time test diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index b8c698e28bb..2aca878cd77 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,9 @@ +2015-12-14 Jerry DeLisle + + PR libfortran/pr68867 + * io/write.c (set_fnode_default): For kind=16, set the decimal precision + depending on the platform binary precision, 106 or 113. + 2015-12-05 Juoko Orava PR fortran/50201 diff --git a/libgfortran/io/write.c b/libgfortran/io/write.c index 6656c976815..f72b4828aa6 100644 --- a/libgfortran/io/write.c +++ b/libgfortran/io/write.c @@ -1405,9 +1405,16 @@ set_fnode_default (st_parameter_dt *dtp, fnode *f, int length) f->u.real.e = 4; break; case 16: + /* Adjust decimal precision depending on binary precision, 106 or 113. */ +#if GFC_REAL_16_DIGITS == 113 f->u.real.w = 45; f->u.real.d = 36; f->u.real.e = 4; +#else + f->u.real.w = 41; + f->u.real.d = 32; + f->u.real.e = 4; +#endif break; default: internal_error (&dtp->common, "bad real kind"); -- 2.30.2