aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2022-03-30 09:38:51 +0200
committerJakub Jelinek <jakub@redhat.com>2022-03-30 09:38:51 +0200
commit410f39f56c14b195f066b9a18a3c6e8ffa03f848 (patch)
treece5fe4de63bebddd80bfa0910e73b46347de14e4 /gcc/cp
parent9778a7dc0b3000813a1d25669bf2735f38219650 (diff)
downloadgcc-410f39f56c14b195f066b9a18a3c6e8ffa03f848.zip
gcc-410f39f56c14b195f066b9a18a3c6e8ffa03f848.tar.gz
gcc-410f39f56c14b195f066b9a18a3c6e8ffa03f848.tar.bz2
openmp: Ensure DECL_CONTEXT of OpenMP iterators in templates [PR105092]
cp_parser_omp_iterators does: DECL_ARTIFICIAL (iter_var) = 1; DECL_CONTEXT (iter_var) = current_function_decl; pushdecl (iter_var); on the newly created iterator vars, but when we instantiate templates containing them, we just tsubst_decl them (which apparently for automatic vars clears DECL_CONTEXT with a comment that pushdecl should be called on them later). The result is that we have automatic vars in the IL which have NULL DECL_CONTEXT and the analyzer is upset about those. Fixed by setting DECL_CONTEXT and calling pushdecl during the instantiation. 2022-03-30 Jakub Jelinek <jakub@redhat.com> PR c++/105092 * pt.cc (tsubst_omp_clause_decl): When handling iterators, set DECL_CONTEXT of the iterator var to current_function_decl and call pushdecl. * g++.dg/gomp/pr105092.C: New test.
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/pt.cc2
1 files changed, 2 insertions, 0 deletions
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index ece839c..bdba5cf 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -17575,6 +17575,8 @@ tsubst_omp_clause_decl (tree decl, tree args, tsubst_flags_t complain,
*tp = copy_node (it);
TREE_VEC_ELT (*tp, 0)
= tsubst_decl (TREE_VEC_ELT (it, 0), args, complain);
+ DECL_CONTEXT (TREE_VEC_ELT (*tp, 0)) = current_function_decl;
+ pushdecl (TREE_VEC_ELT (*tp, 0));
TREE_VEC_ELT (*tp, 1)
= tsubst_expr (TREE_VEC_ELT (it, 1), args, complain, in_decl,
/*integral_constant_expression_p=*/false);