]> git.ipfire.org Git - thirdparty/gcc.git/commit
OpenMP/Fortran: 'declare target' fix + parse 'local' clause; parse groupprivate
authorTobias Burnus <tburnus@baylibre.com>
Wed, 26 Nov 2025 20:47:18 +0000 (21:47 +0100)
committerTobias Burnus <tburnus@baylibre.com>
Wed, 26 Nov 2025 20:47:18 +0000 (21:47 +0100)
commit26d41e245dbba3e2267c0bd432f31c6d1fb81361
tree12195d75cf2c989bb1080bc0661a4d47a316ce37
parent856fae983bca6a934b74f47c7cd21e6919035fc0
OpenMP/Fortran: 'declare target' fix + parse 'local' clause; parse groupprivate

Declare target's 'link' clause disallows 'nohost'; check for it.
Additionally, some other cleanups have been done.

The 'local' clause to 'declare target' is now supported in the FE,
but a 'sorry, unimplemented' is printed at TREE generation time.

This commit also adds the 'groupprivate' directive, which implies
'declare target' with the 'local' clause. And for completeness also
the 'dyn_groupprivate' clause to 'target'. However, all those new
features will eventually print 'sorry, unimplemented' for now.

gcc/fortran/ChangeLog:

* dump-parse-tree.cc (show_attr): Handle OpenMP's 'local' clause
and the 'groupprivate' directive.
(show_omp_clauses): Handle dyn_groupprivate.
* frontend-passes.cc (gfc_code_walker): Walk dyn_groupprivate.
* gfortran.h (enum gfc_statement): Add ST_OMP_GROUPPRIVATE.
(enum gfc_omp_fallback, gfc_add_omp_groupprivate,
gfc_add_omp_declare_target_local): New.
* match.h (gfc_match_omp_groupprivate): New.
* module.cc (enum ab_attribute, mio_symbol_attribute, load_commons,
write_common_0): Handle 'groupprivate' + declare target's 'local'.
* openmp.cc (gfc_omp_directives): Add 'groupprivate'.
(gfc_free_omp_clauses): Free dyn_groupprivate.
(enum omp_mask2): Add OMP_CLAUSE_LOCAL and OMP_CLAUSE_DYN_GROUPPRIVATE.
(gfc_match_omp_clauses): Match them.
(OMP_TARGET_CLAUSES): Add OMP_CLAUSE_DYN_GROUPPRIVATE.
(OMP_DECLARE_TARGET_CLAUSES): Add OMP_CLAUSE_LOCAL.
(gfc_match_omp_declare_target): Handle groupprivate + fixes.
(gfc_match_omp_threadprivate): Code move to and calling now ...
(gfc_match_omp_thread_group_private): ... this new function.
Also handle groupprivate.
(gfc_match_omp_groupprivate): New.
(resolve_omp_clauses): Resolve dyn_groupprivate.
* parse.cc (decode_omp_directive): Match groupprivate.
(case_omp_decl, parse_spec, gfc_ascii_statement): Handle it.
* resolve.cc (resolve_symbol): Handle groupprivate.
* symbol.cc (gfc_check_conflict, gfc_copy_attr): Handle 'local'
and 'groupprivate'.
(gfc_add_omp_groupprivate, gfc_add_omp_declare_target_local): New.
* trans-common.cc (build_common_decl,
accumulate_equivalence_attributes): Print 'sorry' for
groupprivate and declare target's local.
* trans-decl.cc (add_attributes_to_decl): Likewise..
* trans-openmp.cc (gfc_trans_omp_clauses): Print 'sorry' for
dyn_groupprivate.
(fallback): Process declare target with link/local as
done for 'enter'.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/crayptr2.f90: Move dg-error line.
* gfortran.dg/gomp/declare-target-2.f90: Extend.
* gfortran.dg/gomp/declare-target-4.f90: Update comment,
enable one test.
* gfortran.dg/gomp/declare-target-5.f90: Update dg- wording,
add new test.
* gfortran.dg/gomp/declare-target-indirect-2.f90: Expect
'device_type(any)' in scan-tree-dump.
* gfortran.dg/gomp/declare-target-6.f90: New test.
* gfortran.dg/gomp/dyn_groupprivate-1.f90: New test.
* gfortran.dg/gomp/dyn_groupprivate-2.f90: New test.
* gfortran.dg/gomp/groupprivate-1.f90: New test.
* gfortran.dg/gomp/groupprivate-2.f90: New test.
* gfortran.dg/gomp/groupprivate-3.f90: New test.
* gfortran.dg/gomp/groupprivate-4.f90: New test.
* gfortran.dg/gomp/groupprivate-5.f90: New test.
* gfortran.dg/gomp/groupprivate-6.f90: New test.
26 files changed:
gcc/fortran/dump-parse-tree.cc
gcc/fortran/frontend-passes.cc
gcc/fortran/gfortran.h
gcc/fortran/match.h
gcc/fortran/module.cc
gcc/fortran/openmp.cc
gcc/fortran/parse.cc
gcc/fortran/resolve.cc
gcc/fortran/symbol.cc
gcc/fortran/trans-common.cc
gcc/fortran/trans-decl.cc
gcc/fortran/trans-openmp.cc
gcc/testsuite/gfortran.dg/gomp/crayptr2.f90
gcc/testsuite/gfortran.dg/gomp/declare-target-2.f90
gcc/testsuite/gfortran.dg/gomp/declare-target-4.f90
gcc/testsuite/gfortran.dg/gomp/declare-target-5.f90
gcc/testsuite/gfortran.dg/gomp/declare-target-6.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/gomp/declare-target-indirect-2.f90
gcc/testsuite/gfortran.dg/gomp/dyn_groupprivate-1.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/gomp/dyn_groupprivate-2.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/gomp/groupprivate-1.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/gomp/groupprivate-2.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/gomp/groupprivate-3.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/gomp/groupprivate-4.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/gomp/groupprivate-5.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/gomp/groupprivate-6.f90 [new file with mode: 0644]