https://gcc.gnu.org/bugzilla/show_bug.cgi?id=45516
--- Comment #8 from Paul Thomas <pault at gcc dot gnu.org> --- Author: pault Date: Tue Oct 25 20:37:05 2016 New Revision: 241539 URL: https://gcc.gnu.org/viewcvs?rev=241539&root=gcc&view=rev Log: 2016-10-25 Paul Thomas <pa...@gcc.gnu.org> PR fortran/45516 * class.c (gfc_find_derived_vtab): Detect recursive allocatable derived type components. If present, add '_deallocate' field to the vtable and build the '__deallocate' function. * decl.c (build_struct): Allow recursive allocatable derived type components for -std=f2008 or more. (gfc_match_data_decl): Accept these derived types. * expr.c (gfc_has_default_initializer): Ditto. * resolve.c (resolve_component): Make sure that the vtable is built for these derived types. * trans-array.c(structure_alloc_comps) : Use the '__deallocate' function for the automatic deallocation of these types. * trans-expr.c : Generate the deallocate accessor. * trans.h : Add its prototype. * trans-types.c (gfc_get_derived_type): Treat the recursive allocatable components in the same way as the corresponding pointer components. 2016-10-25 Paul Thomas <pa...@gcc.gnu.org> PR fortran/45516 * gfortran.dg/class_2.f03: Set -std=f2003. * gfortran.dg/finalize_21.f90: Modify tree-dump. * gfortran.dg/recursive_alloc_comp_1.f08: New test. * gfortran.dg/recursive_alloc_comp_2.f08: New test. * gfortran.dg/recursive_alloc_comp_3.f08: New test. * gfortran.dg/recursive_alloc_comp_4.f08: New test. Added: trunk/gcc/testsuite/gfortran.dg/recursive_alloc_comp_1.f08 trunk/gcc/testsuite/gfortran.dg/recursive_alloc_comp_2.f08 trunk/gcc/testsuite/gfortran.dg/recursive_alloc_comp_3.f08 trunk/gcc/testsuite/gfortran.dg/recursive_alloc_comp_4.f08 Modified: trunk/gcc/fortran/class.c trunk/gcc/fortran/decl.c trunk/gcc/fortran/expr.c trunk/gcc/fortran/resolve.c trunk/gcc/fortran/trans-array.c trunk/gcc/fortran/trans-expr.c trunk/gcc/fortran/trans-types.c trunk/gcc/fortran/trans.h trunk/gcc/testsuite/gfortran.dg/class_2.f03 trunk/gcc/testsuite/gfortran.dg/finalize_21.f90