https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84469
--- Comment #9 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:f13305518558f20ef2d460a74eb29dad5fce1350 commit r13-4461-gf13305518558f20ef2d460a74eb29dad5fce1350 Author: Jakub Jelinek <ja...@redhat.com> Date: Fri Dec 2 10:30:16 2022 +0100 c++: Incremental fix for g++.dg/gomp/for-21.C [PR84469] The PR84469 patch I've just posted regresses the for-21.C testcase, when in OpenMP loop there are at least 2 associated loops and in a template outer structured binding with non type dependent expression is used in the expressions of some inner loop, we don't diagnose those any longer, as the (weirdly worded) diagnostics was only done during finish_id_expression -> mark_used which for the inner loop expressions happens before the structured bindings are finalized. When in templates, mark_used doesn't diagnose uses of non-deduced variables, and if the range for expression is type dependent, it is similarly diagnosed during instantiation. But newly with the PR84469 fix if the range for expression is not type dependent, there is no place that would diagnose it, as during instantiation the structured bindings are already deduced. This patch ensures that the bug of using structured bindings from one associated loop in other associated loops is diagnosed by the c_omp_check_loop_iv code by ensuring that cp_finish_decomp is called already during cp_convert_omp_range_for if the artificial iterator has been successfully auto-deduced. 2022-12-02 Jakub Jelinek <ja...@redhat.com> PR c++/84469 gcc/c-family/ * c-omp.cc (c_omp_is_loop_iterator): For range for with structured binding return TREE_VEC_LENGTH (d->declv) even if decl is equal to any of the structured binding decls. gcc/cp/ * parser.cc (cp_convert_omp_range_for): After do_auto_deduction if !processing_template_decl call cp_finish_decomp with processing_template_decl temporarily incremented. gcc/testsuite/ * g++.dg/gomp/for-21.C (f3, f6, f9): Adjust expected diagnostics. * g++.dg/gomp/for-22.C: New test.