diff options
author | Jakub Jelinek <jakub@redhat.com> | 2025-03-20 09:06:17 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2025-03-20 09:06:17 +0100 |
commit | e0b3eeb67f6d3bfe95591d8fb0c7dfd3f1b3b4ef (patch) | |
tree | d3a2d0e18e921319a124cb1602c0807a854ffd2a /gcc/testsuite/rust/compile/struct-expr-parse.rs | |
parent | 62a6cafd7f55c6e88a9780b91039257572038535 (diff) | |
download | gcc-e0b3eeb67f6d3bfe95591d8fb0c7dfd3f1b3b4ef.zip gcc-e0b3eeb67f6d3bfe95591d8fb0c7dfd3f1b3b4ef.tar.gz gcc-e0b3eeb67f6d3bfe95591d8fb0c7dfd3f1b3b4ef.tar.bz2 |
openmp: Fix up cloning of dynamic C++ initializers for OpenMP target [PR119370]
The following testcase ICEs, because we emit the dynamic initialization twice,
once for host and once for target initialization, and although we use
copy_tree_body_r to unshare it, e.g. for the array initializers it can contain
TARGET_EXPRs with local temporaries (or local temporaries alone).
Now, these temporaries were created when current_function_decl was NULL,
they are outside of any particular function, so they have DECL_CONTEXT NULL.
That is normally fine, gimple_add_tmp_var will set DECL_CONTEXT for them
later on to the host __static_init* function into which they are gimplified.
The problem is that the copy_tree_body_r cloning happens before that (and has
to, gimplification is destructive and so we couldn't gimplify the same tree
again in __omp_static_init* function) and uses auto_var_in_fn_p to see what
needs to be remapped. But that means it doesn't remap temporaries with
NULL DECL_CONTEXT and having the same temporaries in two different functions
results in ICEs (sure, one can e.g. use parent function's temporaries in a
nested function).
The following patch just arranges to set DECL_CONTEXT on the temporaries
to the host dynamic initialization function, so that they get remapped.
If gimplification cared whether DECL_CONTEXT is NULL or not, we could
remember those that we've changed in a vector and undo it afterwards,
but seems it doesn't really care.
2025-03-20 Jakub Jelinek <jakub@redhat.com>
PR c++/119370
* decl2.cc (set_context_for_auto_vars_r): New function.
(emit_partial_init_fini_fn): Call walk_tree with that function
on &init before walk_tree with copy_tree_body_r.
* g++.dg/gomp/pr119370.C: New test.
Diffstat (limited to 'gcc/testsuite/rust/compile/struct-expr-parse.rs')
0 files changed, 0 insertions, 0 deletions