This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH, fortran] Fix a few PRs.


2007-11-28  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: Document the C escaped characters activated
	by -fbackslash.  Improve -fno-range-check description.

	PR libfortran/33583
	* libgfortran/gfortran.map: Add tgammaf.
	* gfortran.dg/gamma_5.f90: Remove xfail.

-- 
Steve
Index: gcc/testsuite/gfortran.dg/gamma_5.f90
===================================================================
--- gcc/testsuite/gfortran.dg/gamma_5.f90	(revision 130499)
+++ 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 130499)
+++ 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 130499)
+++ 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 130499)
+++ gcc/fortran/arith.c	(working copy)
@@ -348,14 +348,21 @@ 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;
+	{
+	  mpfr_set_ui (q, 0, GFC_RND_MODE);
+	  mpfr_setsign (p, q, mpfr_signbit (p), GFC_RND_MODE);
+	  retval = ARITH_OK;
+	}
       else
 	retval = ARITH_UNDERFLOW;
     }
Index: libgfortran/gfortran.map
===================================================================
--- libgfortran/gfortran.map	(revision 130499)
+++ libgfortran/gfortran.map	(working copy)
@@ -1155,4 +1155,5 @@ GFORTRAN_C99_1.0 {
     y0f;
     y1f;
     ynf;
+    tgammaf;
 };

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]