]> git.ipfire.org Git - thirdparty/gcc.git/commit
openmp: Fix handling of declare target statics with array type which need destruction...
authorJakub Jelinek <jakub@redhat.com>
Tue, 25 Feb 2025 08:29:39 +0000 (09:29 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 25 Feb 2025 08:29:39 +0000 (09:29 +0100)
commit86a4af2793393e47af6b78cb7094c97914890091
tree32f3e251227ac72efb8a2df4d33bdbc807719617
parenta41b3f54c13890b1327bb3d4fbae8f7feb37d00b
openmp: Fix handling of declare target statics with array type which need destruction [PR118876]

The following testcase ICEs because it attempts to emit the __tcfa function twice,
once when handling the host destruction and once when handling nohost destruction.

This patch fixes it by using __omp_tcfa function for the nohost case and marks it
with the needed "omp declare target" and "omp declare target nohost" attributes.

2025-02-25  Jakub Jelinek  <jakub@redhat.com>

PR c++/118876
* cp-tree.h (register_dtor_fn): Add a bool argument defaulted to false.
* decl.cc (start_cleanup_fn): Add OMP_TARGET argument, use
"__omp_tcf" prefix rather than "__tcf" in that case.  Add
"omp declare target" and "omp declare target nohost" attributes
to the fndecl.
(register_dtor_fn): Add OMP_TARGET argument, pass it down to
start_cleanup_fn.
* decl2.cc (one_static_initialization_or_destruction): Add OMP_TARGET
argument, pass it down to register_dtor_fn.
(emit_partial_init_fini_fn): Pass omp_target to
one_static_initialization_or_destruction.
(handle_tls_init): Pass false to
one_static_initialization_or_destruction.

* g++.dg/gomp/pr118876.C: New test.
gcc/cp/cp-tree.h
gcc/cp/decl.cc
gcc/cp/decl2.cc
gcc/testsuite/g++.dg/gomp/pr118876.C [new file with mode: 0644]