This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[Fortran] Committed fix for FLOAT intrinsics
- From: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- To: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Tue, 28 Mar 2006 11:44:52 -0800
- Subject: [Fortran] Committed fix for FLOAT intrinsics
I've committed the following patch under the "Obviously
correct" rule to both trunk (3 days ago) and 4.1 (today).
This fixes a regression with respect to g77.
Bootstraps of trunk and 4.1 and regression tests were done
on i386-*-freebsd and amd64-*-freebsd. Documentation was
checked with a "gmake dvi" in 4.1.
2006-03-28 Steven G. Kargl <kargls@comcast.net>
PR fortran/26816
* intrinsic.c (add_functions): Allow FLOAT to accept all integer kinds.
* intrinsic.texi: Document FLOAT.
2006-03-28 Steven G. Kargl <kargls@comcast.net>
PR fortran/26816
* gfortran.dg/float_1.f90: New test.
! { 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
Index: intrinsic.c
===================================================================
--- intrinsic.c (revision 112390)
+++ intrinsic.c (working copy)
@@ -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,
Index: intrinsic.texi
===================================================================
--- intrinsic.texi (revision 112390)
+++ intrinsic.texi (working copy)
@@ -88,6 +88,7 @@ and editing. All contributions and corr
* @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
@@ -2839,6 +2840,41 @@ program test_fdate
call fdate(date)
print *, 'Program ended on ', date
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
--
Steve