From: Owen Avery Date: Mon, 12 Jun 2023 20:17:09 +0000 (-0400) Subject: gccrs: Remove direct error on macro rule count-related match failure X-Git-Tag: basepoints/gcc-15~2465 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=99894a81392fb83aa8886884f70d76b24f048c45;p=thirdparty%2Fgcc.git gccrs: 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 --- diff --git a/gcc/rust/expand/rust-macro-expand.cc b/gcc/rust/expand/rust-macro-expand.cc index 47384dfffdeb..a92bbdcb9433 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 000000000000..c148ff5d270f --- /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 0ca35ba68884..9c54a674533d 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 abc48057c545..563acddb8673 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(); }; }