From: kargl Date: Sun, 26 Mar 2006 05:20:09 +0000 (+0000) Subject: PR fortran/26816 X-Git-Url: http://git.sourceforge.jp/view?p=pf3gnuchains%2Fgcc-fork.git;a=commitdiff_plain;h=06a4a0dd0feb22ae48e4272ca3700dd83a5dd2f9 PR fortran/26816 * intrinsic.c (add_functions): Allow FLOAT to accept all integer kinds. * intrinsic.texi: Document FLOAT. * gfortran.dg/float_1.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@112392 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 5937e09a45f..e5245db20f7 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2006-03-25 Steven G. Kargl + + PR fortran/26816 + * intrinsic.c (add_functions): Allow FLOAT to accept all integer kinds. + * intrinsic.texi: Document FLOAT. + 2006-03-25 Thomas Koenig PR fortran/26769 diff --git a/gcc/fortran/intrinsic.c b/gcc/fortran/intrinsic.c index 56f92a2dca3..707fe5b456a 100644 --- a/gcc/fortran/intrinsic.c +++ b/gcc/fortran/intrinsic.c @@ -1899,7 +1899,7 @@ add_functions (void) a, BT_UNKNOWN, dr, REQUIRED); add_sym_1 ("float", 1, 0, BT_REAL, dr, GFC_STD_F77, - NULL, gfc_simplify_float, NULL, + gfc_check_i, gfc_simplify_float, NULL, a, BT_INTEGER, di, REQUIRED); add_sym_1 ("sngl", 1, 0, BT_REAL, dr, GFC_STD_F77, diff --git a/gcc/fortran/intrinsic.texi b/gcc/fortran/intrinsic.texi index 81a56f5fb40..5942329be8c 100644 --- a/gcc/fortran/intrinsic.texi +++ b/gcc/fortran/intrinsic.texi @@ -88,6 +88,7 @@ and editing. All contributions and corrections are strongly encouraged. * @code{EXP}: EXP, Exponential function * @code{EXPONENT}: EXPONENT, Exponent function * @code{FDATE}: FDATE, Subroutine (or function) to get the current time as a string +* @code{FLOAT}: FLOAT, Convert integer to default real * @code{FLOOR}: FLOOR, Integer floor function * @code{FNUM}: FNUM, File number function * @code{FREE}: FREE, Memory de-allocation subroutine @@ -2842,6 +2843,41 @@ end program test_fdate @end smallexample @end table +@node FLOAT +@section @code{FLOAT} --- Convert integer to default real +@findex @code{FLOAT} intrinsic +@cindex floor + +@table @asis +@item @emph{Description}: +@code{FLOAT(I)} converts the integer @var{I} to a default real value. + +@item @emph{Option}: +gnu + +@item @emph{Class}: +function + +@item @emph{Syntax}: +@code{X = FLOAT(I)} + +@item @emph{Arguments}: +@multitable @columnfractions .15 .80 +@item @var{I} @tab The type shall be @code{INTEGER(*)}. +@end multitable + +@item @emph{Return value}: +The return value is of type default @code{REAL} + +@item @emph{Example}: +@smallexample +program test_float + integer :: i = 1 + if (float(i) /= 1.) call abort +end program test_float +@end smallexample +@end table + @node FLOOR @section @code{FLOOR} --- Integer floor function diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 30d523ea916..2a9840b8979 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2006-03-25 Steven G. Kargl + + PR fortran/26816 + * gfortran.dg/float_1.f90: New test. + 2006-03-25 Steven G. Kargl * gfortran.dg/transfer_array_intrinsic_1.f90: Restrict to i?86 and diff --git a/gcc/testsuite/gfortran.dg/float_1.f90 b/gcc/testsuite/gfortran.dg/float_1.f90 new file mode 100644 index 00000000000..224d31dce0d --- /dev/null +++ b/gcc/testsuite/gfortran.dg/float_1.f90 @@ -0,0 +1,12 @@ +! { dg-do run } +! PR fortran/26816 +program test_float + integer(1) :: i1 = 1 + integer(2) :: i2 = 1 + integer(4) :: i4 = 1 + integer(8) :: i8 = 1 + if (float(i1) /= 1.) call abort + if (float(i2) /= 1.) call abort + if (float(i4) /= 1.) call abort + if (float(i8) /= 1.) call abort +end program test_float