aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorSebastian Kirmayer <gnu@kirmayer.eu>2023-04-05 06:09:11 +0200
committerCohenArthur <arthur.cohen@embecosm.com>2023-04-14 12:53:54 +0000
commitcde6f8d9b531a129e2058c23729b74c976d08c4a (patch)
tree6f84615f6d07dadbf4dd8a0fdb7ac1098ae93def /gcc
parent2608859a394d28ddf6dc0f31954e252c7a562318 (diff)
downloadgcc-cde6f8d9b531a129e2058c23729b74c976d08c4a.zip
gcc-cde6f8d9b531a129e2058c23729b74c976d08c4a.tar.gz
gcc-cde6f8d9b531a129e2058c23729b74c976d08c4a.tar.bz2
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<ManagedTokenSource>::parse_macro_match_repetition): reject separator in `?` repetition gcc/testsuite/ChangeLog: * rust/compile/macro-issue2092.rs: New test. Signed-off-by: Sebastian Kirmayer <gnu@kirmayer.eu>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/parse/rust-parse-impl.h10
-rw-r--r--gcc/testsuite/rust/compile/macro-issue2092.rs4
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 38f68ba..85e044d 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),?) => {};
+}