trans-array.c (gfc_alloc_allocatable_for_assignment): Allocate at least one byte.

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-21  Tobias Burnus  <burnus@net-b.de>

        * gfortran.dg/realloc_on_assign_18.f90: New.

From-SVN: r200320
This commit is contained in:
Tobias Burnus 2013-06-21 23:24:59 +02:00 committed by Tobias Burnus
parent 2ce86d2eb5
commit 6f556b07c9
5 changed files with 35 additions and 0 deletions

View file

@ -1,3 +1,9 @@
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.

View file

@ -8209,6 +8209,8 @@ gfc_alloc_allocatable_for_assignment (gfc_loopinfo *loop,
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

View file

@ -7574,6 +7574,9 @@ alloc_scalar_allocatable_for_assignment (stmtblock_t *block,
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,

View file

@ -1,3 +1,7 @@
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.

View file

@ -0,0 +1,20 @@
! { 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" } }