diff options
author | Janus Weil <janus@gcc.gnu.org> | 2010-10-26 19:38:42 +0200 |
---|---|---|
committer | Janus Weil <janus@gcc.gnu.org> | 2010-10-26 19:38:42 +0200 |
commit | 2c80712872be90ceda8afb904e3b1f8d6501d070 (patch) | |
tree | 94b46a9fc603f6f0d3a211f16ef784d84c96bfaf /gcc/fortran/trans-array.c | |
parent | 530f3a1bf62964c0c52d6fcf4ca0d321ce9d5156 (diff) | |
download | gcc-2c80712872be90ceda8afb904e3b1f8d6501d070.zip gcc-2c80712872be90ceda8afb904e3b1f8d6501d070.tar.gz gcc-2c80712872be90ceda8afb904e3b1f8d6501d070.tar.bz2 |
re PR fortran/42647 ([F03] Missed initialization/dealloc of allocatable scalar DT with allocatable component)
2010-10-26 Janus Weil <janus@gcc.gnu.org>
PR fortran/42647
* trans.h (gfc_deallocate_scalar_with_status): New prototype.
* trans.c (gfc_deallocate_scalar_with_status): New function for
deallocation of allocatable scalars.
* trans-array.c (structure_alloc_comps): Call it here ...
* trans-decl.c (gfc_trans_deferred_vars): ... here ...
* trans-stmt.c (gfc_trans_deallocate): ... and here.
2010-10-26 Janus Weil <janus@gcc.gnu.org>
PR fortran/42647
* gfortran.dg/allocatable_scalar_9.f90: Extended.
* gfortran.dg/allocatable_scalar_10.f90: New.
* gfortran.dg/class_19.f03: Extended.
From-SVN: r165973
Diffstat (limited to 'gcc/fortran/trans-array.c')
-rw-r--r-- | gcc/fortran/trans-array.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index db05734..47ee8fd 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -6281,22 +6281,18 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl, switch (purpose) { case DEALLOCATE_ALLOC_COMP: - /* Do not deallocate the components of ultimate pointer - components. */ - if (cmp_has_alloc_comps && !c->attr.pointer) - { - comp = fold_build3_loc (input_location, COMPONENT_REF, ctype, - decl, cdecl, NULL_TREE); - rank = c->as ? c->as->rank : 0; - tmp = structure_alloc_comps (c->ts.u.derived, comp, NULL_TREE, - rank, purpose); - gfc_add_expr_to_block (&fnblock, tmp); - } - if (c->attr.allocatable && c->attr.dimension) { comp = fold_build3_loc (input_location, COMPONENT_REF, ctype, decl, cdecl, NULL_TREE); + if (cmp_has_alloc_comps && !c->attr.pointer) + { + /* Do not deallocate the components of ultimate pointer + components. */ + tmp = structure_alloc_comps (c->ts.u.derived, comp, NULL_TREE, + c->as->rank, purpose); + gfc_add_expr_to_block (&fnblock, tmp); + } tmp = gfc_trans_dealloc_allocated (comp); gfc_add_expr_to_block (&fnblock, tmp); } @@ -6306,7 +6302,8 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl, comp = fold_build3_loc (input_location, COMPONENT_REF, ctype, decl, cdecl, NULL_TREE); - tmp = gfc_deallocate_with_status (comp, NULL_TREE, true, NULL); + tmp = gfc_deallocate_scalar_with_status (comp, NULL, true, NULL, + c->ts); gfc_add_expr_to_block (&fnblock, tmp); tmp = fold_build2_loc (input_location, MODIFY_EXPR, @@ -6325,7 +6322,8 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl, comp = fold_build3_loc (input_location, COMPONENT_REF, TREE_TYPE (tmp), comp, tmp, NULL_TREE); - tmp = gfc_deallocate_with_status (comp, NULL_TREE, true, NULL); + tmp = gfc_deallocate_scalar_with_status (comp, NULL, true, NULL, + CLASS_DATA (c)->ts); gfc_add_expr_to_block (&fnblock, tmp); tmp = fold_build2_loc (input_location, MODIFY_EXPR, |