re PR fortran/41478 (Corrupted memory using PACK for derived-types with allocated...
authorPaul Thomas <pault@gcc.gnu.org>
Thu, 14 Jan 2010 06:17:38 +0000 (06:17 +0000)
committerPaul Thomas <pault@gcc.gnu.org>
Thu, 14 Jan 2010 06:17:38 +0000 (06:17 +0000)
commit40c3294835c9e8e416c0eae4688c1160ffc8ad3f
tree00205ae58b6e5ce1f062de0463815660141dcdc6
parent08b02036337225eb9b58497c704efaa2b41918bc
re PR fortran/41478 (Corrupted memory using PACK for derived-types with allocated components)

2010-01-14  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/41478
        * trans-array.c (duplicate_allocatable):  Static version of
gfc_duplicate_allocatable with provision to handle scalar
components. New boolean argument to switch off call to malloc
if true.
(gfc_duplicate_allocatable): New function to call above with
new argument false.
(gfc_copy_allocatable_data): New function to call above with
new argument true.
(structure_alloc_comps): Do not apply indirect reference to
scalar pointers. Add new section to copy allocatable components
of arrays. Extend copying of allocatable components to include
scalars.
(gfc_copy_only_alloc_comp): New function to copy allocatable
component derived types, without allocating the base structure.
* trans-array.h : Add primitive for gfc_copy_allocatable_data.
Add primitive for gfc_copy_only_alloc_comp.
* trans-expr.c (gfc_conv_procedure_call): After calls to
transformational functions with results that are derived types
with allocatable components, copy the components in the result.
(gfc_trans_arrayfunc_assign): Deallocate allocatable components
of lhs derived types before allocation.

2010-01-14  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/41478
        * gfortran.dg/alloc_comp_scalar_1.f90: New test.
        * gfortran.dg/alloc_comp_transformational_1.f90: New test.

From-SVN: r155877
gcc/fortran/ChangeLog
gcc/fortran/trans-array.c
gcc/fortran/trans-array.h
gcc/fortran/trans-expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/alloc_comp_scalar_1.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/alloc_comp_transformational_1.f90 [new file with mode: 0644]