From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2071) id CEE3A385702C; Sun, 23 Oct 2022 20:17:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CEE3A385702C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666556268; bh=jtxlYgGc1cZzEU6Ls1j4i/SljOHX7ArQUcglt7dUKO8=; h=From:To:Subject:Date:From; b=yC6nqppQV8aTQXvkepbRX54ru3F0QFtka7BSdsgyz0LaicDYanfzWzw4sn/3/REyu UYR2qcDu+TVd8djuX2aAQICuqoyO2YzYSJHjdFfHCwrFY2i3BGztm8BHYguGF3VIwo tila/cndsaOUOMBaRB13Y+Msx/dNWMTmJaeVwW/Q= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Harald Anlauf To: gcc-cvs@gcc.gnu.org Subject: [gcc r10-11055] Fortran: error recovery with references of bad array constructors [PR105633] X-Act-Checkin: gcc X-Git-Author: Harald Anlauf X-Git-Refname: refs/heads/releases/gcc-10 X-Git-Oldrev: ee737e5611e7e7aa7997daef2cc6c327b599d213 X-Git-Newrev: 910156619c93ff988587762b446542c4dfbb00a2 Message-Id: <20221023201748.CEE3A385702C@sourceware.org> Date: Sun, 23 Oct 2022 20:17:48 +0000 (GMT) List-Id: https://gcc.gnu.org/g:910156619c93ff988587762b446542c4dfbb00a2 commit r10-11055-g910156619c93ff988587762b446542c4dfbb00a2 Author: Harald Anlauf Date: Wed Oct 19 22:37:56 2022 +0200 Fortran: error recovery with references of bad array constructors [PR105633] gcc/fortran/ChangeLog: PR fortran/105633 * expr.c (find_array_section): Move check for NULL pointers so that both subscript triplets and vector subscripts are covered. gcc/testsuite/ChangeLog: PR fortran/105633 * gfortran.dg/pr105633.f90: New test. Co-authored-by: Steven G. Kargl (cherry picked from commit ecb20df4fa6d99daa635c7fb662dc0554610777e) Diff: --- gcc/fortran/expr.c | 10 +++++++--- gcc/testsuite/gfortran.dg/pr105633.f90 | 8 ++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index 1129f5f3302..b65fc764fb8 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -1549,6 +1549,12 @@ find_array_section (gfc_expr *expr, gfc_ref *ref) lower = ref->u.ar.as->lower[d]; upper = ref->u.ar.as->upper[d]; + if (!lower || !upper) + { + t = false; + goto cleanup; + } + if (ref->u.ar.dimen_type[d] == DIMEN_VECTOR) /* Vector subscript. */ { gfc_constructor *ci; @@ -1591,9 +1597,7 @@ find_array_section (gfc_expr *expr, gfc_ref *ref) { if ((begin && begin->expr_type != EXPR_CONSTANT) || (finish && finish->expr_type != EXPR_CONSTANT) - || (step && step->expr_type != EXPR_CONSTANT) - || !lower - || !upper) + || (step && step->expr_type != EXPR_CONSTANT)) { t = false; goto cleanup; diff --git a/gcc/testsuite/gfortran.dg/pr105633.f90 b/gcc/testsuite/gfortran.dg/pr105633.f90 new file mode 100644 index 00000000000..f2dbc5e742a --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr105633.f90 @@ -0,0 +1,8 @@ +! { dg-do compile } +! PR fortran/105633 - ICE in find_array_section +! Contributed by G.Steinmetz + +program p + integer, parameter :: a(:) = [1,2] ! { dg-error "deferred shape" } + print *, [a([1,2])] +end