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 r10-10351] Fortran: catch failed simplification of bad stride expression Date: Sun, 19 Dec 2021 20:29:09 +0000 (GMT) [thread overview] Message-ID: <20211219202909.DB2EA3858412@sourceware.org> (raw) https://gcc.gnu.org/g:650ac4b25121e48a64a021b0d21738ea08be3511 commit r10-10351-g650ac4b25121e48a64a021b0d21738ea08be3511 Author: Harald Anlauf <anlauf@gmx.de> Date: Tue Dec 7 18:46:52 2021 +0100 Fortran: catch failed simplification of bad stride expression gcc/fortran/ChangeLog: PR fortran/103588 * array.c (gfc_ref_dimen_size): Do not generate internal error on failed simplification of stride expression; just return failure. gcc/testsuite/ChangeLog: PR fortran/103588 * gfortran.dg/pr103588.f90: New test. (cherry picked from commit 652c28736209f10bac1aa7ecb31f9056b518dacf) Diff: --- gcc/fortran/array.c | 9 ++++----- gcc/testsuite/gfortran.dg/pr103588.f90 | 8 ++++++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/gcc/fortran/array.c b/gcc/fortran/array.c index 5f3aec78711..edf5cef61ec 100644 --- a/gcc/fortran/array.c +++ b/gcc/fortran/array.c @@ -2405,12 +2405,11 @@ gfc_ref_dimen_size (gfc_array_ref *ar, int dimen, mpz_t *result, mpz_t *end) { stride_expr = gfc_copy_expr(ar->stride[dimen]); - if(!gfc_simplify_expr(stride_expr, 1)) - gfc_internal_error("Simplification error"); - - if (stride_expr->expr_type != EXPR_CONSTANT - || mpz_cmp_ui (stride_expr->value.integer, 0) == 0) + if (!gfc_simplify_expr (stride_expr, 1) + || stride_expr->expr_type != EXPR_CONSTANT + || mpz_cmp_ui (stride_expr->value.integer, 0) == 0) { + gfc_free_expr (stride_expr); mpz_clear (stride); return false; } diff --git a/gcc/testsuite/gfortran.dg/pr103588.f90 b/gcc/testsuite/gfortran.dg/pr103588.f90 new file mode 100644 index 00000000000..198e1766cd2 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr103588.f90 @@ -0,0 +1,8 @@ +! { dg-do compile } +! PR fortran/103588 - ICE: Simplification error in gfc_ref_dimen_size +! Contributed by G.Steinmetz + +program p + integer, parameter :: a(:) = [1,2] ! { dg-error "cannot be automatic or of deferred shape" } + integer :: b(2) = a(::a(1)) ! { dg-error "Invalid" } +end
reply other threads:[~2021-12-19 20:29 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=20211219202909.DB2EA3858412@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).