From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2071) id EBFD938560AA; Fri, 13 Oct 2023 20:07:57 +0000 (GMT) ARC-Filter: OpenARC Filter v1.0.0 sourceware.org EBFD938560AA Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=127.0.0.1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697227678; cv=none; b=dbWoK+/4ipx/uy2M0a1djTxM3hMBXx1SjGG5Cn1zosMn8FOgl7jJKPRAzUcm70DN4TuhvNYlUT9udALyZ58uaBTt8dRsq+ShzGlOZ1dQqg5E55F0pSlUygKpEbNBReua0v4u2eIVEYewpCNu3B4Bi/VvPrVZcwxaXpJSGw2hRNo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697227678; c=relaxed/simple; bh=DATEU8v9g7bIgk/E/HcqWoISwIr7cqlCBDZx3Xu0E3I=; h=DKIM-Signature:MIME-Version:From:To:Subject:Message-Id:Date; b=sJxaw+ng9DN1baSzt/rTN3Z8IEsYarzyYqtHvisMVQfFVY241hld9uU3M62KjvX29PzccXjbfXf4T31lQrI+djBfu9Q9X6ejIZOsCHHEpHp3VgR2ivKecrv6CmJjnh74Y4VXg+WUMbA5H0EOWfFe17NI2bQiQwyjZwVl+rrY/40= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EBFD938560AA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1697227677; bh=7GVYiaofw8xQsICt7vKaKyF2IMtmOFgUVN8/K5cS5DU=; h=From:To:Subject:Date:From; b=WhydPJbTjO5FNSo2FEHukJcoLIyIeYnqy3jNWuFnB4r/AhHdB2vNjoGSKZsaw+36B Po8G8lqEFoUysoTzQ+TKerjnZMIOrK2iSiJ+ETbo28maDq4AVLPsJ2sDJ/bwm/sSpq b/CO2Jv59wxGNi07reajnv406QerqYnASRCzuhqc= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Harald Anlauf To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-4631] fortran: fix handling of options -ffpe-trap and -ffpe-summary [PR110957] X-Act-Checkin: gcc X-Git-Author: Harald Anlauf X-Git-Refname: refs/heads/master X-Git-Oldrev: 8be20f3b0bded7f9b690b27cbee58b283dbe827b X-Git-Newrev: 458c253ccdae9df439b9a452d04e325101e5756e Message-Id: <20231013200757.EBFD938560AA@sourceware.org> Date: Fri, 13 Oct 2023 20:07:57 +0000 (GMT) List-Id: https://gcc.gnu.org/g:458c253ccdae9df439b9a452d04e325101e5756e commit r14-4631-g458c253ccdae9df439b9a452d04e325101e5756e Author: Harald Anlauf Date: Fri Oct 6 22:21:56 2023 +0200 fortran: fix handling of options -ffpe-trap and -ffpe-summary [PR110957] 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. Diff: --- gcc/fortran/invoke.texi | 6 ++++-- gcc/fortran/options.cc | 9 ++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/gcc/fortran/invoke.texi b/gcc/fortran/invoke.texi index 38150b1e29e..10387e39501 100644 --- a/gcc/fortran/invoke.texi +++ b/gcc/fortran/invoke.texi @@ -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 diff --git a/gcc/fortran/options.cc b/gcc/fortran/options.cc index 27311961325..2ad22478042 100644 --- a/gcc/fortran/options.cc +++ b/gcc/fortran/options.cc @@ -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);