From 1119902b6c7c1c50123ed85ec1def8be4772d68c Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 21 Dec 2022 09:05:27 +0100 Subject: openmp: Don't try to destruct DECL_OMP_PRIVATIZED_MEMBER vars [PR108180] DECL_OMP_PRIVATIZED_MEMBER vars are artificial vars with DECL_VALUE_EXPR of this->field used just during gimplification and omp lowering/expansion to privatize individual fields in methods when needed. As the following testcase shows, when not in templates, they were handled right, but in templates we actually called cp_finish_decl on them and that can result in their destruction, which is obviously undesirable, we should only destruct the privatized copies of them created in omp lowering. Fixed thusly. 2022-12-21 Jakub Jelinek PR c++/108180 * pt.cc (tsubst_expr): Don't call cp_finish_decl on DECL_OMP_PRIVATIZED_MEMBER vars. * testsuite/libgomp.c++/pr108180.C: New test. --- gcc/cp/pt.cc | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gcc') diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 2d90298..e68c749 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -18874,6 +18874,11 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl) maybe_push_decl (decl); if (VAR_P (decl) + && DECL_LANG_SPECIFIC (decl) + && DECL_OMP_PRIVATIZED_MEMBER (decl)) + break; + + if (VAR_P (decl) && DECL_DECOMPOSITION_P (decl) && TREE_TYPE (pattern_decl) != error_mark_node) ndecl = tsubst_decomp_names (decl, pattern_decl, args, -- cgit v1.1