public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Harald Anlauf <anlauf@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-10501] Fortran: fix ICE in check_charlen_present [PR108420] Date: Sat, 4 Feb 2023 15:43:11 +0000 (GMT) [thread overview] Message-ID: <20230204154311.B4CB43858033@sourceware.org> (raw) 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
reply other threads:[~2023-02-04 15:43 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230204154311.B4CB43858033@sourceware.org \ --to=anlauf@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).