aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-expr.c
diff options
context:
space:
mode:
authorAndre Vehreschild <vehre@gcc.gnu.org>2016-07-15 11:28:47 +0200
committerAndre Vehreschild <vehre@gcc.gnu.org>2016-07-15 11:28:47 +0200
commit29eb509ccb9acd5aac604e6796e376bc09c4626d (patch)
treecb05c4e1d65c3529218ea419f580af1e8a5238b9 /gcc/fortran/trans-expr.c
parent43aabfcfd4139e4c9e7b868199e09b97e66010bc (diff)
downloadgcc-29eb509ccb9acd5aac604e6796e376bc09c4626d.zip
gcc-29eb509ccb9acd5aac604e6796e376bc09c4626d.tar.gz
gcc-29eb509ccb9acd5aac604e6796e376bc09c4626d.tar.bz2
re PR fortran/71807 (Internal compiler error with NULL() reference in structure constructor)
gcc/fortran/ChangeLog: 2016-07-15 Andre Vehreschild <vehre@gcc.gnu.org> PR fortran/71807 * trans-expr.c (gfc_trans_subcomponent_assign): Special casing when allocatable component is set to null() in initializer. gcc/testsuite/ChangeLog: 2016-07-15 Andre Vehreschild <vehre@gcc.gnu.org> PR fortran/71807 * gfortran.dg/null_9.f90: New test. From-SVN: r238368
Diffstat (limited to 'gcc/fortran/trans-expr.c')
-rw-r--r--gcc/fortran/trans-expr.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 4321850..e3559f4 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -7200,6 +7200,12 @@ gfc_trans_subcomponent_assign (tree dest, gfc_component * cm, gfc_expr * expr,
tmp = gfc_trans_alloc_subarray_assign (tmp, cm, expr);
gfc_add_expr_to_block (&block, tmp);
}
+ else if (init && cm->attr.allocatable && expr->expr_type == EXPR_NULL)
+ {
+ /* NULL initialization for allocatable components. */
+ gfc_add_modify (&block, dest, fold_convert (TREE_TYPE (dest),
+ null_pointer_node));
+ }
else if (init && (cm->attr.allocatable
|| (cm->ts.type == BT_CLASS && CLASS_DATA (cm)->attr.allocatable
&& expr->ts.type != BT_CLASS)))