[Bug c++/122788] [[maybe_unused]] ignored in expansion statement
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sat Nov 22 11:39:44 GMT 2025
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122788
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:cf865c811be1b83e960b3e661123cb19105d3181
commit r16-5507-gcf865c811be1b83e960b3e661123cb19105d3181
Author: Jakub Jelinek <jakub@redhat.com>
Date: Sat Nov 22 12:39:09 2025 +0100
c++: Fix up [[maybe_unused]] handling on expansion stmts [PR122788]
This PR complains that [[maybe_unused]] attribute is ignored on
the range-for-declaration of expansion-statement.
We copy DECL_ATTRIBUTES and apply late attributes, but early attributes
don't have their handlers called again, so some extra flags need to be
copied as well.
This copies TREE_USED and DECL_READ_P flags.
2025-11-22 Jakub Jelinek <jakub@redhat.com>
PR c++/122788
* pt.cc (finish_expansion_stmt): Or in TREE_USED and DECL_READ_P
flags from range_decl to decl or from corresponding structured
binding
to this_decl.
* g++.dg/cpp26/expansion-stmt27.C: New test.
More information about the Gcc-bugs
mailing list