public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-7915] openmp: Ensure DECL_CONTEXT of OpenMP iterators in templates [PR105092] Date: Wed, 30 Mar 2022 07:41:54 +0000 (GMT) [thread overview] Message-ID: <20220330074154.E5A283858403@sourceware.org> (raw) https://gcc.gnu.org/g:410f39f56c14b195f066b9a18a3c6e8ffa03f848 commit r12-7915-g410f39f56c14b195f066b9a18a3c6e8ffa03f848 Author: Jakub Jelinek <jakub@redhat.com> Date: Wed Mar 30 09:38:51 2022 +0200 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. Diff: --- gcc/cp/pt.cc | 2 ++ gcc/testsuite/g++.dg/gomp/pr105092.C | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index ece839c22e3..bdba5cf3b85 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); diff --git a/gcc/testsuite/g++.dg/gomp/pr105092.C b/gcc/testsuite/g++.dg/gomp/pr105092.C new file mode 100644 index 00000000000..5f4e38aae40 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr105092.C @@ -0,0 +1,26 @@ +// PR c++/105092 +// { dg-do compile { target analyzer } } +// { dg-options "-fanalyzer -fopenmp" } + +struct S { S () {} }; + +template <typename T> +struct U { + T c[10]; + U () { +#pragma omp task affinity (iterator (i = 0 : 10 : 1): c[i]) + ; + } +}; + +template <typename T> +struct V { + T c[10]; + V () { +#pragma omp task depend (iterator (i = 0 : 10 : 1), inout: c[i]) + ; + } +}; + +U<S> u; +V<S> v;
reply other threads:[~2022-03-30 7:41 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220330074154.E5A283858403@sourceware.org \ --to=jakub@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).