aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/expr.cc
diff options
context:
space:
mode:
authorHarald Anlauf <anlauf@gmx.de>2022-02-10 21:22:48 +0100
committerHarald Anlauf <anlauf@gmx.de>2022-02-14 20:31:14 +0100
commit19b517dff37b8e25f6babf8883483be73cad8fb3 (patch)
tree53aff7107a574ac64a34a2079e5a03d42a83948d /gcc/fortran/expr.cc
parent3d50dede07de0923f0f320d385162e546445e640 (diff)
downloadgcc-19b517dff37b8e25f6babf8883483be73cad8fb3.zip
gcc-19b517dff37b8e25f6babf8883483be73cad8fb3.tar.gz
gcc-19b517dff37b8e25f6babf8883483be73cad8fb3.tar.bz2
Fortran: improve error recovery on bad array section
gcc/fortran/ChangeLog: PR fortran/104211 * expr.cc (find_array_section): Replace assertion by error recovery when encountering bad array constructor. gcc/testsuite/ChangeLog: PR fortran/104211 * gfortran.dg/pr104211.f90: New test.
Diffstat (limited to 'gcc/fortran/expr.cc')
-rw-r--r--gcc/fortran/expr.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/gcc/fortran/expr.cc b/gcc/fortran/expr.cc
index ed82a94..c9c0ba4 100644
--- a/gcc/fortran/expr.cc
+++ b/gcc/fortran/expr.cc
@@ -1718,7 +1718,13 @@ find_array_section (gfc_expr *expr, gfc_ref *ref)
}
cons = gfc_constructor_lookup (base, limit);
- gcc_assert (cons);
+ if (cons == NULL)
+ {
+ gfc_error ("Error in array constructor referenced at %L",
+ &ref->u.ar.where);
+ t = false;
+ goto cleanup;
+ }
gfc_constructor_append_expr (&expr->value.constructor,
gfc_copy_expr (cons->expr), NULL);
}