]> git.ipfire.org Git - thirdparty/gcc.git/commit
Fortran: Add code gen for do,concurrent's LOCAL/LOCAL_INIT [PR101602]
authorTobias Burnus <tburnus@baylibre.com>
Wed, 9 Apr 2025 06:21:19 +0000 (08:21 +0200)
committerTobias Burnus <tburnus@baylibre.com>
Wed, 9 Apr 2025 06:21:19 +0000 (08:21 +0200)
commit2d7e1d6e40a13a5f160b584336795b80f193ec3b
treebeeb5256dd903907a5c3b257207e25065fe1a082
parent94438ca82792063abf05823326695af25ab02d17
Fortran: Add code gen for do,concurrent's LOCAL/LOCAL_INIT [PR101602]

Implement LOCAL and LOCAL_INIT; we locally replace the tree declaration by
a local declaration of the outer variable. The 'local_init' then assigns
the value at the beginning of each loop iteration from the outer
declaration.

Note that the current implementation does not handle LOCAL with types that
have a default initializer and LOCAL/LOCAL_INIT for assumed-shape arrays;
this is diagnosed with a sorry error.

PR fortran/101602

gcc/fortran/ChangeLog:

* resolve.cc (resolve_locality_spec): Remove 'sorry, unimplemented'.
* trans-stmt.cc (struct symbol_and_tree_t): New.
(gfc_trans_concurrent_locality_spec): New.
(gfc_trans_forall_1): Call it; update to handle local and local_init.
* trans-decl.cc (gfc_start_saved_local_decls,
gfc_stop_saved_local_decls): New; moved code from ...
(gfc_process_block_locals): ... here. Call it.
* trans.h (gfc_start_saved_local_decls,
gfc_stop_saved_local_decls): Declare.

gcc/testsuite/ChangeLog:

* gfortran.dg/do_concurrent_8_f2023.f90: Update for removed 'sorry,
unimplemented'.
* gfortran.dg/do_concurrent_9.f90: Likewise.
* gfortran.dg/do_concurrent_all_clauses.f90: Likewise.
* gfortran.dg/do_concurrent_local_init.f90: Likewise.
* gfortran.dg/do_concurrent_locality_specs.f90: Likewise.
* gfortran.dg/do_concurrent_11.f90: New test.
* gfortran.dg/do_concurrent_12.f90: New test.
* gfortran.dg/do_concurrent_13.f90: New test.
* gfortran.dg/do_concurrent_14.f90: New test.
* gfortran.dg/do_concurrent_15.f90: New test.
14 files changed:
gcc/fortran/resolve.cc
gcc/fortran/trans-decl.cc
gcc/fortran/trans-stmt.cc
gcc/fortran/trans.h
gcc/testsuite/gfortran.dg/do_concurrent_11.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/do_concurrent_12.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/do_concurrent_13.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/do_concurrent_14.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/do_concurrent_15.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/do_concurrent_8_f2023.f90
gcc/testsuite/gfortran.dg/do_concurrent_9.f90
gcc/testsuite/gfortran.dg/do_concurrent_all_clauses.f90
gcc/testsuite/gfortran.dg/do_concurrent_local_init.f90
gcc/testsuite/gfortran.dg/do_concurrent_locality_specs.f90