about summary refs log tree commit diff
path: root/tests/codegen/enum
diff options
context:
space:
mode:
authorThe Miri Cronjob Bot <miri@cron.bot>2024-03-09 05:01:38 +0000
committerThe Miri Cronjob Bot <miri@cron.bot>2024-03-09 05:01:38 +0000
commite720147bf527dfe837ec1161853b3e28a238202d (patch)
treed597a7cbe6c865a5b289dc559e06fadd054124a3 /tests/codegen/enum
parent52db5f6cdc8d1e7c6270f9d2ce926d70ac706431 (diff)
parent4d4bb491b65c300835442f6cb4f34fc9a5685c26 (diff)
downloadrust-e720147bf527dfe837ec1161853b3e28a238202d.tar.gz
rust-e720147bf527dfe837ec1161853b3e28a238202d.zip
Merge from rustc
Diffstat (limited to 'tests/codegen/enum')
-rw-r--r--tests/codegen/enum/uninhabited_enum_default_branch.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/codegen/enum/uninhabited_enum_default_branch.rs b/tests/codegen/enum/uninhabited_enum_default_branch.rs
new file mode 100644
index 00000000000..5f318f18dec
--- /dev/null
+++ b/tests/codegen/enum/uninhabited_enum_default_branch.rs
@@ -0,0 +1,24 @@
+//@ compile-flags: -O
+
+#![crate_type = "lib"]
+
+#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
+pub struct Int(u32);
+
+const A: Int = Int(201);
+const B: Int = Int(270);
+const C: Int = Int(153);
+
+// CHECK-LABEL: @foo(
+// CHECK-SAME: [[TMP0:%.*]])
+// CHECK-NEXT:  start:
+// CHECK-NEXT:    [[TMP1:%.*]] = add i32 [[TMP0]], -201
+// CHECK-NEXT:    icmp ult i32 [[TMP1]], 70
+// CHECK-NEXT:    icmp eq i32 [[TMP0]], 153
+// CHECK-NEXT:    [[SPEC_SELECT:%.*]] = or i1
+// CHECK-NEXT:    ret i1 [[SPEC_SELECT]]
+#[no_mangle]
+pub fn foo(x: Int) -> bool {
+    (x >= A && x <= B)
+        || x == C
+}