From c988c699fa09c91485afa24526f965e3fd4269d6 Mon Sep 17 00:00:00 2001 From: "Steven G. Kargl" Date: Fri, 11 Oct 2019 17:41:29 +0000 Subject: [PATCH] re PR fortran/92019 (ICE in find_inquiry_ref, at expr.c:1790) 2019-10-11 Steven G. Kargl PR fortran/92019 * array.c (match_subscript): BOZ cannot be an array subscript. 2019-10-11 Steven G. Kargl PR fortran/92019 * gfortran.dg/pr92019.f90: New test. From-SVN: r276897 --- gcc/fortran/ChangeLog | 5 +++++ gcc/fortran/array.c | 21 ++++++++++++++++++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/pr92019.f90 | 9 +++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/pr92019.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 5aeacc1781a..47b20614cd7 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2019-10-11 Steven G. Kargl + + PR fortran/92019 + * array.c (match_subscript): BOZ cannot be an array subscript. + 2019-10-11 Tobias Burnus PR fortran/92050 diff --git a/gcc/fortran/array.c b/gcc/fortran/array.c index 3a504ebfea8..cbeece44ecf 100644 --- a/gcc/fortran/array.c +++ b/gcc/fortran/array.c @@ -66,6 +66,7 @@ match_subscript (gfc_array_ref *ar, int init, bool match_star) match m = MATCH_ERROR; bool star = false; int i; + bool saw_boz = false; i = ar->dimen + ar->codimen; @@ -91,6 +92,12 @@ match_subscript (gfc_array_ref *ar, int init, bool match_star) else if (!star) m = gfc_match_expr (&ar->start[i]); + if (ar->start[i] && ar->start[i]->ts.type == BT_BOZ) + { + gfc_error ("Invalid BOZ literal constant used in subscript at %C"); + saw_boz = true; + } + if (m == MATCH_NO) gfc_error ("Expected array subscript at %C"); if (m != MATCH_YES) @@ -117,6 +124,12 @@ end_element: else m = gfc_match_expr (&ar->end[i]); + if (ar->end[i] && ar->end[i]->ts.type == BT_BOZ) + { + gfc_error ("Invalid BOZ literal constant used in subscript at %C"); + saw_boz = true; + } + if (m == MATCH_ERROR) return MATCH_ERROR; @@ -132,6 +145,12 @@ end_element: m = init ? gfc_match_init_expr (&ar->stride[i]) : gfc_match_expr (&ar->stride[i]); + if (ar->stride[i] && ar->stride[i]->ts.type == BT_BOZ) + { + gfc_error ("Invalid BOZ literal constant used in subscript at %C"); + saw_boz = true; + } + if (m == MATCH_NO) gfc_error ("Expected array subscript stride at %C"); if (m != MATCH_YES) @@ -142,7 +161,7 @@ matched: if (star) ar->dimen_type[i] = DIMEN_STAR; - return MATCH_YES; + return (saw_boz ? MATCH_ERROR : MATCH_YES); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2459275f333..6c6a077259f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-10-11 Steven G. Kargl + + PR fortran/92019 + * gfortran.dg/pr92019.f90: New test. + 2019-10-11 Joseph Myers * gcc.dg/dfp/c11-keywords-1.c, gcc.dg/dfp/c11-keywords-2.c, diff --git a/gcc/testsuite/gfortran.dg/pr92019.f90 b/gcc/testsuite/gfortran.dg/pr92019.f90 new file mode 100644 index 00000000000..488774ba82f --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr92019.f90 @@ -0,0 +1,9 @@ +! { dg-do compile } +! PR fortran/92019 +program foo + integer :: a(4) = [1, 2, 3, 4] + print *, a(z'1') ! { dg-error "Invalid BOZ literal constant" } + print *, a(1:z'3') ! { dg-error "Invalid BOZ literal constant" } + print *, a(1:2:z'2') ! { dg-error "Invalid BOZ literal constant" } + print *, a([z'2',z'1']) ! { dg-error "cannot appear in an array constructor" } +end program foo -- 2.30.2