diff options
author | Harald Anlauf <anlauf@gmx.de> | 2020-11-25 20:20:44 +0100 |
---|---|---|
committer | Harald Anlauf <anlauf@gmx.de> | 2020-11-25 20:20:44 +0100 |
commit | 94172dc7091a2c6b2d2f99857de77c607fac3935 (patch) | |
tree | ef16798307cc1e140a5e68a5fbda91a39c7d854c /gcc/fortran/resolve.c | |
parent | 1049e5408fa343b5bf0a6380212a8ec8dfe2b6fc (diff) | |
download | gcc-94172dc7091a2c6b2d2f99857de77c607fac3935.zip gcc-94172dc7091a2c6b2d2f99857de77c607fac3935.tar.gz gcc-94172dc7091a2c6b2d2f99857de77c607fac3935.tar.bz2 |
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.
Diffstat (limited to 'gcc/fortran/resolve.c')
-rw-r--r-- | gcc/fortran/resolve.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 1641eb6..b6d21ad 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; } |