This problem is not really a regression but is a "feature" that was exposed by my patch for PR81447.
The testcase fails because the caf token for the pointer component is not present in the type. This is fixed in trans-types.c (gfc_get_derived_type) in the manner described in the ChangeLog. Bootstrapped and regtested on FC23/x86_64 - OK for trunk? I would be grateful if caf aficionados would give the patch a whirl on their favourite codes. Cheers Paul 2017-11-29 Paul Thomas <pa...@gcc.gnu.org> PR fortran/83076 * trans-types.c (gfc_get_derived_type): Flag GFC_FCOARRAY_LIB for module derived types that are not vtypes. Use this flag to use the module backend_decl as the canonical type and to build the type anew, ensuring that scalar allocatable and pointer components have the caf token field added. 2017-11-29 Paul Thomas <pa...@gcc.gnu.org> PR fortran/83076 * gfortran.dg/coarray_45.f90 : New test.
Index: gcc/fortran/trans-types.c =================================================================== *** gcc/fortran/trans-types.c (revision 255161) --- gcc/fortran/trans-types.c (working copy) *************** gfc_get_derived_type (gfc_symbol * deriv *** 2483,2488 **** --- 2483,2492 ---- gfc_dt_list *dt; gfc_namespace *ns; tree tmp; + bool coarray_flag; + + coarray_flag = flag_coarray == GFC_FCOARRAY_LIB + && derived->module && !derived->attr.vtype; gcc_assert (!derived->attr.pdt_template); *************** gfc_get_derived_type (gfc_symbol * deriv *** 2523,2534 **** return derived->backend_decl; } ! /* If use associated, use the module type for this one. */ if (derived->backend_decl == NULL && derived->attr.use_assoc && derived->module && gfc_get_module_backend_decl (derived)) ! goto copy_derived_types; /* The derived types from an earlier namespace can be used as the canonical type. */ --- 2527,2545 ---- return derived->backend_decl; } ! /* If use associated, use the module type for this one, except for the case ! where codimensions are present or where a caf_token is needed for pointer ! or allocatable components. */ if (derived->backend_decl == NULL && derived->attr.use_assoc && derived->module && gfc_get_module_backend_decl (derived)) ! { ! if (coarray_flag || codimen) ! got_canonical = true; ! else ! goto copy_derived_types; ! } /* The derived types from an earlier namespace can be used as the canonical type. */ *************** gfc_get_derived_type (gfc_symbol * deriv *** 2764,2770 **** GFC_DECL_PTR_ARRAY_P (c->backend_decl) = 1; /* Do not add a caf_token field for classes' data components. */ ! if (codimen && !c->attr.dimension && !c->attr.codimension && (c->attr.allocatable || c->attr.pointer) && c->caf_token == NULL_TREE && strcmp ("_data", c->name) != 0) { --- 2775,2782 ---- GFC_DECL_PTR_ARRAY_P (c->backend_decl) = 1; /* Do not add a caf_token field for classes' data components. */ ! if ((codimen || coarray_flag) ! && !c->attr.dimension && !c->attr.codimension && (c->attr.allocatable || c->attr.pointer) && c->caf_token == NULL_TREE && strcmp ("_data", c->name) != 0) { Index: gcc/testsuite/gfortran.dg/coarray_45.f90 =================================================================== *** gcc/testsuite/gfortran.dg/coarray_45.f90 (nonexistent) --- gcc/testsuite/gfortran.dg/coarray_45.f90 (working copy) *************** *** 0 **** --- 1,24 ---- + ! { dg-do compile } + ! { dg-options "-fcoarray=lib -lcaf_single " } + ! + ! Test the fix for PR83076 + ! + module m + type t + integer, pointer :: z + end type + type(t) :: ptr + contains + function g(x) + type(t) :: x[*] + if (associated (x%z, ptr%z)) deallocate (x%z) ! This used to ICE with -fcoarray=lib + end + end module + + use m + contains + function f(x) + type(t) :: x[*] + if (associated (x%z, ptr%z)) deallocate (x%z) + end + end