]> gcc.gnu.org Git - gcc.git/commitdiff
fortran: fix handling of options -ffpe-trap and -ffpe-summary [PR110957]
authorHarald Anlauf <anlauf@gmx.de>
Fri, 6 Oct 2023 20:21:56 +0000 (22:21 +0200)
committerHarald Anlauf <anlauf@gmx.de>
Fri, 13 Oct 2023 16:54:53 +0000 (18:54 +0200)
gcc/fortran/ChangeLog:

PR fortran/110957
* invoke.texi: Update documentation to reflect '-ffpe-trap=none'.
* options.cc (gfc_handle_fpe_option): Fix mixup up of error messages
for options -ffpe-trap and -ffpe-summary.  Accept '-ffpe-trap=none'
to clear FPU traps previously set on command line.

gcc/fortran/invoke.texi
gcc/fortran/options.cc

index 38150b1e29eab3991ae9507ac96587f3582e60d5..10387e39501026857def19adcc78b5a50352b44c 100644 (file)
@@ -1294,7 +1294,8 @@ Specify a list of floating point exception traps to enable.  On most
 systems, if a floating point exception occurs and the trap for that
 exception is enabled, a SIGFPE signal will be sent and the program
 being aborted, producing a core file useful for debugging.  @var{list}
-is a (possibly empty) comma-separated list of the following
+is a (possibly empty) comma-separated list of either @samp{none} (to
+clear the set of exceptions to be trapped), or of the following
 exceptions: @samp{invalid} (invalid floating point operation, such as
 @code{SQRT(-1.0)}), @samp{zero} (division by zero), @samp{overflow}
 (overflow in a floating point operation), @samp{underflow} (underflow
@@ -1314,7 +1315,8 @@ If the option is used more than once in the command line, the lists will
 be joined: '@code{ffpe-trap=}@var{list1} @code{ffpe-trap=}@var{list2}'
 is equivalent to @code{ffpe-trap=}@var{list1},@var{list2}.
 
-Note that once enabled an exception cannot be disabled (no negative form).
+Note that once enabled an exception cannot be disabled (no negative form),
+except by clearing all traps by specifying @samp{none}.
 
 Many, if not most, floating point operations incur loss of precision
 due to rounding, and hence the @code{ffpe-trap=inexact} is likely to
index 27311961325da4114345494b409e587e19928d91..2ad22478042991cd3728145a9371ea29bb04613f 100644 (file)
@@ -555,9 +555,12 @@ gfc_handle_fpe_option (const char *arg, bool trap)
        pos++;
 
       result = 0;
-      if (!trap && strncmp ("none", arg, pos) == 0)
+      if (strncmp ("none", arg, pos) == 0)
        {
-         gfc_option.fpe_summary = 0;
+         if (trap)
+           gfc_option.fpe = 0;
+         else
+           gfc_option.fpe_summary = 0;
          arg += pos;
          pos = 0;
          continue;
@@ -586,7 +589,7 @@ gfc_handle_fpe_option (const char *arg, bool trap)
              break;
            }
          }
-      if (!result && !trap)
+      if (!result && trap)
        gfc_fatal_error ("Argument to %<-ffpe-trap%> is not valid: %s", arg);
       else if (!result)
        gfc_fatal_error ("Argument to %<-ffpe-summary%> is not valid: %s", arg);
This page took 0.282987 seconds and 5 git commands to generate.