From patchwork Mon Jan 30 21:55:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 50521 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2414378wrn; Mon, 30 Jan 2023 13:56:26 -0800 (PST) X-Google-Smtp-Source: AMrXdXsRHKYKNrEkU2nIVVm3J40NNeFlJLwV08EsfI/ypOLfxfPOnqFetqeNuyjVGeMMqP3+GHQz X-Received: by 2002:a17:906:7748:b0:7c0:e30a:d3e5 with SMTP id o8-20020a170906774800b007c0e30ad3e5mr48512009ejn.18.1675115786525; Mon, 30 Jan 2023 13:56:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675115786; cv=none; d=google.com; s=arc-20160816; b=B77fE48FLfJ7pMhafel79N8GE/aoL13seSpfaqoOYqrj0ftCKb3WBBgwjE3p8P+Ibh J7swNC5JPQe8aamQPy8rgCsJsTA18eLe+3/zsoV9ArnysFG0u5yWw2G4Ds4wylmp1kVK CKoSHwZRBjqOKYM99R3JrprpoAuLKDlbXkJsVB+EWSMioFCCqSIiemJZcmBXV9jOnXPB LWQqqxDE4jQoAO0itoaF4ARWbStjEKE9XiLhCrkgVBeEHNbU7RBRPZ983ChBdfGoHgSv CVhrDxcFdeuPp9J9yeAzn+Nj6YFAvip2P5xIr/Lq0PT8S4faV8qoxgEdZh8oPfXgdNRn RqvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:ui-outboundreport :sensitivity:importance:date:subject:to:message-id:mime-version :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=SBmLR8VVhZNXWF4dJIpN1P1GvQA5hlo7n3ZOMtGsBg8=; b=KRr0Nj12XLkMn6cBo/KXD/9jKD+rNn/Nt1w3BZAzWJF+AU68Qt+7P1c/R9QU16GrfC k67Bhnr/5mmCGi0sxOcOH+oRKU8ybXsQPB5t4VnSbjIChnmet91qfolLgtYPMpdCLFkh 5SPms8VEIXwChN0bmzLG1VCb1EBOu9OgBtqgzRJyFpmoxTQDBJ/HqpRW6E9AiQWyc8RZ MSEwQVpvmHO4MdfR3iUa+1YoU4/4rcv0faD6e2C/F1HP2EER7HBnbq0pC6L8j2iG5sYY Vgp/5qymhay4XP+1joNrX52QskG2VRjEOZO4PJ7hLwRgz6flXTvRIwek6C5fBo5jRMpe T4YQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=A0SZkyzH; 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=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id f8-20020a1709063f4800b0087329ff5952si17445564ejj.219.2023.01.30.13.56.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 13:56:26 -0800 (PST) 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=@gcc.gnu.org header.s=default header.b=A0SZkyzH; 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=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 484B53858D32 for ; Mon, 30 Jan 2023 21:56:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 484B53858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675115776; bh=SBmLR8VVhZNXWF4dJIpN1P1GvQA5hlo7n3ZOMtGsBg8=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=A0SZkyzHZiQ5btl2CxTHmFrPCyZNL9lMdEup/UPPFqY2oBtXSSLviEKFeWFOzalXh GExxZ/L2IWBnqZBx0u3cdhXK9tZoRWM30Eza7dt2F7uFpGGf8wtmXaUpXfYkzNyekH sDKCTA+X6LyKf3iKI4mc4De46HAQsEN7ionIQyyw= 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.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 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: To: fortran , gcc-patches Subject: [PATCH] Fortran: prevent redundant integer division truncation warnings [PR108592] Date: Mon, 30 Jan 2023 22:55:31 +0100 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:SiQSRHLJgThqdqEP74FS6aPDUvElc/e9FwAfY2mqHYm68PH7vE9RiVNMNnltre6YJflej yh9t7dfZi5lyLGsiEDjmtZUh4+iAc3+SBNxaK/upv3i5MwCwgg5UPFPeAaZxn0Op5PWPbZYv9QQi 9uRxeC+7OJFI1jDy5A8Sv6mAQ766CqO+xNUhSh2kWo330fcWUTZV3vANgibj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ID_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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Harald Anlauf via Gcc-patches From: Harald Anlauf Reply-To: Harald Anlauf Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756486210914411808?= X-GMAIL-MSGID: =?utf-8?q?1756486210914411808?= 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 From 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. --- 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 --- a/gcc/fortran/arith.cc +++ b/gcc/fortran/arith.cc @@ -778,7 +778,7 @@ gfc_arith_divide (gfc_expr *op1, gfc_expr *op2, gfc_expr **resultp) { char *p; p = 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/gfortran.dg/pr108592.f90 new file mode 100644 index 00000000000..224b1d8d1fc --- /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 -- 2.35.3