]> gcc.gnu.org Git - gcc.git/commit
c++: Incremental fix for g++.dg/gomp/for-21.C [PR84469]
authorJakub Jelinek <jakub@redhat.com>
Fri, 2 Dec 2022 09:30:16 +0000 (10:30 +0100)
committerJakub Jelinek <jakub@redhat.com>
Fri, 2 Dec 2022 09:30:16 +0000 (10:30 +0100)
commitf13305518558f20ef2d460a74eb29dad5fce1350
treeec07b437ca12940cf9fe14582ea3930ae786bd31
parentee4f25999f6832a1c5060b9277222c03d852709a
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  <jakub@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.
gcc/c-family/c-omp.cc
gcc/cp/parser.cc
gcc/testsuite/g++.dg/gomp/for-21.C
gcc/testsuite/g++.dg/gomp/for-22.C [new file with mode: 0644]
This page took 0.05646 seconds and 5 git commands to generate.