https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124483
--- Comment #1 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Nathaniel Shead <[email protected]>: https://gcc.gnu.org/g:e20b3ae5e7cdda45582fa09b7dc9c7840ed8f079 commit r16-8241-ge20b3ae5e7cdda45582fa09b7dc9c7840ed8f079 Author: Nathaniel Shead <[email protected]> Date: Thu Mar 19 22:56:20 2026 +1100 c++/modules: Handle maybe_unused on PARM_DECLs [PR124483] The [[maybe_unused]] attribute works by marking relevant entities as TREE_USED, and DECL_READ_P for vars and parms. But modules streaming typically clears this flag unless reading a definition. This patch sets it back again when we see this attribute applied to a parameter. PR c++/124483 gcc/cp/ChangeLog: * module.cc (trees_in::fn_parms_init): Set TREE_USED and DECL_READ_P for parameters deliberately marked unused. gcc/testsuite/ChangeLog: * g++.dg/modules/attrib-4_a.C: New test. * g++.dg/modules/attrib-4_b.C: New test. Signed-off-by: Nathaniel Shead <[email protected]> Reviewed-by: Jason Merrill <[email protected]>
