]> git.ipfire.org Git - thirdparty/gcc.git/commit
Fortran: Auto array allocation with function dependencies [PR59104]
authorPaul Thomas <pault@gcc.gnu.org>
Thu, 20 Jun 2024 07:01:36 +0000 (08:01 +0100)
committerPaul Thomas <pault@gcc.gnu.org>
Thu, 20 Jun 2024 07:01:36 +0000 (08:01 +0100)
commitccaa39a268bef2a1d8880022696ff2dcaa6af941
treefc4dec85138e2edc6ae85f0e3c705ac3d9ea175b
parent46bb4ce4d30ab749d40f6f4cef6f1fb7c7813452
Fortran: Auto array allocation with function dependencies [PR59104]

2024-06-20  Paul Thomas  <pault@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.
gcc/fortran/dependency.cc
gcc/fortran/dependency.h
gcc/fortran/error.cc
gcc/fortran/gfortran.h
gcc/fortran/symbol.cc
gcc/fortran/trans-array.cc
gcc/fortran/trans-decl.cc
gcc/fortran/trans.cc
gcc/fortran/trans.h
gcc/testsuite/gfortran.dg/dependent_decls_2.f90 [new file with mode: 0644]