Fix ICE in gfc_trans_subcomponent_assign due to NULL components.

PR fortran/78259
	* gcc/fortran/trans-expr.c (gfc_trans_subcomponent_assign): Guard
	against NULL values.

	PR fortran/78259
	* gcc/testsuite/gfortran.dg/pr78259.f90: New test.

From-SVN: r242010
This commit is contained in:
Fritz O. Reese 2016-11-09 17:31:27 +00:00 committed by Fritz Reese
parent b349a81aa0
commit f31adad4cb
4 changed files with 35 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2016-11-09 Fritz O. Reese <fritzoreese@gmail.com>
PR fortran/78259
* trans-expr.c (gfc_trans_subcomponent_assign): Guard against NULL
values.
2016-11-09 Steve Kargl <kargl@gcc.gnu.org>
Janus Weil <janus@gcc.gnu.org>

View File

@ -7327,7 +7327,8 @@ gfc_trans_subcomponent_assign (tree dest, gfc_component * cm, gfc_expr * expr,
gfc_constructor *c = gfc_constructor_first (expr->value.constructor);
/* We mark that the entire union should be initialized with a contrived
EXPR_NULL expression at the beginning. */
if (c->n.component == NULL && c->expr->expr_type == EXPR_NULL)
if (c != NULL && c->n.component == NULL
&& c->expr != NULL && c->expr->expr_type == EXPR_NULL)
{
tmp = build2_loc (input_location, MODIFY_EXPR, void_type_node,
dest, build_constructor (TREE_TYPE (dest), NULL));

View File

@ -1,3 +1,8 @@
2016-11-09 Fritz O. Reese <fritzoreese@gmail.com>
PR fortran/78259
* gfortran.dg/pr78259.f90: New test.
2016-11-09 Janus Weil <janus@gcc.gnu.org>
PR fortran/60777

View File

@ -0,0 +1,22 @@
! { dg-do "compile" }
! { dg-options "-fdec-structure" }
!
! PR fortran/78259
!
! ICE in gfc_trans_subcomponent_assign
!
subroutine sub
structure /s/
union
map
integer n(2)
end map
map
integer(8) m /2/
end map
end union
end structure
record /s/ r
r.n(1) = 1
end