This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [PATCH, fortran] Fix a few PRs.
On Thu, Nov 29, 2007 at 10:56:26AM +0100, Tobias Burnus wrote:
> Hi Steve and Jerry,
> > Steve Kargl wrote:
> >> * fortran/invoke.texi: Document the C escaped characters activated
> >> by -fbackslash. Improve -fno-range-check description.
> The C-escaped characters patch is came up for PR fortran/34203. You
> could cite this PR in the ChangeLog.
>
> If an expression evaluates to a value
> +outside of the relevant range of \[@code{-HUGE()}:@code{HUGE()}\],
> +then the expression will be replaced by @code{-Inf} or @code{+Inf}
> +as appropriate.
>
> Change "\[ ... \]" into "[ ... ]".
>
> >> PR libfortran/33583
> >> * libgfortran/gfortran.map: Add tgammaf.
> You should also add "tgamma" (double-precision version) and lgamma and
> lgammaf, for which also fall-back implementations exists in libgfortran.
>
> Thanks for the patch,
>
> Jerry DeLisle wrote:
> > I will commit for you.
>
> Thanks for taking care for this patch.
>
Updated patch.
2007-11-29 Steven G. Kargl <kargls@comcast.net>
PR fortran/34230
* fortran/arith.c (gfc_check_real_range): Set intermediate values
to +-Inf and 0 when -fno-range-check is in effect.
* gfortran.dg/real_const_3.f90: Fix up for new range-check handling.
* fortran/invoke.texi: Improve -fno-range-check description.
PR fortran/34203
* fortran/invoke.texi: Document the C escaped characters activated
by -fbackslash.
PR libfortran/33583
* libgfortran/gfortran.map: Add tgammaf, tgamma, lgamma, and lgammaf.
* gfortran.dg/gamma_5.f90: Remove xfail.
--
Steve
Index: gcc/testsuite/gfortran.dg/gamma_5.f90
===================================================================
--- gcc/testsuite/gfortran.dg/gamma_5.f90 (revision 130517)
+++ gcc/testsuite/gfortran.dg/gamma_5.f90 (working copy)
@@ -1,5 +1,4 @@
! { dg-do run }
-! { dg-xfail-if "" { "*-*-freebsd*" } { "*" } { "" } }
! PR 33683 - we used to pick up the wrong gamma function
! from the library on some systems.
program main
Index: gcc/testsuite/gfortran.dg/real_const_3.f90
===================================================================
--- gcc/testsuite/gfortran.dg/real_const_3.f90 (revision 130517)
+++ gcc/testsuite/gfortran.dg/real_const_3.f90 (working copy)
@@ -3,39 +3,52 @@
! PR19310 and PR19904, allow disabling range check during compile.
! Contributed by Jerry DeLisle <jvdelisle@gcc.gnu.org>
program main
+ character(len=80) str
real, parameter :: zero=0, nan=0/zero
complex :: z = (-0.1,-2.2)/(0.0,0.0)
complex :: z2 = (0.1,1)/0
- complex :: z3 = (1e300, -2e-200)/1234e-325
- complex :: z4 = (1e-300, -2e-200)/1234e325
+ complex :: z3 = (1e35, -2e3)/1.234e-37
+ complex :: z4 = (1e-35, -2e-35)/1234e34
real :: a
a = exp(1000.0)
b = 1/exp(1000.0)
- print *, a
- print *, b
- print *, -1.0/b
- print *, b/0.0
- print *, 0.0/0.0
- print *, 1.0/-0.0
- print *, -2.0/0.0
- print *, 3.0/0.0
- print *, nan
- print *, z
- print *, z2
- print *, z3
- print *, z4
+
+ write(str,*) a
+ if (trim(adjustl(str)) .ne. '+Infinity') call abort
+
+ if (b .ne. 0.) call abort
+
+ write(str,*) -1.0/b
+ if (trim(adjustl(str)) .ne. '-Infinity') call abort
+
+ write(str,*) b/0.0
+ if (trim(adjustl(str)) .ne. 'NaN') call abort
+
+ write(str,*) 0.0/0.0
+ if (trim(adjustl(str)) .ne. 'NaN') call abort
+
+ write(str,*) 1.0/-0.
+ if (trim(adjustl(str)) .ne. '-Infinity') call abort
+
+ write(str,*) -2.0/0.
+ if (trim(adjustl(str)) .ne. '-Infinity') call abort
+
+ write(str,*) 3.0/0.
+ if (trim(adjustl(str)) .ne. '+Infinity') call abort
+
+ write(str,*) nan
+ if (trim(adjustl(str)) .ne. 'NaN') call abort
+
+ write(str,*) z
+ if (trim(adjustl(str)) .ne. '( NaN, NaN)') call abort
+
+ write(str,*) z2
+ if (trim(adjustl(str)) .ne. '( NaN, NaN)') call abort
+
+ write(str,*) z3
+ if (trim(adjustl(str)) .ne. '( +Infinity, -Infinity)') call abort
+
+ write(str,*) z4
+ if (trim(adjustl(str)) .ne. '( 0.0000000 , -0.0000000 )') call abort
end program main
-!{ dg-output " \\+Infinity(\n|\r\n|\r)" }
-!{ dg-output " 0.0000000 (\n|\r\n|\r)" }
-!{ dg-output " -Infinity(\n|\r\n|\r)" }
-!{ dg-output " NaN(\n|\r\n|\r)" }
-!{ dg-output " NaN(\n|\r\n|\r)" }
-!{ dg-output " -Infinity(\n|\r\n|\r)" }
-!{ dg-output " -Infinity(\n|\r\n|\r)" }
-!{ dg-output " \\+Infinity(\n|\r\n|\r)" }
-!{ dg-output " NaN(\n|\r\n|\r)" }
-!{ dg-output " \\( NaN, NaN\\)(\n|\r\n|\r)" }
-!{ dg-output " \\( NaN, NaN\\)(\n|\r\n|\r)" }
-!{ dg-output " \\( \\+Infinity, -Infinity\\)(\n|\r\n|\r)" }
-!{ dg-output " \\( 0.0000000 , -0.0000000 \\)(\n|\r\n|\r)" }
Index: gcc/fortran/invoke.texi
===================================================================
--- gcc/fortran/invoke.texi (revision 130517)
+++ gcc/fortran/invoke.texi (working copy)
@@ -239,6 +239,11 @@ Allow @samp{$} as a valid character in a
@cindex escape characters
Change the interpretation of backslashes in string literals
from a single backslash character to ``C-style'' escape characters.
+The following combinations are expanded \a, \b, \f, \n, \r, \t,
+\v, \\, and \0 to the ASCII characters alert, backspace, form feed,
+newline, carriage return, horizontal tab, vertical tab, backslash,
+and NUL, respectively. All other combinations of a character preceded
+by \ are unexpanded.
@item -fmodule-private
@opindex @code{fmodule-private}
@@ -303,10 +308,13 @@ in. The option @option{-fopenmp} implie
@item -fno-range-check
@opindex @code{frange-check}
Disable range checking on results of simplification of constant
-expressions during compilation. For example, by default, GNU Fortran
-will give an overflow error at compile time when simplifying @code{a =
-EXP(1000)}. With @option{-fno-range-check}, no error will be given and
-the variable @code{a} will be assigned the value @code{+Infinity}.
+expressions during compilation. For example, GNU Fortran will give
+an error at compile time when simplifying @code{a = 1. / 0}.
+With this option, no error will be given and @code{a} will be assigned
+the value @code{+Infinity}. If an expression evaluates to a value
+outside of the relevant range of [@code{-HUGE()}:@code{HUGE()}],
+then the expression will be replaced by @code{-Inf} or @code{+Inf}
+as appropriate.
Similarly, @code{DATA i/Z'FFFFFFFF'/} will result in an integer overflow
on most systems, but with @option{-fno-range-check} the value will
``wrap around'' and @code{i} will be initialized to @math{-1} instead.
Index: gcc/fortran/arith.c
===================================================================
--- gcc/fortran/arith.c (revision 130517)
+++ gcc/fortran/arith.c (working copy)
@@ -348,14 +348,27 @@ gfc_check_real_range (mpfr_t p, int kind
else if (mpfr_cmp (q, gfc_real_kinds[i].huge) > 0)
{
if (gfc_option.flag_range_check == 0)
- retval = ARITH_OK;
+ {
+ mpfr_set_inf (p, mpfr_sgn (p));
+ retval = ARITH_OK;
+ }
else
retval = ARITH_OVERFLOW;
}
else if (mpfr_cmp (q, gfc_real_kinds[i].subnormal) < 0)
{
if (gfc_option.flag_range_check == 0)
- retval = ARITH_OK;
+ {
+ if (mpfr_sgn (p) < 0)
+ {
+ mpfr_set_ui (p, 0, GFC_RND_MODE);
+ mpfr_set_si (q, -1, GFC_RND_MODE);
+ mpfr_copysign (p, p, q, GFC_RND_MODE);
+ }
+ else
+ mpfr_set_ui (p, 0, GFC_RND_MODE);
+ retval = ARITH_OK;
+ }
else
retval = ARITH_UNDERFLOW;
}
Index: libgfortran/gfortran.map
===================================================================
--- libgfortran/gfortran.map (revision 130517)
+++ libgfortran/gfortran.map (working copy)
@@ -1136,6 +1136,8 @@ GFORTRAN_C99_1.0 {
j0f;
j1f;
jnf;
+ lgamma;
+ lgammaf;
log10f;
log10l;
logf;
@@ -1150,6 +1152,8 @@ GFORTRAN_C99_1.0 {
sqrtf;
tanf;
tanhf;
+ tgamma;
+ tgammaf;
trunc;
truncf;
y0f;