From 725a74a517294915302c713ee309340779514621 Mon Sep 17 00:00:00 2001 From: Dominique d'Humieres Date: Thu, 12 Jan 2012 07:53:59 +0100 Subject: [PATCH] re PR testsuite/51057 (FAIL: gfortran.dg/quad_2.f90 -O0 execution test on powerpc*-*-*) 2012-01-12 Dominique d'Humieres Tobias Burnus PR fortran/51057 PR fortran/51616 * lib/target-supports.exp (check_effective_target_fortran_largest_fp_has_sqrt): New. * gfortran.dg/quad_2.f90: Use it, add pattern for IBM's real(16). Co-Authored-By: Tobias Burnus From-SVN: r183121 --- gcc/testsuite/ChangeLog | 9 +++++++++ gcc/testsuite/gfortran.dg/quad_2.f90 | 19 +++++++++++++++++-- gcc/testsuite/lib/target-supports.exp | 22 ++++++++++++++++++++++ 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 29c31f06d62..b576b6928d4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2012-01-12 Dominique d'Humieres + Tobias Burnus + + PR fortran/51057 + PR fortran/51616 + * lib/target-supports.exp + (check_effective_target_fortran_largest_fp_has_sqrt): New. + * gfortran.dg/quad_2.f90: Use it, add pattern for IBM's real(16). + 2012-01-11 Jason Merrill PR c++/51565 diff --git a/gcc/testsuite/gfortran.dg/quad_2.f90 b/gcc/testsuite/gfortran.dg/quad_2.f90 index c1334db9cd4..d3c90a0bc2a 100644 --- a/gcc/testsuite/gfortran.dg/quad_2.f90 +++ b/gcc/testsuite/gfortran.dg/quad_2.f90 @@ -1,4 +1,5 @@ ! { dg-do run } +! { dg-require-effective-target fortran_largest_fp_has_sqrt } ! ! This test checks whether the largest possible ! floating-point number works. @@ -40,22 +41,36 @@ program test_qp if (str2 /= "1.0000000000000000") call abort() if (str3 /= " 1.4142135623730951") call abort() if (str4 /= "1.4142135623730951") call abort() + case (10) if (str1 /= " 1.00000000000000000000") call abort() if (str2 /= "1.00000000000000000000") call abort() if (str3 /= " 1.41421356237309504876") call abort() if (str4 /= "1.41421356237309504876") call abort() + case (16) if (str1 /= " 1.00000000000000000000000000000000000") call abort() if (str2 /= "1.00000000000000000000000000000000000") call abort() - if (str3 /= " 1.41421356237309504880168872420969798") call abort() - if (str4 /= "1.41421356237309504880168872420969798") call abort() + + if (digits(1.0_qp) == 113) then + ! IEEE 754 binary 128 format + ! e.g. libquadmath/__float128 on i686/x86_64/ia64 + 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() + end if + + ! Do a libm run-time test block real(qp), volatile :: fp2a fp2a = 2.0_qp fp2a = sqrt (fp2a) if (abs (fp2a - fp2) > sqrt(2.0_qp)-nearest(sqrt(2.0_qp),-1.0_qp)) call abort() end block + case default call abort() end select diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 9f2d7bae863..be33407a409 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -984,6 +984,28 @@ proc check_effective_target_fortran_real_16 { } { }] } + +# Return 1 if the target supports SQRT for the largest floating-point +# type. (Some targets lack the libm support for this FP type.) +# On most targets, this check effectively checks either whether sqrtl is +# available or on __float128 systems whether libquadmath is installed, +# which provides sqrtq. +# +# When the target name changes, replace the cached result. + +proc check_effective_target_fortran_largest_fp_has_sqrt { } { + return [check_no_compiler_messages fortran_largest_fp_has_sqrt executable { + ! Fortran + use iso_fortran_env, only: real_kinds + integer,parameter:: maxFP = real_kinds(ubound(real_kinds,dim=1)) + real(kind=maxFP), volatile :: x + x = 2.0_maxFP + x = sqrt (x) + end + }] +} + + # Return 1 if the target supports Fortran integer kinds larger than # integer(8), 0 otherwise. #