From 7671253eda836193313586013e92dde3d14f5ebe Mon Sep 17 00:00:00 2001 From: Owen Avery Date: Mon, 12 Jun 2023 16:17:09 -0400 Subject: Remove direct error on macro rule count-related match failure gcc/rust/ChangeLog: * expand/rust-macro-expand.cc (MacroExpander::match_repetition): Remove redundant rust_error_at call. gcc/testsuite/ChangeLog: * rust/compile/macro6.rs: Remove check for direct error. * rust/compile/macro7.rs: Likewise. * rust/compile/macro-issue2229.rs: New test. Signed-off-by: Owen Avery --- gcc/rust/expand/rust-macro-expand.cc | 7 ------- gcc/testsuite/rust/compile/macro-issue2229.rs | 6 ++++++ gcc/testsuite/rust/compile/macro6.rs | 2 +- gcc/testsuite/rust/compile/macro7.rs | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) create mode 100644 gcc/testsuite/rust/compile/macro-issue2229.rs (limited to 'gcc') diff --git a/gcc/rust/expand/rust-macro-expand.cc b/gcc/rust/expand/rust-macro-expand.cc index 00a0a5f..9858049 100644 --- a/gcc/rust/expand/rust-macro-expand.cc +++ b/gcc/rust/expand/rust-macro-expand.cc @@ -694,13 +694,6 @@ MacroExpander::match_repetition (Parser &parser, gcc_unreachable (); } - if (!res) - rust_error_at (rep.get_match_locus (), - "invalid amount of matches for macro invocation. Expected " - "between %s and %s, got %lu", - lo_str.c_str (), hi_str.c_str (), - (unsigned long) match_amount); - rust_debug_loc (rep.get_match_locus (), "%s matched %lu times", res ? "successfully" : "unsuccessfully", (unsigned long) match_amount); diff --git a/gcc/testsuite/rust/compile/macro-issue2229.rs b/gcc/testsuite/rust/compile/macro-issue2229.rs new file mode 100644 index 0000000..c148ff5 --- /dev/null +++ b/gcc/testsuite/rust/compile/macro-issue2229.rs @@ -0,0 +1,6 @@ +macro_rules! foo { + ($(+)+) => {e}; + () => {} +} + +foo!(); diff --git a/gcc/testsuite/rust/compile/macro6.rs b/gcc/testsuite/rust/compile/macro6.rs index 0ca35ba..9c54a67 100644 --- a/gcc/testsuite/rust/compile/macro6.rs +++ b/gcc/testsuite/rust/compile/macro6.rs @@ -1,5 +1,5 @@ macro_rules! zero_or_one { - ($($a:literal)?) => { // { dg-error "invalid amount of matches for macro invocation. Expected between 0 and 1, got 2" } + ($($a:literal)?) => { f(); } } diff --git a/gcc/testsuite/rust/compile/macro7.rs b/gcc/testsuite/rust/compile/macro7.rs index abc4805..563acdd 100644 --- a/gcc/testsuite/rust/compile/macro7.rs +++ b/gcc/testsuite/rust/compile/macro7.rs @@ -1,7 +1,7 @@ fn f() {} macro_rules! one_or_more { - ($($a:literal)+) => { // { dg-error "invalid amount of matches for macro invocation" } + ($($a:literal)+) => { f(); }; } -- cgit v1.1