From: Paul Thomas Date: Sat, 20 Sep 2025 13:25:47 +0000 (+0100) Subject: Fortran: Fix regtest failure in pdt_48.f03. [PR83746] X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8ded56a52a79333ea0829d930254ec9c6f04db90;p=thirdparty%2Fgcc.git Fortran: Fix regtest failure in pdt_48.f03. [PR83746] 2025-09-20 Paul Thomas gcc/fortran PR fortran/83746 * trans-decl.cc (gfc_trans_deferred_vars): If a procedure with an non-allocatable, non-pointer explicit PDT result has no default initializer, the parameterized components should be allocated. --- diff --git a/gcc/fortran/trans-decl.cc b/gcc/fortran/trans-decl.cc index f423dd728aa..055698b1efd 100644 --- a/gcc/fortran/trans-decl.cc +++ b/gcc/fortran/trans-decl.cc @@ -4831,6 +4831,23 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, gfc_wrapped_block * block) } } + sym = (proc_sym->attr.function + && proc_sym != proc_sym->result) ? proc_sym->result : NULL; + + if (sym && !sym->attr.allocatable && !sym->attr.pointer + && sym->ts.type == BT_DERIVED + && sym->ts.u.derived + && !gfc_has_default_initializer (sym->ts.u.derived) + && sym->ts.u.derived->attr.pdt_type) + { + gfc_init_block (&tmpblock); + tmp = gfc_allocate_pdt_comp (sym->ts.u.derived, + sym->backend_decl, + sym->as ? sym->as->rank : 0, + sym->param_list); + gfc_add_expr_to_block (&tmpblock, tmp); + gfc_add_init_cleanup (block, gfc_finish_block (&tmpblock), NULL); + } /* Initialize the INTENT(OUT) derived type dummy arguments. This should be done here so that the offsets and lbounds of arrays