]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: Fix up handling of name independent structured binding packs [PR117783]
authorJakub Jelinek <jakub@redhat.com>
Mon, 11 Aug 2025 07:02:38 +0000 (09:02 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 11 Aug 2025 07:05:45 +0000 (09:05 +0200)
commitb7e4b5e862fcb12cfeaa3bee4e8c77098201d5f4
tree919ac6c1c1c093ffcfd0df25c6ad1a8f7ddfced8
parent5274f490fa72830aafd278bc752145f1225b08e0
c++: Fix up handling of name independent structured binding packs [PR117783]

I've realized I haven't added testsuite coverage for name independent
structured binding packs.  And the
  auto [i, ..._, j] = T {};
  auto [k, ..._, l] = T {};
case shows a problem with that.  The elements of the structured binding
pack have #i appended to their names, so for the _ case e.g. _#0, _#1
etc. (to print something useful in diagnostics, perhaps debug info later
on).  The above is valid though as long as one doesn't use _ (which is
ambiguous), but we were emitting errors on redeclaration of _#0, _#1
etc.

The following patch uses DECL_NAME (decl) = NULL_TREE; for the
name independent decl case so that the false positive redeclaration
errors aren't emitted.

2025-08-11  Jakub Jelinek  <jakub@redhat.com>

PR c++/117783
* decl.cc (set_sb_pack_name): For name independent decls
just clear DECL_NAME instead of appending #i to it.

* g++.dg/cpp26/name-independent-decl11.C: New test.
gcc/cp/decl.cc
gcc/testsuite/g++.dg/cpp26/name-independent-decl11.C [new file with mode: 0644]