aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/iresolve.cc
diff options
context:
space:
mode:
authorHarald Anlauf <anlauf@gmx.de>2023-01-16 21:41:09 +0100
committerHarald Anlauf <anlauf@gmx.de>2023-01-23 20:14:58 +0100
commite6669c0a50ed8aee9e5997d61e6271668d149218 (patch)
tree9003645d3ebca1cb341135b56b981df96cb5ff37 /gcc/fortran/iresolve.cc
parent4b125d01a5d5e601961419396332b74eea2219bb (diff)
downloadgcc-e6669c0a50ed8aee9e5997d61e6271668d149218.zip
gcc-e6669c0a50ed8aee9e5997d61e6271668d149218.tar.gz
gcc-e6669c0a50ed8aee9e5997d61e6271668d149218.tar.bz2
Fortran: fix ICE in check_charlen_present [PR108420]
gcc/fortran/ChangeLog: PR fortran/108420 * iresolve.cc (check_charlen_present): Preserve character length if there is no array constructor. gcc/testsuite/ChangeLog: PR fortran/108420 * gfortran.dg/pr108420.f90: New test.
Diffstat (limited to 'gcc/fortran/iresolve.cc')
-rw-r--r--gcc/fortran/iresolve.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/gcc/fortran/iresolve.cc b/gcc/fortran/iresolve.cc
index 711e917..33794f0 100644
--- a/gcc/fortran/iresolve.cc
+++ b/gcc/fortran/iresolve.cc
@@ -94,9 +94,12 @@ check_charlen_present (gfc_expr *source)
else if (source->expr_type == EXPR_ARRAY)
{
gfc_constructor *c = gfc_constructor_first (source->value.constructor);
- source->ts.u.cl->length
- = gfc_get_int_expr (gfc_charlen_int_kind, NULL,
- c->expr->value.character.length);
+ if (c)
+ source->ts.u.cl->length
+ = gfc_get_int_expr (gfc_charlen_int_kind, NULL,
+ c->expr->value.character.length);
+ if (source->ts.u.cl->length == NULL)
+ gfc_internal_error ("check_charlen_present(): length not set");
}
}