From: Mark Eggleston Date: Tue, 18 Feb 2020 14:15:41 +0000 (+0000) Subject: [Fortran] ICE: Invalid expression in gfc_element_size PR93601 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=23d3f25c87d307536f7e0f15e211968a87657602;p=gcc.git [Fortran] ICE: Invalid expression in gfc_element_size PR93601 ICE occurs when assigning a BOZ constant to an class(*) variable with the allocatable attribute. Use of BOZ constants outside data statements and int/real/dble/cmplx intrinsics is not allowed. Original patch provided by Steven G. Kargl . gcc/fortran/ChangeLog PR fortran/93601 * match.c (gfc_match_assignment) : Reject assignment if the lhs stype is BT_CLASS and the rhs type is BT_BOZ. gcc/testsuite/ChangeLog PR fortran/93601 * gfortran.dg/pr93601.f90 : New test. --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 2e874b83c64..5daaefdee9b 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2020-02-18 Steven G. Kargl + + PR fortran/93601 + * match.c (gfc_match_assignment) : Reject assignment if + the lhs stype is BT_CLASS and the rhs type is BT_BOZ. + 2020-02-18 Steven G. Kargl PR fortran/93603 diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index 9c2ec41c49c..e4d52245976 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -1348,6 +1348,16 @@ gfc_match_assignment (void) rvalue = NULL; m = gfc_match (" %e%t", &rvalue); + if (m == MATCH_YES + && rvalue->ts.type == BT_BOZ + && lvalue->ts.type == BT_CLASS) + { + m = MATCH_ERROR; + gfc_error ("BOZ literal constant at %L is neither a DATA statement " + "value nor an actual argument of INT/REAL/DBLE/CMPLX " + "intrinsic subprogram", &rvalue->where); + } + if (lvalue->expr_type == EXPR_CONSTANT) { /* This clobbers %len and %kind. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9f7a4f7a61d..6b008fde202 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-02-18 Mark Eggleston + + PR fortran/93601 + * gfortran.dg/pr93601.f90 : New test. + 2020-02-18 Martin Liska PR ipa/93583 diff --git a/gcc/testsuite/gfortran.dg/pr93601.f90 b/gcc/testsuite/gfortran.dg/pr93601.f90 new file mode 100644 index 00000000000..495447c637b --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr93601.f90 @@ -0,0 +1,7 @@ +! { dg-do compile } + +program p + class(*), allocatable :: z + z = z'1' ! { dg-error "BOZ literal constant at" } +end +