Patchwork [testsuite] PR47293 Real 16 NaN test

login
register
mail settings
Submitter Jerry DeLisle
Date Jan. 29, 2011, 9:36 p.m.
Message ID <4D44884A.9010808@frontier.com>
Download mbox | patch
Permalink /patch/80963/
State New
Headers show

Comments

Jerry DeLisle - Jan. 29, 2011, 9:36 p.m.
Hi,

This patch adds a check in the test mechanism for dg-require-effective-target 
fortran_real_16. The patch also adds a new test case, nan_7.f90 which passes on 
x86-64. It should pass on PPC as well.  There are some differences in the 
results between platforms for reading "NaN" so the test case masks out the bits 
that differ.

OK for trunk?  (This must go in after the NaN patch posted earlier for libquadmath.

Regards,

Jerry

PS I will include a ChangeLog entry.

Patch

Index: lib/target-supports.exp
===================================================================
--- lib/target-supports.exp	(revision 169374)
+++ lib/target-supports.exp	(working copy)
@@ -945,6 +945,22 @@  proc check_effective_target_fortran_large_real { }
     }]
 }
 
+# Return 1 if the target supports Fortran real kind real(16),
+# 0 otherwise. Contrary to check_effective_target_fortran_large_real
+# this checks for Real(16) only; the other returned real(10) if
+# both real(10) and real(16) are available.
+#
+# When the target name changes, replace the cached result.
+
+proc check_effective_target_fortran_real_16 { } {
+    return [check_no_compiler_messages fortran_large_real executable {
+	! Fortran
+	real(kind=16) :: x
+	x = cos (x)
+	end
+    }]
+}
+
 # Return 1 if the target supports Fortran integer kinds larger than
 # integer(8), 0 otherwise.
 #
Index: gfortran.dg/nan_7.f90
===================================================================
--- gfortran.dg/nan_7.f90	(revision 0)
+++ gfortran.dg/nan_7.f90	(revision 0)
@@ -0,0 +1,15 @@ 
+! { dg-do run }
+! { dg-options "-fno-range-check" }
+! { dg-require-effective-target fortran_real_16 }
+! { dg-require-effective-target fortran_integer_16 }
+! PR47293 NAN not correctly read
+character(len=200) :: str
+real(16) :: r
+integer(16) :: k2
+integer(16), parameter :: quietnan = 170099645085600953110659059745250344960
+r = 1.0
+str = 'NAN' ; read(str,*) r
+k2 = transfer(r,k2)
+k2 = iand(k2, z'fff80000000000000000000000000000')
+if (k2.ne.quietnan) call abort
+end