public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-10501] Fortran: fix ICE in check_charlen_present [PR108420]
@ 2023-02-04 15:43 Harald Anlauf
0 siblings, 0 replies; only message in thread
From: Harald Anlauf @ 2023-02-04 15:43 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:c3985fd624053502b0aad85132982b4f8970811a
commit r11-10501-gc3985fd624053502b0aad85132982b4f8970811a
Author: Harald Anlauf <anlauf@gmx.de>
Date: Mon Jan 16 21:41:09 2023 +0100
Fortran: fix ICE in check_charlen_present [PR108420]
gcc/fortran/ChangeLog:
PR fortran/108420
* iresolve.c (check_charlen_present): Preserve character length if
there is no array constructor.
gcc/testsuite/ChangeLog:
PR fortran/108420
* gfortran.dg/pr108420.f90: New test.
(cherry picked from commit e6669c0a50ed8aee9e5997d61e6271668d149218)
Diff:
---
gcc/fortran/iresolve.c | 9 ++++++---
gcc/testsuite/gfortran.dg/pr108420.f90 | 10 ++++++++++
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/gcc/fortran/iresolve.c b/gcc/fortran/iresolve.c
index 598c0409b66..03db23b5b45 100644
--- a/gcc/fortran/iresolve.c
+++ b/gcc/fortran/iresolve.c
@@ -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");
}
}
diff --git a/gcc/testsuite/gfortran.dg/pr108420.f90 b/gcc/testsuite/gfortran.dg/pr108420.f90
new file mode 100644
index 00000000000..985c0b3bf53
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr108420.f90
@@ -0,0 +1,10 @@
+! { dg-do compile }
+! PR fortran/108420
+! Contributed by G.Steinmetz
+
+program p
+ character :: c = 'c'
+ logical :: m = .true.
+ print *, merge(transfer('a', 'b', 0), c, .true.)
+ print *, merge(transfer('a', 'b', 0), c, m)
+end
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-02-04 15:43 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-04 15:43 [gcc r11-10501] Fortran: fix ICE in check_charlen_present [PR108420] Harald Anlauf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).