aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Herron <herron.philip@googlemail.com>2023-03-29 22:27:38 +0100
committerPhilip Herron <philip.herron@embecosm.com>2023-04-19 21:12:08 +0000
commitab4931bf811646b8f6a46af024d8156c8c56e33f (patch)
treea9c5079c0557c86439e38a32e89e4bdff37ab12b
parent74b4d6ddf6758addd3b93985aa56382fa00c43e1 (diff)
downloadgcc-ab4931bf811646b8f6a46af024d8156c8c56e33f.zip
gcc-ab4931bf811646b8f6a46af024d8156c8c56e33f.tar.gz
gcc-ab4931bf811646b8f6a46af024d8156c8c56e33f.tar.bz2
gccrs: Add testcase to show matching of enum variants
Fixes #852 gcc/testsuite/ChangeLog: * rust/compile/issue-852.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
-rw-r--r--gcc/testsuite/rust/compile/issue-852.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/gcc/testsuite/rust/compile/issue-852.rs b/gcc/testsuite/rust/compile/issue-852.rs
new file mode 100644
index 0000000..763105d
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-852.rs
@@ -0,0 +1,30 @@
+// { dg-options "-w" }
+extern "C" {
+ fn printf(s: *const i8, ...);
+}
+
+enum Foo {
+ A,
+ B(i32),
+}
+
+fn main() {
+ let result = Foo::B(123);
+
+ match result {
+ A => unsafe {
+ let a = "A\n\0";
+ let b = a as *const str;
+ let c = b as *const i8;
+
+ printf(c);
+ },
+ Foo::B(x) => unsafe {
+ let a = "Result: %i\n\0";
+ let b = a as *const str;
+ let c = b as *const i8;
+
+ printf(c, x);
+ },
+ }
+}