]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Remove direct error on macro rule count-related match failure
authorOwen Avery <powerboat9.gamer@gmail.com>
Mon, 12 Jun 2023 20:17:09 +0000 (16:17 -0400)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:46:27 +0000 (18:46 +0100)
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 <powerboat9.gamer@gmail.com>
gcc/rust/expand/rust-macro-expand.cc
gcc/testsuite/rust/compile/macro-issue2229.rs [new file with mode: 0644]
gcc/testsuite/rust/compile/macro6.rs
gcc/testsuite/rust/compile/macro7.rs

index 47384dfffdeb7cb1b06f705485b6f93d9c73e4cd..a92bbdcb943371afd38310a7cdbc548917a23e88 100644 (file)
@@ -694,13 +694,6 @@ MacroExpander::match_repetition (Parser<MacroInvocLexer> &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 (file)
index 0000000..c148ff5
--- /dev/null
@@ -0,0 +1,6 @@
+macro_rules! foo {
+    ($(+)+) => {e};
+    () => {}
+}
+
+foo!();
index 0ca35ba688848e37c3bf7c5752fdb50a9164f400..9c54a674533d4744455fd8d6ff6b4c771c92bb41 100644 (file)
@@ -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();
     }
 }
index abc48057c5458cc958ad45f4a1b996dac7363cac..563acddb867303b2d96576000cf452bacdc9d182 100644 (file)
@@ -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();
     };
 }