+2013-06-21 Tobias Burnus <burnus@net-b.de>
+
+ * trans-array.c (gfc_alloc_allocatable_for_assignment): Allocate
+ at least one byte.
+ * trans-expr.c (alloc_scalar_allocatable_for_assignment): Ditto.
+
2013-06-20 Tobias Burnus <burnus@net-b.de>
* resolve.c (get_temp_from_expr): Don't set FL_VARIABLE twice.
gfc_array_index_type,
tmp, size2);
size2 = fold_convert (size_type_node, size2);
+ size2 = fold_build2_loc (input_location, MAX_EXPR, size_type_node,
+ size2, size_one_node);
size2 = gfc_evaluate_now (size2, &fblock);
/* Realloc expression. Note that the scalarizer uses desc.data
size_in_bytes = size;
}
+ size_in_bytes = fold_build2_loc (input_location, MAX_EXPR, size_type_node,
+ size_in_bytes, size_one_node);
+
if (expr1->ts.type == BT_DERIVED && expr1->ts.u.derived->attr.alloc_comp)
{
tmp = build_call_expr_loc (input_location,
+2013-06-21 Tobias Burnus <burnus@net-b.de>
+
+ * gfortran.dg/realloc_on_assign_18.f90: New.
+
2013-06-21 Balaji V. Iyer <balaji.v.iyer@intel.com>
* c-c++-common/cilk-plus/AN/array_test1.c: Make this an execution test.
--- /dev/null
+! { dg-do compile }
+! { dg-options "-fdump-tree-original" }
+!
+! Ensure that for zero-sized array, nonzero memory is allocated
+!
+type t
+end type t
+
+type(t), allocatable :: x, y(:)
+
+x = t()
+y = [ t :: ]
+
+if (.not. allocated (x)) call abort ()
+if (.not. allocated (y)) call abort ()
+end
+
+! { dg-final { scan-tree-dump "x = \\(struct t .\\) __builtin_malloc \\(1\\);" "original" } }
+! { dg-final { scan-tree-dump "y.data = \\(void . restrict\\) __builtin_malloc \\(1\\);" "original" } }
+! { dg-final { cleanup-tree-dump "original" } }