OSDN Git Service

2012-01-12 Dominique d'Humieres <dominiq@lps.ens.fr>
authorburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 12 Jan 2012 06:53:59 +0000 (06:53 +0000)
committerburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 12 Jan 2012 06:53:59 +0000 (06:53 +0000)
            Tobias Burnus  <burnus@net-b.de>

        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).

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@183121 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/quad_2.f90
gcc/testsuite/lib/target-supports.exp

index 29c31f0..b576b69 100644 (file)
@@ -1,3 +1,12 @@
+2012-01-12  Dominique d'Humieres  <dominiq@lps.ens.fr>
+           Tobias Burnus  <burnus@net-b.de>
+
+       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  <jason@redhat.com>
 
        PR c++/51565
index c1334db..d3c90a0 100644 (file)
@@ -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
index 9f2d7ba..be33407 100644 (file)
@@ -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.
 #