diff options
author | Harald Anlauf <anlauf@gmx.de> | 2021-12-07 23:06:41 +0100 |
---|---|---|
committer | Harald Anlauf <anlauf@gmx.de> | 2021-12-08 19:34:57 +0100 |
commit | 5f7cdea34e118776d0ccd2ff3dda0f5acab18a94 (patch) | |
tree | c1c4e20bb830a588f1acac99944635df91bb5014 /gcc/fortran/array.c | |
parent | df704591a2cad3526456aa77be403d21c822724d (diff) | |
download | gcc-5f7cdea34e118776d0ccd2ff3dda0f5acab18a94.zip gcc-5f7cdea34e118776d0ccd2ff3dda0f5acab18a94.tar.gz gcc-5f7cdea34e118776d0ccd2ff3dda0f5acab18a94.tar.bz2 |
Fortran: dimensions of an array have to be non-negative
gcc/fortran/ChangeLog:
PR fortran/103610
* array.c (spec_dimen_size): Fix simplification of SHAPE:
dimensions must be non-negative.
gcc/testsuite/ChangeLog:
PR fortran/103610
* gfortran.dg/shape_11.f90: New test.
Diffstat (limited to 'gcc/fortran/array.c')
-rw-r--r-- | gcc/fortran/array.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/gcc/fortran/array.c b/gcc/fortran/array.c index e5e2209..e4891df 100644 --- a/gcc/fortran/array.c +++ b/gcc/fortran/array.c @@ -2296,8 +2296,7 @@ gfc_copy_iterator (gfc_iterator *src) /********* Subroutines for determining the size of an array *********/ /* These are needed just to accommodate RESHAPE(). There are no - diagnostics here, we just return a negative number if something - goes wrong. */ + diagnostics here, we just return false if something goes wrong. */ /* Get the size of single dimension of an array specification. The @@ -2330,6 +2329,9 @@ spec_dimen_size (gfc_array_spec *as, int dimen, mpz_t *result) mpz_add_ui (*result, *result, 1); + if (mpz_cmp_si (*result, 0) < 0) + mpz_set_si (*result, 0); + return true; } |