From: Fritz O. Reese Date: Wed, 9 Nov 2016 17:31:27 +0000 (+0000) Subject: Fix ICE in gfc_trans_subcomponent_assign due to NULL components. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f31adad4cbbb1ece12a84b698e5cbfeea756d4ce;p=gcc.git 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 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 615ade012f7..ab59584852c 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2016-11-09 Fritz O. Reese + + PR fortran/78259 + * trans-expr.c (gfc_trans_subcomponent_assign): Guard against NULL + values. + 2016-11-09 Steve Kargl Janus Weil diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index 61214295f66..48296b8dbdb 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -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)); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 749c7d6bef0..7def8a781cd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-11-09 Fritz O. Reese + + PR fortran/78259 + * gfortran.dg/pr78259.f90: New test. + 2016-11-09 Janus Weil PR fortran/60777 diff --git a/gcc/testsuite/gfortran.dg/pr78259.f90 b/gcc/testsuite/gfortran.dg/pr78259.f90 new file mode 100644 index 00000000000..82f48ea5f3e --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr78259.f90 @@ -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