===================================================================
@@ -1,6 +1,13 @@
2016-07-22 Andre Vehreschild <vehre@gcc.gnu.org>
Backport from trunk:
+ PR fortran/71807
+ * trans-expr.c (gfc_trans_subcomponent_assign): Special casing
+ when allocatable component is set to null() in initializer.
+
+2016-07-22 Andre Vehreschild <vehre@gcc.gnu.org>
+
+ Backport from trunk:
PR fortran/70842
* simplify.c (gfc_simplify_len): Only for unlimited polymorphic
types replace the expression's _data ref with a _len ref.
===================================================================
@@ -7012,6 +7012,12 @@
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)))
===================================================================
@@ -1,6 +1,12 @@
2016-07-22 Andre Vehreschild <vehre@gcc.gnu.org>
Backport from trunk:
+ PR fortran/71807
+ * gfortran.dg/null_9.f90: New test.
+
+2016-07-22 Andre Vehreschild <vehre@gcc.gnu.org>
+
+ Backport from trunk:
PR fortran/70842
* gfortran.dg/select_type_35.f03: New test.
===================================================================
@@ -0,0 +1,30 @@
+! { dg-do run }
+
+MODULE fold_convert_loc_ice
+ IMPLICIT NONE
+ PRIVATE
+
+ TYPE, PUBLIC :: ta
+ PRIVATE
+ INTEGER :: a_comp
+ END TYPE ta
+
+ TYPE, PUBLIC :: tb
+ TYPE(ta), ALLOCATABLE :: b_comp
+ END TYPE tb
+
+ PUBLIC :: proc
+CONTAINS
+ SUBROUTINE proc
+ TYPE(tb) :: b
+
+ b = tb(null())
+ if (allocated( b%b_comp )) call abort()
+ END SUBROUTINE proc
+END MODULE fold_convert_loc_ice
+
+ USE fold_convert_loc_ice
+
+ call proc()
+END
+