* [PATCH] PR fortran/85796 - Floating point exception with implied do
@ 2020-11-23 21:18 Harald Anlauf
2020-11-25 11:41 ` Tobias Burnus
0 siblings, 1 reply; 2+ messages in thread
From: Harald Anlauf @ 2020-11-23 21:18 UTC (permalink / raw)
To: fortran, gcc-patches; +Cc: Jerry DeLisle
[-- Attachment #1: Type: text/plain, Size: 628 bytes --]
The patch below is based on a previous version by Steve.
The present version fixes an additional copy&paste error.
Needless to say that it (still!) regtests cleanly on x86_64-pc-linux-gnu.
OK for master? As it appears safe, OK for backport to at least 10-branch?
Thanks,
Harald
PR fortran/85796 - Floating point exception with implied do
Catch invalid step=0 in implied do loop within data statements.
gcc/fortran/ChangeLog:
PR fortran/85796
* resolve.c (traverse_data_list): Fix copy&paste errors; catch
step=0 in implied do loop.
gcc/testsuite/ChangeLog:
PR fortran/85796
* gfortran.dg/pr85796.f90: New test.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: pr85796.patch --]
[-- Type: text/x-patch, Size: 1521 bytes --]
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 1641eb6ca10..b6d21ad1bac 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -16327,7 +16327,7 @@ traverse_data_list (gfc_data_variable *var, locus *where)
|| end->expr_type != EXPR_CONSTANT)
{
gfc_error ("end of implied-do loop at %L could not be "
- "simplified to a constant value", &start->where);
+ "simplified to a constant value", &end->where);
retval = false;
goto cleanup;
}
@@ -16335,7 +16335,14 @@ traverse_data_list (gfc_data_variable *var, locus *where)
|| step->expr_type != EXPR_CONSTANT)
{
gfc_error ("step of implied-do loop at %L could not be "
- "simplified to a constant value", &start->where);
+ "simplified to a constant value", &step->where);
+ retval = false;
+ goto cleanup;
+ }
+ if (mpz_cmp_si (step->value.integer, 0) == 0)
+ {
+ gfc_error ("step of implied-do loop at %L shall not be zero",
+ &step->where);
retval = false;
goto cleanup;
}
diff --git a/gcc/testsuite/gfortran.dg/pr85796.f90 b/gcc/testsuite/gfortran.dg/pr85796.f90
new file mode 100644
index 00000000000..78683787fbb
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr85796.f90
@@ -0,0 +1,8 @@
+! { dg-do compile }
+! PR fortran/85796 - Floating point exception with implied do in data statement
+
+program p
+ implicit none
+ integer :: i, j, x(2,2)
+ data ((x(i,j),i=1,2,j-1),j=1,2) /3*789/ ! { dg-error "step of implied-do loop" }
+end
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] PR fortran/85796 - Floating point exception with implied do
2020-11-23 21:18 [PATCH] PR fortran/85796 - Floating point exception with implied do Harald Anlauf
@ 2020-11-25 11:41 ` Tobias Burnus
0 siblings, 0 replies; 2+ messages in thread
From: Tobias Burnus @ 2020-11-25 11:41 UTC (permalink / raw)
To: Harald Anlauf, fortran, gcc-patches; +Cc: Jerry DeLisle
On 23.11.20 22:18, Harald Anlauf wrote:
> The patch below is based on a previous version by Steve.
> The present version fixes an additional copy&paste error.
>
> Needless to say that it (still!) regtests cleanly on x86_64-pc-linux-gnu.
>
> OK for master? As it appears safe, OK for backport to at least 10-branch?
LGTM. Thanks for the patch; I think we can backport it to GCC 10.
Tobias
PS: Sorry for the slow patch review
> PR fortran/85796 - Floating point exception with implied do
>
> Catch invalid step=0 in implied do loop within data statements.
>
> gcc/fortran/ChangeLog:
>
> PR fortran/85796
> * resolve.c (traverse_data_list): Fix copy&paste errors; catch
> step=0 in implied do loop.
>
> gcc/testsuite/ChangeLog:
>
> PR fortran/85796
> * gfortran.dg/pr85796.f90: New test.
>
-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-11-25 11:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-23 21:18 [PATCH] PR fortran/85796 - Floating point exception with implied do Harald Anlauf
2020-11-25 11:41 ` Tobias Burnus
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).