+2019-10-11 Steven G. Kargl <kargl@gcc.gnu.org>
+
+ PR fortran/92019
+ * array.c (match_subscript): BOZ cannot be an array subscript.
+
2019-10-11 Tobias Burnus <tobias@codesourcery.com>
PR fortran/92050
match m = MATCH_ERROR;
bool star = false;
int i;
+ bool saw_boz = false;
i = ar->dimen + ar->codimen;
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)
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;
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)
if (star)
ar->dimen_type[i] = DIMEN_STAR;
- return MATCH_YES;
+ return (saw_boz ? MATCH_ERROR : MATCH_YES);
}
+2019-10-11 Steven G. Kargl <kargl@gcc.gnu.org>
+
+ PR fortran/92019
+ * gfortran.dg/pr92019.f90: New test.
+
2019-10-11 Joseph Myers <joseph@codesourcery.com>
* gcc.dg/dfp/c11-keywords-1.c, gcc.dg/dfp/c11-keywords-2.c,
--- /dev/null
+! { 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