https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105092
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:410f39f56c14b195f066b9a18a3c6e8ffa03f848 commit r12-7915-g410f39f56c14b195f066b9a18a3c6e8ffa03f848 Author: Jakub Jelinek <ja...@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 <ja...@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.