summaryrefslogtreecommitdiffstats
path: root/src/test/ui/mir/simplify-branch-same.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/test/ui/mir/simplify-branch-same.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/test/ui/mir/simplify-branch-same.rs b/src/test/ui/mir/simplify-branch-same.rs
new file mode 100644
index 000000000..d631c33d6
--- /dev/null
+++ b/src/test/ui/mir/simplify-branch-same.rs
@@ -0,0 +1,21 @@
+// Regression test for SimplifyBranchSame miscompilation.
+// run-pass
+
+macro_rules! m {
+ ($a:expr, $b:expr, $c:block) => {
+ match $a {
+ Lto::Fat | Lto::Thin => { $b; (); $c }
+ Lto::No => { $b; () }
+ }
+ }
+}
+
+pub enum Lto { No, Thin, Fat }
+
+fn f(mut cookie: u32, lto: Lto) -> u32 {
+ let mut _a = false;
+ m!(lto, _a = true, {cookie = 0});
+ cookie
+}
+
+fn main() { assert_eq!(f(42, Lto::Thin), 0) }