diff options
author | Harald Anlauf <anlauf@gmx.de> | 2022-07-14 22:24:55 +0200 |
---|---|---|
committer | Harald Anlauf <anlauf@gmx.de> | 2022-07-14 22:25:48 +0200 |
commit | 748f8a8b145dde59c7b63aa68b5a59515b7efc49 (patch) | |
tree | d50cf8be704c294081c3f19690ea96a98f84cbf9 /gcc/fortran/decl.cc | |
parent | b4f81085d1ef5776be30f95c102ec67daf03c35c (diff) | |
download | gcc-748f8a8b145dde59c7b63aa68b5a59515b7efc49.zip gcc-748f8a8b145dde59c7b63aa68b5a59515b7efc49.tar.gz gcc-748f8a8b145dde59c7b63aa68b5a59515b7efc49.tar.bz2 |
Fortran: error recovery for bad initializers of implied-shape arrays [PR106209]
gcc/fortran/ChangeLog:
PR fortran/106209
* decl.cc (add_init_expr_to_sym): Handle bad initializers for
implied-shape arrays.
gcc/testsuite/ChangeLog:
PR fortran/106209
* gfortran.dg/pr106209.f90: New test.
Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
Diffstat (limited to 'gcc/fortran/decl.cc')
-rw-r--r-- | gcc/fortran/decl.cc | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/gcc/fortran/decl.cc b/gcc/fortran/decl.cc index 339f8b1..b640051 100644 --- a/gcc/fortran/decl.cc +++ b/gcc/fortran/decl.cc @@ -2129,10 +2129,21 @@ add_init_expr_to_sym (const char *name, gfc_expr **initp, locus *var_locus) /* The shape may be NULL for EXPR_ARRAY, set it. */ if (init->shape == NULL) { - gcc_assert (init->expr_type == EXPR_ARRAY); + if (init->expr_type != EXPR_ARRAY) + { + gfc_error ("Bad shape of initializer at %L", &init->where); + return false; + } + init->shape = gfc_get_shape (1); if (!gfc_array_size (init, &init->shape[0])) - gfc_internal_error ("gfc_array_size failed"); + { + gfc_error ("Cannot determine shape of initializer at %L", + &init->where); + free (init->shape); + init->shape = NULL; + return false; + } } for (dim = 0; dim < sym->as->rank; ++dim) |