diff options
author | Daniel Carrera <dcarrera@gmail.com> | 2011-07-27 10:10:06 +0000 |
---|---|---|
committer | Daniel Carrera <dcarrera@gcc.gnu.org> | 2011-07-27 10:10:06 +0000 |
commit | 4f13e17fff3c787928f674a9ba26fd5517fc387d (patch) | |
tree | 0ce63aa3e4271ca28e6a80ffa44834d9407308ed /gcc/fortran/trans-stmt.c | |
parent | 7bbdd4e9c3f0647ee683a7e433128737139275fe (diff) | |
download | gcc-4f13e17fff3c787928f674a9ba26fd5517fc387d.zip gcc-4f13e17fff3c787928f674a9ba26fd5517fc387d.tar.gz gcc-4f13e17fff3c787928f674a9ba26fd5517fc387d.tar.bz2 |
re PR fortran/49755 (ALLOCATE with STAT= produces invalid code for already allocated vars)
2011-07-26 Daniel Carrera <dcarrera@gmail.com>
PR fortran/49755
* trans.c (gfc_allocate_using_malloc): Change function signature.
Return nothing. New parameter "pointer". Eliminate temorary variables.
(gfc_allocate_using_lib): Ditto.
(gfc_allocate_allocatable): Ditto. Update call to gfc_allocate_using_lib
and gfc_allocate_using_malloc. Do not free and then reallocate a
variable that is already allocated.
(gfc_likely): New function. Basedon gfc_unlikely.
* trans-array.c (gfc_array_init_size): New parameter "descriptor_block".
Instructions to modify the array descriptor are stored in this block
while other instructions continue to be stored in "pblock".
(gfc_array_allocate): Update call to gfc_array_init_size. Move the
descriptor_block so that the array descriptor is only updated if
the array was allocated successfully.
Update calls to gfc_allocate_allocatable and gfc_allocate_using_malloc.
* trans.h (gfc_allocate_allocatable): Change function signature.
Function now returns void.
(gfc_allocate_using_lib): Ditto, and new function parameter.
(gfc_allocate_using_malloc): Ditto.
* trans-openmp.c (gfc_omp_clause_default_ctor,
gfc_omp_clause_copy_ctor,gfc_trans_omp_array_reduction): Replace a call
to gfc_allocate_allocatable with gfc_allocate_using_malloc.
* trans-stmt.c (gfc_trans_allocate): Update function calls for
gfc_allocate_allocatable and gfc_allocate_using_malloc.
2011-07-26 Daniel Carrera <dcarrera@gmail.com>
PR fortran/49755
* gfortran.dg/multiple_allocation_1.f90: Fix test. Allocating an
allocated array should *not* change its size.
* gfortran.dg/multiple_allocation_3.f90: New test.
From-SVN: r176822
Diffstat (limited to 'gcc/fortran/trans-stmt.c')
-rw-r--r-- | gcc/fortran/trans-stmt.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c index 75d72a2..defa445 100644 --- a/gcc/fortran/trans-stmt.c +++ b/gcc/fortran/trans-stmt.c @@ -4867,15 +4867,10 @@ gfc_trans_allocate (gfc_code * code) /* Allocate - for non-pointers with re-alloc checking. */ if (gfc_expr_attr (expr).allocatable) - tmp = gfc_allocate_allocatable (&se.pre, se.expr, memsz, - stat, errmsg, errlen, expr); + gfc_allocate_allocatable (&se.pre, se.expr, memsz, + stat, errmsg, errlen, expr); else - tmp = gfc_allocate_using_malloc (&se.pre, memsz, stat); - - tmp = fold_build2_loc (input_location, MODIFY_EXPR, void_type_node, - se.expr, - fold_convert (TREE_TYPE (se.expr), tmp)); - gfc_add_expr_to_block (&se.pre, tmp); + gfc_allocate_using_malloc (&se.pre, se.expr, memsz, stat); if (expr->ts.type == BT_DERIVED && expr->ts.u.derived->attr.alloc_comp) { @@ -4901,7 +4896,7 @@ gfc_trans_allocate (gfc_code * code) boolean_type_node, stat, build_int_cst (TREE_TYPE (stat), 0)); tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node, - parm, tmp, + gfc_unlikely(parm), tmp, build_empty_stmt (input_location)); gfc_add_expr_to_block (&block, tmp); } |