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 r9-9751] Fortran - improve error recovery determining array element from constructor Date: Thu, 30 Sep 2021 19:28:27 +0000 (GMT) [thread overview] Message-ID: <20210930192827.830B83857C42@sourceware.org> (raw) https://gcc.gnu.org/g:e3ad4c45d128c1f4a69f86116a36312aa593554c commit r9-9751-ge3ad4c45d128c1f4a69f86116a36312aa593554c Author: Harald Anlauf <anlauf@gmx.de> Date: Tue Sep 7 20:51:49 2021 +0200 Fortran - improve error recovery determining array element from constructor gcc/fortran/ChangeLog: PR fortran/101327 * expr.c (find_array_element): When bounds cannot be determined as constant, return error instead of aborting. gcc/testsuite/ChangeLog: PR fortran/101327 * gfortran.dg/pr101327.f90: New test. (cherry picked from commit 2a1537a19cb2fa85823cfa18ed40baa4b259b4e3) Diff: --- gcc/fortran/expr.c | 7 +++---- gcc/testsuite/gfortran.dg/pr101327.f90 | 11 +++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index 9627ad3b653..f099da98ab0 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -1330,7 +1330,9 @@ find_array_element (gfc_constructor_base base, gfc_array_ref *ar, for (i = 0; i < ar->dimen; i++) { if (!gfc_reduce_init_expr (ar->as->lower[i]) - || !gfc_reduce_init_expr (ar->as->upper[i])) + || !gfc_reduce_init_expr (ar->as->upper[i]) + || ar->as->upper[i]->expr_type != EXPR_CONSTANT + || ar->as->lower[i]->expr_type != EXPR_CONSTANT) { t = false; cons = NULL; @@ -1344,9 +1346,6 @@ find_array_element (gfc_constructor_base base, gfc_array_ref *ar, goto depart; } - gcc_assert (ar->as->upper[i]->expr_type == EXPR_CONSTANT - && ar->as->lower[i]->expr_type == EXPR_CONSTANT); - /* Check the bounds. */ if ((ar->as->upper[i] && mpz_cmp (e->value.integer, diff --git a/gcc/testsuite/gfortran.dg/pr101327.f90 b/gcc/testsuite/gfortran.dg/pr101327.f90 new file mode 100644 index 00000000000..f4377aabe7a --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr101327.f90 @@ -0,0 +1,11 @@ +! { dg-do compile } +! PR fortran/101327 - ICE in find_array_element, at fortran/expr.c:1355 + +subroutine s + integer, parameter :: n([2]) = [1, 2] ! { dg-error "must be scalar" } + type t + integer :: a(n(1):n(2)) + end type +end + +! { dg-error "cannot be automatic or of deferred shape" " " { target *-*-* } 5 }
reply other threads:[~2021-09-30 19:28 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=20210930192827.830B83857C42@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).