https://gcc.gnu.org/g:1bf052967ce09aca7cb20b35a85b7e4a07f147d7
commit r17-3103-g1bf052967ce09aca7cb20b35a85b7e4a07f147d7 Author: Yap Zhi Heng <[email protected]> Date: Mon Jul 6 19:51:31 2026 +0800 gccrs: Fix duplicate "trailing semicolon in macro used" warnings gcc/rust/ChangeLog: * expand/rust-macro-expand.cc (transcribe_expression (Parser<MacroInvocLexer>)): Prevent the same trailing semicolon warning from being generated at the same loc. Signed-Off-By: Yap Zhi Heng <[email protected]> Diff: --- gcc/rust/expand/rust-macro-expand.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gcc/rust/expand/rust-macro-expand.cc b/gcc/rust/expand/rust-macro-expand.cc index 2ab9d2541dcb..30373722e8c8 100644 --- a/gcc/rust/expand/rust-macro-expand.cc +++ b/gcc/rust/expand/rust-macro-expand.cc @@ -1012,9 +1012,14 @@ transcribe_expression (Parser<MacroInvocLexer> &parser) // FIXME: make this an error for some edititons if (parser.peek_current_token ()->get_id () == SEMICOLON) { - rust_warning_at ( - parser.peek_current_token ()->get_locus (), 0, - "trailing semicolon in macro used in expression context"); + // TODO bandaid for now, make this a member for MacroExpander instead in + // the future + static std::unordered_set<location_t> warned_loc; + auto locus = parser.peek_current_token ()->get_locus (); + if (warned_loc.insert (locus).second) + rust_warning_at ( + parser.peek_current_token ()->get_locus (), 0, + "trailing semicolon in macro used in expression context"); parser.skip_token (); }
