public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Thomas Schwinge <tschwinge@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] macros: Add test cases for macro repetition separators Date: Wed, 8 Jun 2022 12:15:16 +0000 (GMT) [thread overview] Message-ID: <20220608121516.D5988398241D@sourceware.org> (raw) https://gcc.gnu.org/g:0c7e16e1258b67ba8efa1b019802bee4d802d4a5 commit 0c7e16e1258b67ba8efa1b019802bee4d802d4a5 Author: Arthur Cohen <arthur.cohen@embecosm.com> Date: Thu Mar 3 14:26:23 2022 +0100 macros: Add test cases for macro repetition separators Diff: --- gcc/testsuite/rust/compile/macro9.rs | 17 +++++++++++++++++ gcc/testsuite/rust/execute/torture/macros19.rs | 14 ++++++++++++++ gcc/testsuite/rust/execute/torture/macros20.rs | 14 ++++++++++++++ 3 files changed, 45 insertions(+) diff --git a/gcc/testsuite/rust/compile/macro9.rs b/gcc/testsuite/rust/compile/macro9.rs new file mode 100644 index 00000000000..9a59089b1e4 --- /dev/null +++ b/gcc/testsuite/rust/compile/macro9.rs @@ -0,0 +1,17 @@ +macro_rules! add { + ($e:expr, $($es:expr),*) => { + $e + add!($($es),*) + }; + ($e:expr) => { + $e + }; +} + +fn main() -> i32 { + let a = add!(15 2 9); // { dg-error "Failed to match any rule within macro" } + let b = add!(15); + let b = add!(15 14); // { dg-error "Failed to match any rule within macro" } + let b = add!(15, 14,); // { dg-error "Failed to match any rule within macro" } + + 0 +} diff --git a/gcc/testsuite/rust/execute/torture/macros19.rs b/gcc/testsuite/rust/execute/torture/macros19.rs new file mode 100644 index 00000000000..4732545410e --- /dev/null +++ b/gcc/testsuite/rust/execute/torture/macros19.rs @@ -0,0 +1,14 @@ +macro_rules! add { + ($e:expr, $($es:expr),*) => { + $e + add!($($es),*) + }; + ($e:expr) => { + $e + }; +} + +fn main() -> i32 { + let a = add!(15, 2, 9); // 26 + + a - 26 +} diff --git a/gcc/testsuite/rust/execute/torture/macros20.rs b/gcc/testsuite/rust/execute/torture/macros20.rs new file mode 100644 index 00000000000..fc116d089c4 --- /dev/null +++ b/gcc/testsuite/rust/execute/torture/macros20.rs @@ -0,0 +1,14 @@ +macro_rules! add { + ($e:expr big_tok $($es:expr) big_tok *) => { + $e + add!($($es) big_tok *) + }; + ($e:expr) => { + $e + }; +} + +fn main() -> i32 { + let a = add!(15 big_tok 2 big_tok 9); // 26 + + a - 26 +}
reply other threads:[~2022-06-08 12:15 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220608121516.D5988398241D@sourceware.org \ --to=tschwinge@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).