]> gcc.gnu.org Git - gcc.git/commit
c++: Deduce range for structured bindings if expression is not type dependent [PR84469]
authorJakub Jelinek <jakub@redhat.com>
Fri, 2 Dec 2022 09:29:11 +0000 (10:29 +0100)
committerJakub Jelinek <jakub@redhat.com>
Fri, 2 Dec 2022 09:29:11 +0000 (10:29 +0100)
commitee4f25999f6832a1c5060b9277222c03d852709a
treef0933f33052f8dcf265e4da2785ecf6d3362633c
parent6508d5e5a1a8c08bebf83d258fad525eadc9f5d1
c++: Deduce range for structured bindings if expression is not type dependent [PR84469]

As shown on the decomp56.C testcase, if the range for expression
when using structured bindings is not type dependent, we deduce
the finish the structured binding types only when not in template
(cp_convert_range_for takes care of that), but if in templates,
do_range_for_auto_deduction is called instead and it doesn't handle
structured bindings.  During instantiation they are handled later,
but during the parsing keeping the structured bindings type
dependent when they shouldn't be changes behavior.
The following patch calls cp_finish_decomp even from
do_range_for_auto_deduction.
The patch regresses the OpenMP g++.dg/gomp/for-21.C test (3 errors
are gone), I'll post an incremental patch for it momentarily.

2022-12-02  Jakub Jelinek  <jakub@redhat.com>

PR c++/84469
* parser.cc (do_range_for_auto_deduction): Add DECOMP_FIRST_NAME
and DECOMP_CNT arguments.  Call cp_finish_decomp if DECL
is a structured binding.
(cp_parser_range_for): Adjust do_range_for_auto_deduction caller.
(cp_convert_omp_range_for): Likewise.

* g++.dg/cpp1z/decomp56.C: New test.
* g++.dg/gomp/pr84469.C: New test.
gcc/cp/parser.cc
gcc/testsuite/g++.dg/cpp1z/decomp56.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/pr84469.C [new file with mode: 0644]
This page took 0.058559 seconds and 5 git commands to generate.