public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] macros: Add base for execution tests for macros
@ 2022-06-08 12:06 Thomas Schwinge
0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-06-08 12:06 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:08dbb4e32263e611691dc73519b95a97e638fb41
commit 08dbb4e32263e611691dc73519b95a97e638fb41
Author: Arthur Cohen <arthur.cohen@embecosm.com>
Date: Wed Feb 16 02:14:03 2022 +0100
macros: Add base for execution tests for macros
Diff:
---
gcc/testsuite/rust/execute/xfail/macro1.rs | 32 +++++++++++++++++++++
gcc/testsuite/rust/execute/xfail/macro2.rs | 30 ++++++++++++++++++++
gcc/testsuite/rust/execute/xfail/macro3.rs | 45 ++++++++++++++++++++++++++++++
3 files changed, 107 insertions(+)
diff --git a/gcc/testsuite/rust/execute/xfail/macro1.rs b/gcc/testsuite/rust/execute/xfail/macro1.rs
new file mode 100644
index 00000000000..eab5a0285cf
--- /dev/null
+++ b/gcc/testsuite/rust/execute/xfail/macro1.rs
@@ -0,0 +1,32 @@
+// { dg-output "macro\nmacro\nmacro\nmacro\n" }
+extern "C" {
+ fn printf(s: *const i8, ...);
+}
+
+fn f() {
+ let r_s = "macro\n\0";
+ let s_p = r_s as *const str;
+ let c_p = s_p as *const i8;
+
+ printf(c_p);
+}
+
+macro_rules! empty0 {
+ () => ( f() );
+}
+
+macro_rules! empty1 {
+ {} => { f() };
+}
+
+macro_rules! empty2 {
+ [] => [ f() ];
+}
+
+// using multiple parens/brackets/curlies variants allows us to make sure we
+// parse everything properly
+fn main() {
+ empty0!();
+ empty1!{};
+ empty2![];
+}
diff --git a/gcc/testsuite/rust/execute/xfail/macro2.rs b/gcc/testsuite/rust/execute/xfail/macro2.rs
new file mode 100644
index 00000000000..49bd6a8c026
--- /dev/null
+++ b/gcc/testsuite/rust/execute/xfail/macro2.rs
@@ -0,0 +1,30 @@
+// { dg-output "arg\narg\n" }
+extern "C" {
+ fn printf(s: *const i8, ...);
+}
+
+fn f() {
+ let r_s = "arg\n\0";
+ let s_p = r_s as *const str;
+ let c_p = s_p as *const i8;
+
+ printf(c_p);
+}
+
+macro_rules! kw0 {
+ (keyword) => { f() };
+}
+
+macro_rules! kw1 {
+ (fn) => { f() };
+}
+
+macro_rules! kw2 {
+ (kw0 kw1 kw3) => { f() };
+}
+
+fn main() {
+ kw0!(keyword);
+ kw1!(fn);
+ kw2!(kw0 kw1 kw3);
+}
diff --git a/gcc/testsuite/rust/execute/xfail/macro3.rs b/gcc/testsuite/rust/execute/xfail/macro3.rs
new file mode 100644
index 00000000000..0d99d7165ac
--- /dev/null
+++ b/gcc/testsuite/rust/execute/xfail/macro3.rs
@@ -0,0 +1,45 @@
+// { dg-output "invok\ninvok\ninvok\ninvok\ninvok\n" }
+extern "C" {
+ fn printf(s: *const i8, ...);
+}
+
+fn f() {
+ let r_s = "invok\n\0";
+ let s_p = r_s as *const str;
+ let c_p = s_p as *const i8;
+
+ printf(c_p);
+}
+
+macro_rules! invocation0 {
+ (valid) => { f() };
+ () => { };
+}
+
+macro_rules! invocation1 {
+ (valid) => { };
+ () => { f() };
+}
+
+macro_rules! invocation2 {
+ (valid) => { f() };
+ (invalid) => { };
+}
+
+macro_rules! invocation3 {
+ (this is a valid invocation) => { f() };
+ (not this one) => { };
+}
+
+macro_rules! invocation4 {
+ (fn f() {}) => { f() };
+ (not a keyword) => { };
+}
+
+fn main() {
+ invocation0!(valid);
+ invocation1!();
+ invocation2!(valid);
+ invocation3!(this is a valid invocation);
+ invocation4!(fn f() {});
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-06-08 12:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-08 12:06 [gcc/devel/rust/master] macros: Add base for execution tests for macros Thomas Schwinge
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).