diff options
author | fxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-06-23 18:50:25 +0000 |
---|---|---|
committer | fxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-06-23 18:50:25 +0000 |
commit | 14c3c2352d4d6f42b4dcb7708bd6e1f14b340053 (patch) | |
tree | ff58180369190fdcfc2adfcd84037e51fead61ad /gcc | |
parent | 63a39322242c2834d22c20472e5619697edb68aa (diff) | |
download | gcc-14c3c2352d4d6f42b4dcb7708bd6e1f14b340053.tar.gz |
* intrinsics/c99_functions.c (log10l): New log10l function for
systems where this is not available.
* c99_protos.h: Prototype for log10l function.
* libgfortran.h: Use generated kinds.h to define GFC_INTEGER_*,
GFC_UINTEGER_*, GFC_LOGICAL_*, GFC_REAL_*, GFC_COMPLEX_*. Update
prototypes for gfc_itoa and xtoa.
* io/io.h: Update prototypes for set_integer and max_value.
* io/list_read.c (convert_integer): Use new
GFC_(INTEGER|REAL)_LARGEST type.
* io/read.c (set_integer): Likewise.
(max_value): Likewise.
(convert_real): Likewise.
(real_l): Likewise.
(next_char): Likewise.
(read_decimal): Likewise.
(read_radix): Likewise.
(read_f): Likewise.
* io/write.c (extract_int): Use new GFC_INTEGER_LARGEST type.
(extract_real): Use new GFC_REAL_LARGEST type.
(calculate_exp): Likewise.
(calculate_G_format): Likewise.
(output_float): Likewise. Use log10l for long double values.
Add comment for sprintf format. Use GFC_REAL_LARGEST_FORMAT.
(write_l): Use new GFC_INTEGER_LARGEST type.
(write_float): Use new GFC_REAL_LARGEST type.
(write_int): Remove useless special case for (len < 8).
(write_decimal): Use GFC_INTEGER_LARGEST.
(otoa): Use GFC_UINTEGER_LARGEST as argument.
(btoa): Use GFC_UINTEGER_LARGEST as argument.
* runtime/error.c (gfc_itoa): Use GFC_INTEGER_LARGEST as
argument.
(xtoa): Use GFC_UINTEGER_LARGEST as argument.
* Makefile.am: Use mk-kinds-h.sh to generate header kinds.h
with all Fortran kinds available.
* configure.ac: Check for strtold and log10l.
* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.
* config.h.in: Regenerate.
* mk-kinds-h.sh: Configuration script for available integer
and real kinds.
* lib/target-supports.exp: Add
check_effective_target_fortran_large_real and
check_effective_target_fortran_large_int to check for
corresponding effective targets.
* gfortran.dg/large_integer_kind_1.f90: New test.
* gfortran.dg/large_real_kind_1.f90: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@101274 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/large_integer_kind_1.f90 | 38 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/large_real_kind_1.f90 | 77 | ||||
-rw-r--r-- | gcc/testsuite/lib/target-supports.exp | 76 |
4 files changed, 200 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6250859ac8b..135b52835bc 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2005-06-23 Francois-Xavier Coudert <coudert@clipper.ens.fr> + + * lib/target-supports.exp: Add + check_effective_target_fortran_large_real and + check_effective_target_fortran_large_int to check for + corresponding effective targets. + * gfortran.dg/large_integer_kind_1.f90: New test. + * gfortran.dg/large_real_kind_1.f90: New test. + 2005-06-23 Kazu Hirata <kazu@codesourcery.com> PR tree-optimization/22117 diff --git a/gcc/testsuite/gfortran.dg/large_integer_kind_1.f90 b/gcc/testsuite/gfortran.dg/large_integer_kind_1.f90 new file mode 100644 index 00000000000..9511317901c --- /dev/null +++ b/gcc/testsuite/gfortran.dg/large_integer_kind_1.f90 @@ -0,0 +1,38 @@ +! { dg-do run } +! { dg-require-effective-target fortran_large_int } + +module testmod + integer,parameter :: k = selected_int_kind (range (0_8) + 1) +contains + subroutine testoutput (a,b,length,f) + integer(kind=k),intent(in) :: a + integer(kind=8),intent(in) :: b + integer,intent(in) :: length + character(len=*),intent(in) :: f + + character(len=length) :: ca + character(len=length) :: cb + + write (ca,f) a + write (cb,f) b + if (ca /= cb) call abort + end subroutine testoutput +end module testmod + + +! Testing I/O of large integer kinds (larger than kind=8) +program test + use testmod + implicit none + + integer(kind=k) :: x + character(len=50) :: c1, c2 + + call testoutput (0_k,0_8,50,'(I50)') + call testoutput (1_k,1_8,50,'(I50)') + call testoutput (-1_k,-1_8,50,'(I50)') + x = huge(0_8) + call testoutput (x,huge(0_8),50,'(I50)') + x = -huge(0_8) + call testoutput (x,-huge(0_8),50,'(I50)') +end program test diff --git a/gcc/testsuite/gfortran.dg/large_real_kind_1.f90 b/gcc/testsuite/gfortran.dg/large_real_kind_1.f90 new file mode 100644 index 00000000000..705b51eeb09 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/large_real_kind_1.f90 @@ -0,0 +1,77 @@ +! { dg-do run } +! { dg-require-effective-target fortran_large_real } + +module testmod + integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1) +contains + subroutine testoutput (a,b,length,f) + real(kind=k),intent(in) :: a + real(kind=8),intent(in) :: b + integer,intent(in) :: length + character(len=*),intent(in) :: f + + character(len=length) :: ca + character(len=length) :: cb + + write (ca,f) a + write (cb,f) b + if (ca /= cb) call abort + end subroutine testoutput + + subroutine outputstring (a,f,s) + real(kind=k),intent(in) :: a + character(len=*),intent(in) :: f + character(len=*),intent(in) :: s + + character(len=len(s)) :: c + + write (c,f) a + if (c /= s) call abort + end subroutine outputstring +end module testmod + + +! Testing I/O of large real kinds (larger than kind=8) +program test + use testmod + implicit none + + real(kind=k) :: x + character(len=20) :: c1, c2 + + call testoutput (0.0_k,0.0_8,40,'(F40.35)') + + call testoutput (1.0_k,1.0_8,40,'(F40.35)') + call testoutput (0.1_k,0.1_8,15,'(F15.10)') + call testoutput (1e10_k,1e10_8,15,'(F15.10)') + call testoutput (7.51e100_k,7.51e100_8,15,'(F15.10)') + call testoutput (1e-10_k,1e-10_8,15,'(F15.10)') + call testoutput (7.51e-100_k,7.51e-100_8,15,'(F15.10)') + + call testoutput (-1.0_k,-1.0_8,40,'(F40.35)') + call testoutput (-0.1_k,-0.1_8,15,'(F15.10)') + call testoutput (-1e10_k,-1e10_8,15,'(F15.10)') + call testoutput (-7.51e100_k,-7.51e100_8,15,'(F15.10)') + call testoutput (-1e-10_k,-1e-10_8,15,'(F15.10)') + call testoutput (-7.51e-100_k,-7.51e-100_8,15,'(F15.10)') + + x = huge(x) + call outputstring (2*x,'(F20.15)',' +Infinity') + call outputstring (-2*x,'(F20.15)',' -Infinity') + + write (c1,'(G20.10E5)') x + write (c2,'(G20.10E5)') -x + if (c2(1:1) /= '-') call abort + c2(1:1) = ' ' + if (c1 /= c2) call abort + + x = tiny(x) + call outputstring (x,'(F20.15)',' 0.000000000000000') + call outputstring (-x,'(F20.15)',' 0.000000000000000') + + write (c1,'(G20.10E5)') x + write (c2,'(G20.10E5)') -x + if (c2(1:1) /= '-') call abort + c2(1:1) = ' ' + if (c1 /= c2) call abort +end program test diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 03781699775..dfe7918cfb6 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -410,6 +410,82 @@ proc check_named_sections_available { } { return $answer } +# Return 1 if the target supports Fortran real kinds larger than real(8), +# 0 otherwise. Cache the result. + +proc check_effective_target_fortran_large_real { } { + global et_fortran_large_real_saved + global tool + + if [info exists et_fortran_large_real_saved] { + verbose "check_effective_target_fortran_large_real returning saved $et_fortran_large_real_saved" 2 + } else { + set et_fortran_large_real_saved 0 + + # Set up, compile, and execute a test program using large real + # kinds. Include the current process ID in the file names to + # prevent conflicts with invocations for multiple testsuites. + set src real[pid].f90 + set exe real[pid].x + + set f [open $src "w"] + puts $f "integer,parameter :: k = &" + puts $f " selected_real_kind (precision (0.0_8) + 1)" + puts $f "real(kind=k) :: x" + puts $f "end" + close $f + + verbose "check_effective_target_fortran_large_real compiling testfile $src" 2 + set lines [${tool}_target_compile $src $exe executable ""] + file delete $src + + if [string match "" $lines] then { + # No error message, compilation succeeded. + set et_fortran_large_real_saved 1 + } + } + + return $et_fortran_large_real_saved +} + +# Return 1 if the target supports Fortran integer kinds larger than +# integer(8), 0 otherwise. Cache the result. + +proc check_effective_target_fortran_large_int { } { + global et_fortran_large_int_saved + global tool + + if [info exists et_fortran_large_int_saved] { + verbose "check_effective_target_fortran_large_int returning saved $et_fortran_large_int_saved" 2 + } else { + set et_fortran_large_int_saved 0 + + # Set up, compile, and execute a test program using large integer + # kinds. Include the current process ID in the file names to + # prevent conflicts with invocations for multiple testsuites. + set src int[pid].f90 + set exe int[pid].x + + set f [open $src "w"] + puts $f "integer,parameter :: k = &" + puts $f " selected_int_kind (range (0_8) + 1)" + puts $f "integer(kind=k) :: i" + puts $f "end" + close $f + + verbose "check_effective_target_fortran_large_int compiling testfile $src" 2 + set lines [${tool}_target_compile $src $exe executable ""] + file delete $src + + if [string match "" $lines] then { + # No error message, compilation succeeded. + set et_fortran_large_int_saved 1 + } + } + + return $et_fortran_large_int_saved +} + # Return 1 if the target supports executing AltiVec instructions, 0 # otherwise. Cache the result. |