From patchwork Fri Oct 6 20:38:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 149435 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp623330vqo; Fri, 6 Oct 2023 15:13:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFOgVHsByAXXqnQ6FeeWJHnO4toQHUvseFLKLnH5EARrURF67hFbC70oDMu1UC0xXjSeCbs X-Received: by 2002:a5d:6703:0:b0:31f:a16a:aecd with SMTP id o3-20020a5d6703000000b0031fa16aaecdmr7840819wru.68.1696630413141; Fri, 06 Oct 2023 15:13:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696630413; cv=none; d=google.com; s=arc-20160816; b=rtXsJGjM6h4bF3gL6Z7xIf3yo6LYp1+D+s51O2wnxJFABPb0cLGEIasQYRY3/GDhXZ KL84rGrG5DJ0cYwwPg9Xw48p1N0Ag+eNFvAqlEbjVhbAhJQHpBY9EDEegIbT/M+QHCQ5 Uj28NMa+EhZzpEBJ/HfhI+0dkCUqX7ZZYla4t8oK2zIjPb72skE4Z/OtNCY3fT0dDckr 9VFwkfy3WoN3g/q9dn+q7ehWJ2NAhZzBva4YxSxuG0kuX2tiTwy6nlKeiOyz/PHxkBhM nz/1FI1glaYnG6Tig9A3EFZSxF+VL6galdyM02ODmSWIOvHtEAFkqw7iZJXoHEyZut28 jSnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:ui-outboundreport:sensitivity :importance:date:subject:to:from:message-id:mime-version :dkim-signature:dmarc-filter:delivered-to; bh=udq7grbBhLBlmO5G3tOZY8u3+dR3d2S7J9mfYJPlAsk=; fh=+IEfvAe+9BRgPHWhQEl2uIBTtAiiGDh1ExRZeB5JJoc=; b=wVeHhQG5LdUEsIsYXXy0sUZTBFxDfwl2+NJPYwiM4NWCaTqnaIcHL/FgOUmr6oNO30 /UGDXJWWgDJ/j4oia+4uVGJesAVYywbe0f9WsScyuWsCpAE2sU5vSk7rWpNvl5VTiY94 RNl1bX+OqAJHZ8aU3NZ+bzrk32uOYJurBOPxeBusS58I7ox9YtvXlo0fb80jDW1mijOG 9Yd35g9CFTpx6VErp5HVAuE8H02dNn7O7vHmkuAioGgyerft0+7wi5IxjAHUbIh7IfHq MVY4olNdJMQ5iDli7W81Oos03wdWcDrp65p/qkxybM6EGGpHwRfBiK6neI642Z1deKHL MVuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b="bTJqp/2u"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id l16-20020a056402125000b0053807797172si1981466edw.333.2023.10.06.15.13.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 15:13:33 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b="bTJqp/2u"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E0881385C6F6 for ; Fri, 6 Oct 2023 20:38:32 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by sourceware.org (Postfix) with ESMTPS id 5F6273858426; Fri, 6 Oct 2023 20:38:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5F6273858426 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmx.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1696624686; x=1697229486; i=anlauf@gmx.de; bh=SJm/3WCtHi4VA57ONx9E9OYQd34GIs/lXnQpuPNh8vI=; h=X-UI-Sender-Class:From:To:Subject:Date; b=bTJqp/2uL2Tn84KNBdN5GXyagFs+y7rshmdRLyTxgygXM0a08wOoaRrH2HdYBSw5VoRrzNA4eGS bg7kjBB5l5xOmy4+NCjSM5jogbcdktfJpGP/uO8PuZkiLk/UVmT4j/dNTt5KUOqGyjy10ClFBKcEf At8jgB6f+n+WwF+aIhghXsZehl/aBq/TTtZgFDMMFKKloSV0FODUKEx5NlWrk3mVPDL1aUiCbouKD iXoh1cxf+TOXC9IRv4mUVTO7cPJocfnPlwVFrr17tKCHMJXr0k8HbHR65wSdnXdiQyByOPtCwnhm0 ySxpGQGBHGQSJveylLO9YVv+gldMKmPyfV7A== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [79.232.147.245] ([79.232.147.245]) by web-mail.gmx.net (3c-app-gmx-bap40.server.lan [172.19.172.110]) (via HTTP); Fri, 6 Oct 2023 22:38:06 +0200 MIME-Version: 1.0 Message-ID: From: Harald Anlauf To: fortran , gcc-patches Subject: [PATCH] fortran: fix handling of options -ffpe-trap and -ffpe-summary [PR110957] Date: Fri, 6 Oct 2023 22:38:06 +0200 Importance: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aIAnkl7WyjWQusl5RQ2S56Gk1E2C0S+xyTdM/1YqS3YqZoCgvvH4eevxNqIYbAitU Vbt0aX+m25RkeCY9y1K1m747X2UAL8P8BUS8XHDW2e5lctwdMiSfp0116qsFsovax7uohZhF6 nXcKjQScPba5I/dF4d8esQTZ9BmoX3V7GT2kdx37uYF5k= X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779045931857968633 X-GMAIL-MSGID: 1779045931857968633 Dear all, the attached simple patch fixes a mixup of error messages for -ffpe-trap and -ffpe-summary. While at it, I though it might be useful to accept 'none' as allowable argument to -ffpe-trap, so that traps previously set on the command line may be cleared. This change is also documented. Regtested on x86_64-pc-linux-gnu. OK for mainline? *** The reporter also suggested to detect and handle -fno-trapping-math when any trap is enabled. I am not so sure that this can be required. In gfortran, specifying -ffpe-trap sets the FPU mask in the main and has no further effect. Or am I missing something? Any further opinions or insights? Thanks, Harald From 75dc455f21cea07e64b422c9994ab8879df388de Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Fri, 6 Oct 2023 22:21:56 +0200 Subject: [PATCH] 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. --- 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); -- 2.35.3