[COMMITTED 44/77] gccrs: Fix duplicate "trailing semicolon in macro used" warnings
| Newsgroups | gmane.comp.gcc.rust,gmane.comp.gcc.patches |
|---|---|
| Message-ID | <[email protected]> |
From: Yap Zhi Heng <[email protected]> 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]> --- 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 2ab9d2541dc..30373722e8c 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 (); } -- 2.50.1