public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-5705] Fortran: prevent redundant integer division truncation warnings [PR108592]
@ 2023-02-05 21:53 Harald Anlauf
0 siblings, 0 replies; only message in thread
From: Harald Anlauf @ 2023-02-05 21:53 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:d042f118798ae0648b45f97e63b0e5ab7c82c8ef
commit r13-5705-gd042f118798ae0648b45f97e63b0e5ab7c82c8ef
Author: Harald Anlauf <anlauf@gmx.de>
Date: Mon Jan 30 22:46:43 2023 +0100
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.
Diff:
---
gcc/fortran/arith.cc | 2 +-
gcc/testsuite/gfortran.dg/pr108592.f90 | 8 ++++++++
2 files changed, 9 insertions(+), 1 deletion(-)
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-02-05 21:53 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-05 21:53 [gcc r13-5705] Fortran: prevent redundant integer division truncation warnings [PR108592] Harald Anlauf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).