public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] Add a test for the cfg!() macro
@ 2022-06-08 12:33 Thomas Schwinge
0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-06-08 12:33 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:9a56a0d10d991d066188dedb89d19119146a17a0
commit 9a56a0d10d991d066188dedb89d19119146a17a0
Author: antego <antego@users.noreply.github.com>
Date: Wed Apr 13 20:00:54 2022 +1000
Add a test for the cfg!() macro
See #1116 and #1039
Diff:
---
.../rust/execute/torture/builtin_macro_cfg.rs | 27 ++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/gcc/testsuite/rust/execute/torture/builtin_macro_cfg.rs b/gcc/testsuite/rust/execute/torture/builtin_macro_cfg.rs
new file mode 100644
index 00000000000..ac24791bd6a
--- /dev/null
+++ b/gcc/testsuite/rust/execute/torture/builtin_macro_cfg.rs
@@ -0,0 +1,27 @@
+// { dg-additional-options "-w -frust-cfg=A" }
+// { dg-output "A\n" }
+macro_rules! cfg {
+ () => {{}};
+}
+
+extern "C" {
+ fn printf(fmt: *const i8, ...);
+}
+
+fn print(s: &str) {
+ printf("%s\n" as *const str as *const i8, s as *const str as *const i8);
+}
+
+
+fn main() -> i32 {
+ let cfg = cfg!(A);
+ if cfg {
+ print("A");
+ }
+ let cfg = cfg!(B);
+ if cfg {
+ print("B");
+ }
+
+ 0
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-06-08 12:33 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:33 [gcc/devel/rust/master] Add a test for the cfg!() macro 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).