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 r12-1090] PR fortran/100656 - prevent ICE in gfc_conv_expr_present Date: Thu, 27 May 2021 11:55:52 +0000 (GMT) [thread overview] Message-ID: <20210527115552.4CBC93858025@sourceware.org> (raw) https://gcc.gnu.org/g:9d3a953ec4d2695e9a6bfa5f22655e2aea47a973 commit r12-1090-g9d3a953ec4d2695e9a6bfa5f22655e2aea47a973 Author: Harald Anlauf <anlauf@gmx.de> Date: Thu May 27 13:55:11 2021 +0200 PR fortran/100656 - prevent ICE in gfc_conv_expr_present gcc/fortran/ChangeLog: PR fortran/100656 * trans-array.c (gfc_conv_ss_startstride): Do not call check for presence of a dummy argument when a symbol actually refers to a non-dummy. gcc/testsuite/ChangeLog: PR fortran/100656 * gfortran.dg/bounds_check_22.f90: New test. Diff: --- gcc/fortran/trans-array.c | 5 +++-- gcc/testsuite/gfortran.dg/bounds_check_22.f90 | 12 ++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index 6d38ea78273..7eeef554c0f 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -4718,8 +4718,9 @@ done: /* For optional arguments, only check bounds if the argument is present. */ - if (expr->symtree->n.sym->attr.optional - || expr->symtree->n.sym->attr.not_always_present) + if ((expr->symtree->n.sym->attr.optional + || expr->symtree->n.sym->attr.not_always_present) + && expr->symtree->n.sym->attr.dummy) tmp = build3_v (COND_EXPR, gfc_conv_expr_present (expr->symtree->n.sym), tmp, build_empty_stmt (input_location)); diff --git a/gcc/testsuite/gfortran.dg/bounds_check_22.f90 b/gcc/testsuite/gfortran.dg/bounds_check_22.f90 new file mode 100644 index 00000000000..a84e3dd4f51 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/bounds_check_22.f90 @@ -0,0 +1,12 @@ +! { dg-do compile } +! { dg-options "-fcheck=bounds" } +! PR fortran/100656 - ICE in gfc_conv_expr_present + +subroutine s(x) + character(:), allocatable, optional :: x(:) + if ( present(x) ) then + if ( allocated(x) ) then + x = 'a' // x // 'e' + end if + end if +end
reply other threads:[~2021-05-27 11:55 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=20210527115552.4CBC93858025@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).