diff options
author | dcarrera <dcarrera@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-07-27 10:10:06 +0000 |
---|---|---|
committer | dcarrera <dcarrera@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-07-27 10:10:06 +0000 |
commit | 297effe4a0af07893bba126c94f447e91da63474 (patch) | |
tree | 0ce63aa3e4271ca28e6a80ffa44834d9407308ed /gcc/fortran/trans-openmp.c | |
parent | f5038a769921a53cfaddee7f4fd3668f4d48d849 (diff) | |
download | gcc-297effe4a0af07893bba126c94f447e91da63474.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@176822 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran/trans-openmp.c')
-rw-r--r-- | gcc/fortran/trans-openmp.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c index cd5ef0a4d05..29e342f13fb 100644 --- a/gcc/fortran/trans-openmp.c +++ b/gcc/fortran/trans-openmp.c @@ -188,10 +188,11 @@ gfc_omp_clause_default_ctor (tree clause, tree decl, tree outer) size = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type, size, esize); size = gfc_evaluate_now (fold_convert (size_type_node, size), &cond_block); - ptr = gfc_allocate_allocatable (&cond_block, - build_int_cst (pvoid_type_node, 0), - size, NULL_TREE, NULL_TREE, NULL_TREE, NULL); + + ptr = gfc_create_var (pvoid_type_node, NULL); + gfc_allocate_using_malloc (&cond_block, ptr, size, NULL_TREE); gfc_conv_descriptor_data_set (&cond_block, decl, ptr); + then_b = gfc_finish_block (&cond_block); gfc_init_block (&cond_block); @@ -241,10 +242,11 @@ gfc_omp_clause_copy_ctor (tree clause, tree dest, tree src) size = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type, size, esize); size = gfc_evaluate_now (fold_convert (size_type_node, size), &block); - ptr = gfc_allocate_allocatable (&block, - build_int_cst (pvoid_type_node, 0), - size, NULL_TREE, NULL_TREE, NULL_TREE, NULL); + + ptr = gfc_create_var (pvoid_type_node, NULL); + gfc_allocate_using_malloc (&block, ptr, size, NULL_TREE); gfc_conv_descriptor_data_set (&block, dest, ptr); + call = build_call_expr_loc (input_location, built_in_decls[BUILT_IN_MEMCPY], 3, ptr, fold_convert (pvoid_type_node, @@ -663,10 +665,11 @@ gfc_trans_omp_array_reduction (tree c, gfc_symbol *sym, locus where) size = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type, size, esize); size = gfc_evaluate_now (fold_convert (size_type_node, size), &block); - ptr = gfc_allocate_allocatable (&block, - build_int_cst (pvoid_type_node, 0), - size, NULL_TREE, NULL_TREE, NULL_TREE, NULL); + + ptr = gfc_create_var (pvoid_type_node, NULL); + gfc_allocate_using_malloc (&block, ptr, size, NULL_TREE); gfc_conv_descriptor_data_set (&block, decl, ptr); + gfc_add_expr_to_block (&block, gfc_trans_assignment (e1, e2, false, false)); stmt = gfc_finish_block (&block); |