diff options
-rw-r--r-- | gcc/rust/parse/rust-parse-impl.h | 10 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/macro-issue2092.rs | 4 |
2 files changed, 14 insertions, 0 deletions
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index e636252..6d20f48 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -2261,6 +2261,16 @@ Parser<ManagedTokenSource>::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 ( diff --git a/gcc/testsuite/rust/compile/macro-issue2092.rs b/gcc/testsuite/rust/compile/macro-issue2092.rs new file mode 100644 index 0000000..ec20743 --- /dev/null +++ b/gcc/testsuite/rust/compile/macro-issue2092.rs @@ -0,0 +1,4 @@ +macro_rules! foo { + // { dg-error "does not take a separator" "#2092" { target *-*-*} .+1 } + ($(a),?) => {}; +} |