about summary refs log tree commit diff
path: root/tests/codegen
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2023-02-11 08:59:19 +0000
committerCamille GILLOT <gillot.camille@gmail.com>2023-02-18 21:35:02 +0000
commit86dbcb53907037dcc3fabb635956aec2c384b4e9 (patch)
treedb0c1372c953b1144f8d30c5c57399007e43f251 /tests/codegen
parente34caaf42dd10b3cb8d14e6e99c2c8687fe6342e (diff)
downloadrust-86dbcb53907037dcc3fabb635956aec2c384b4e9.tar.gz
rust-86dbcb53907037dcc3fabb635956aec2c384b4e9.zip
Add codegen test.
Diffstat (limited to 'tests/codegen')
-rw-r--r--tests/codegen/inherit_overflow.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/codegen/inherit_overflow.rs b/tests/codegen/inherit_overflow.rs
new file mode 100644
index 00000000000..d938dadb9c7
--- /dev/null
+++ b/tests/codegen/inherit_overflow.rs
@@ -0,0 +1,14 @@
+// compile-flags: -Zmir-enable-passes=+Inline,+ConstProp --crate-type lib
+// revisions: ASSERT NOASSERT
+//[ASSERT] compile-flags: -Coverflow-checks=on
+//[NOASSERT] compile-flags: -Coverflow-checks=off
+
+// CHECK-LABEL: define{{.*}} @assertion
+// ASSERT: tail call void @_ZN4core9panicking5panic17h
+// NOASSERT: ret i8 0
+#[no_mangle]
+pub fn assertion() -> u8 {
+    // Optimized MIR will replace this `CheckedBinaryOp` by `const (0, true)`.
+    // Verify that codegen does or does not emit the panic.
+    <u8 as std::ops::Add>::add(255, 1)
+}