]> 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)
committerThomas Schwinge <tschwinge@baylibre.com>
Fri, 25 Apr 2025 16:52:08 +0000 (18:52 +0200)
commitcaacc841ee735e094e3e7c3b8b067a969006b4df
tree40005a4177aa9a21aab399dc24c157f7b010ceaf
parent8b55d116b8f4c19696e534fb3a850a9beac396c4
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.

(cherry picked from commit 86a4af2793393e47af6b78cb7094c97914890091)
gcc/cp/ChangeLog.omp
gcc/cp/cp-tree.h
gcc/cp/decl.cc
gcc/cp/decl2.cc
gcc/testsuite/ChangeLog.omp
gcc/testsuite/g++.dg/gomp/pr118876.C [new file with mode: 0644]