https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59104
--- Comment #9 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-14 branch has been updated by Paul Thomas <pa...@gcc.gnu.org>: https://gcc.gnu.org/g:5034af8223c0db07cdec01cef70048ec44cdd47b commit r14-10477-g5034af8223c0db07cdec01cef70048ec44cdd47b Author: Paul Thomas <pa...@gcc.gnu.org> Date: Thu Jun 20 08:01:36 2024 +0100 Fortran: Auto array allocation with function dependencies [PR59104] 2024-06-20 Paul Thomas <pa...@gcc.gnu.org> gcc/fortran PR fortran/59104 * dependency.cc (dependency_fcn, gfc_function_dependency): New functions to detect dependency in array bounds and character lengths on old style function results. * dependency.h : Add prototype for gfc_function_dependency. * error.cc (error_print): Remove trailing space. * gfortran.h : Remove dummy_order and add fn_result_spec. * symbol.cc : Remove declaration of next_dummy_order.. (gfc_set_sym_referenced): remove setting of symbol dummy order. * trans-array.cc (gfc_trans_auto_array_allocation): Detect non-dummy symbols with function dependencies and put the allocation at the end of the initialization code. * trans-decl.cc : Include dependency.h. (decl_order): New function that determines uses the location field of the symbol 'declared_at' to determine the order of two declarations. (gfc_defer_symbol_init): Call gfc_function_dependency to put dependent symbols in the right part of the tlink chain. Use the location field of the symbol declared_at to determine the order of declarations. (gfc_trans_auto_character_variable): Put character length initialization of dependent symbols at the end of the chain. * trans.cc (gfc_add_init_cleanup): Add boolean argument with default false that determines whther an expression is placed at the back or the front of the initialization chain. * trans.h : Update the prototype for gfc_add_init_cleanup. gcc/testsuite/ PR fortran/59104 * gfortran.dg/dependent_decls_2.f90: New test. (cherry picked from commit ccaa39a268bef2a1d8880022696ff2dcaa6af941)