From cde6f8d9b531a129e2058c23729b74c976d08c4a Mon Sep 17 00:00:00 2001 From: Sebastian Kirmayer Date: Wed, 5 Apr 2023 06:09:11 +0200 Subject: parser: macro: reject separator in `?` repetition A matcher like $(a),? is no longer accepted. Fixes #2092. gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_macro_match_repetition): reject separator in `?` repetition gcc/testsuite/ChangeLog: * rust/compile/macro-issue2092.rs: New test. Signed-off-by: Sebastian Kirmayer --- gcc/rust/parse/rust-parse-impl.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'gcc/rust') diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index 38f68ba..85e044d 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -2261,6 +2261,16 @@ Parser::parse_macro_match_repetition () case QUESTION_MARK: op = AST::MacroMatchRepetition::ZERO_OR_ONE; lexer.skip_token (); + + if (separator != nullptr) + { + add_error ( + Error (separator->get_locus (), + "the % macro repetition operator does not take a " + "separator")); + separator = nullptr; + } + break; default: add_error ( -- cgit v1.1