[Bug c++/122788] [[maybe_unused]] ignored in expansion statement

2025-11-22 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122788

Jakub Jelinek  changed:

   What|Removed |Added

 Resolution|--- |FIXED
   Target Milestone|--- |16.0
 Status|ASSIGNED|RESOLVED

--- Comment #5 from Jakub Jelinek  ---
Fixed.

[Bug c++/122788] [[maybe_unused]] ignored in expansion statement

2025-11-22 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122788

--- Comment #4 from GCC Commits  ---
The master branch has been updated by Jakub Jelinek :

https://gcc.gnu.org/g:cf865c811be1b83e960b3e661123cb19105d3181

commit r16-5507-gcf865c811be1b83e960b3e661123cb19105d3181
Author: Jakub Jelinek 
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  

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.

[Bug c++/122788] [[maybe_unused]] ignored in expansion statement

2025-11-21 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122788

Jakub Jelinek  changed:

   What|Removed |Added

 Status|UNCONFIRMED |ASSIGNED
   Last reconfirmed||2025-11-21
   Assignee|unassigned at gcc dot gnu.org  |jakub at gcc dot gnu.org
 Ever confirmed|0   |1

--- Comment #3 from Jakub Jelinek  ---
Created attachment 62872
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=62872&action=edit
gcc16-pr122788.patch

Untested fix.

[Bug c++/122788] [[maybe_unused]] ignored in expansion statement

2025-11-21 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122788

Andrew Pinski  changed:

   What|Removed |Added

   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=77419

--- Comment #2 from Andrew Pinski  ---
Maybe related to PR 77419.

[Bug c++/122788] [[maybe_unused]] ignored in expansion statement

2025-11-21 Thread mkretz at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122788

--- Comment #1 from Matthias Kretz (Vir)  ---
Similar/related test case (https://compiler-explorer.com/z/3Wv3dxnG1):

void f()
{
template for (constexpr auto i : {1})
{
if constexpr (false) (void)i;
}
}