]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: Fix up handling of structured bindings in extract_locals_r [PR99833]
authorJakub Jelinek <jakub@redhat.com>
Fri, 16 Apr 2021 07:32:44 +0000 (09:32 +0200)
committerJakub Jelinek <jakub@redhat.com>
Fri, 16 Apr 2021 07:32:44 +0000 (09:32 +0200)
commit20eb7a1891cfd7fa85295a236cebe0322d041edd
tree8295c3ebe8356c2f3cb3b7fefb7c290f811dc355
parent76c7e7d6b003a17d183d0571bf9b34c691819d25
c++: Fix up handling of structured bindings in extract_locals_r [PR99833]

The following testcase ICEs in tsubst_decomp_names because the assumptions
that the structured binding artificial var is followed in DECL_CHAIN by
the corresponding structured binding vars is violated.
I've tracked it to extract_locals* which is done for the constexpr
IF_STMT.  extract_locals_r when it sees a DECL_EXPR adds that decl
into a hash set so that such decls aren't returned from extract_locals*,
but in the case of a structured binding that just means the artificial var
and not the vars corresponding to structured binding identifiers.
The following patch fixes it by pushing not just the artificial var
for structured bindings but also the other vars.

2021-04-16  Jakub Jelinek  <jakub@redhat.com>

PR c++/99833
* pt.c (extract_locals_r): When handling DECL_EXPR of a structured
binding, add to data.internal also all corresponding structured
binding decls.

* g++.dg/cpp1z/pr99833.C: New test.
* g++.dg/cpp2a/pr99833.C: New test.
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp1z/pr99833.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/pr99833.C [new file with mode: 0644]