From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by sourceware.org (Postfix) with ESMTPS id 50CCA3858C5F; Mon, 30 Jan 2023 21:55:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 50CCA3858C5F 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=1675115731; bh=Oh4hQy1B+TH1M+9gWBeb9vsgdcE+L2NF9H+ijXk7WOU=; h=X-UI-Sender-Class:From:To:Subject:Date; b=neAB1e0pkKQ6bIWmCZGm56ke/F0NYOg6iEFmLNH12ybynZZVdRoOF4ykMKlRz9xAG dK1xHY7cgsxqYpMO+OCj6mXmWjK6eWqvTiqhayRWC0LSCVHM2aKgUowCT66Ntqc7S6 8MT2S1kKe3e/4Z72CnqfQcqGxW21QAhw7xOGpg0+oYMeRK7ehQasQFwkezhItW0jc9 SsK1rfdJSTWOdv25HnytHOEWI7eij2cE9UOY/kFu2SYKVm5wwYSgiHOagQHGi/D21A 6vkgNMQ69Sa7N7zUQT/rqeoOs1jmGihuz037kZNnQgA36Yw0CYLClGjB0xP2Cic6bk /ZJI2KIAZz42Q== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [93.207.90.196] ([93.207.90.196]) by web-mail.gmx.net (3c-app-gmx-bap49.server.lan [172.19.172.119]) (via HTTP); Mon, 30 Jan 2023 22:55:31 +0100 MIME-Version: 1.0 Message-ID: From: Harald Anlauf To: fortran , gcc-patches Subject: [PATCH] Fortran: prevent redundant integer division truncation warnings [PR108592] Content-Type: multipart/mixed; boundary=abmob-26b29396-6c98-4645-93c3-725eac487121 Date: Mon, 30 Jan 2023 22:55:31 +0100 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:S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ti3IIAgQn8t2zAcvDg0QOoevt ovqS+7+59IgLZQ8KIBGfo3wiu4nF9QnzE6g2yrt6MLxmGeJtgHVqqZ5Eq+OuV2C257NQihSXg t3xJTReBf2rbNST7uLu1PlFQ== X-Spam-Status: No, score=-11.0 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_H2,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 List-Id: --abmob-26b29396-6c98-4645-93c3-725eac487121 Content-Type: text/plain; charset=UTF-8 Dear Fortranners, the subject says it all: in some cases we emit redundant integer division truncation warnings (2 or 4), where just one would have been sufficient. This is solved by using gfc_warning instead of gfc_warning_now. The testcase uses a suggestion by Andrew to verify that we get the desired warning exactly once. Regtested on x86_64-pc-linux-gnu. OK for mainline? Thanks, Harald --abmob-26b29396-6c98-4645-93c3-725eac487121 Content-Type: text/x-patch Content-Disposition: attachment; filename=pr108592.diff Content-Transfer-Encoding: quoted-printable =46rom 8340523c8df8edd008174d44e87c0fa54b58b2c7 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Mon, 30 Jan 2023 22:46:43 +0100 Subject: [PATCH] Fortran: prevent redundant integer division truncation warnings [PR108592] gcc/fortran/ChangeLog: PR fortran/108592 * arith.cc (gfc_arith_divide): Emit integer division truncation warnings using gfc_warning instead of gfc_warning_now to prevent redundant messages. gcc/testsuite/ChangeLog: PR fortran/108592 * gfortran.dg/pr108592.f90: New test. =2D-- gcc/fortran/arith.cc | 2 +- gcc/testsuite/gfortran.dg/pr108592.f90 | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/pr108592.f90 diff --git a/gcc/fortran/arith.cc b/gcc/fortran/arith.cc index 6de6d21c73d..d0d1c0b03d2 100644 =2D-- a/gcc/fortran/arith.cc +++ b/gcc/fortran/arith.cc @@ -778,7 +778,7 @@ gfc_arith_divide (gfc_expr *op1, gfc_expr *op2, gfc_ex= pr **resultp) { char *p; p =3D mpz_get_str (NULL, 10, result->value.integer); - gfc_warning_now (OPT_Winteger_division, "Integer division " + gfc_warning (OPT_Winteger_division, "Integer division " "truncated to constant %qs at %L", p, &op1->where); free (p); diff --git a/gcc/testsuite/gfortran.dg/pr108592.f90 b/gcc/testsuite/gfortr= an.dg/pr108592.f90 new file mode 100644 index 00000000000..224b1d8d1fc =2D-- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr108592.f90 @@ -0,0 +1,8 @@ +! { dg-do compile } +! { dg-options "-Winteger-division" } +! PR fortran/108592 - warn only once for truncation of integer division + +program foo + if (8 < (20/9)) stop 1 ! { dg-bogus "Integer division.*Integer division= " } +! { dg-message "Integer division truncated" "" { target *-*-* } .-1 } +end program =2D- 2.35.3 --abmob-26b29396-6c98-4645-93c3-725eac487121--