Commit 23d3f25c by Mark Eggleston

[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  <kargl@gcc.gnu.org>.

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.
parent 08afe87b
2020-02-18 Steven G. Kargl <kargl@gcc.gnu.org>
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 <kargl@gcc.gnu.org>
PR fortran/93603
* match.c (gfc_match_associate) : If target expression
has the type BT_BOZ output an error and goto
......
......@@ -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. */
......
2020-02-18 Mark Eggleston <mark.eggleston@codethink.com>
PR fortran/93601
* gfortran.dg/pr93601.f90 : New test.
2020-02-18 Martin Liska <mliska@suse.cz>
PR ipa/93583
......
! { dg-do compile }
program p
class(*), allocatable :: z
z = z'1' ! { dg-error "BOZ literal constant at" }
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment