about summary refs log tree commit diff
path: root/compiler/rustc_codegen_gcc/tests/run/float.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-04-19 01:12:39 +0000
committerbors <bors@rust-lang.org>2025-04-19 01:12:39 +0000
commit2ef78586529b5f68cc42bcbe9b10b4afe56a942a (patch)
tree2c3fde3eac0a3f91ec51ab95e6df19f7c1cd992f /compiler/rustc_codegen_gcc/tests/run/float.rs
parent191df20fcad9331d3a948aa8e8556775ec3fe69d (diff)
parentcc359b8bb6c693086f69adf013430163992b1807 (diff)
downloadrust-2ef78586529b5f68cc42bcbe9b10b4afe56a942a.tar.gz
rust-2ef78586529b5f68cc42bcbe9b10b4afe56a942a.zip
Auto merge of #140015 - GuillaumeGomez:subtree-update_cg_gcc_2025-04-18, r=antoyo
Subtree update GCC backend

cc `@antoyo`
Diffstat (limited to 'compiler/rustc_codegen_gcc/tests/run/float.rs')
-rw-r--r--compiler/rustc_codegen_gcc/tests/run/float.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/compiler/rustc_codegen_gcc/tests/run/float.rs b/compiler/rustc_codegen_gcc/tests/run/float.rs
new file mode 100644
index 00000000000..424fa1cf4ad
--- /dev/null
+++ b/compiler/rustc_codegen_gcc/tests/run/float.rs
@@ -0,0 +1,28 @@
+// Compiler:
+//
+// Run-time:
+//   status: 0
+
+#![feature(const_black_box)]
+
+fn main() {
+    use std::hint::black_box;
+
+    macro_rules! check {
+        ($ty:ty, $expr:expr) => {{
+            const EXPECTED: $ty = $expr;
+            assert_eq!($expr, EXPECTED);
+        }};
+    }
+
+    check!(i32, (black_box(0.0f32) as i32));
+
+    check!(u64, (black_box(f32::NAN) as u64));
+    check!(u128, (black_box(f32::NAN) as u128));
+
+    check!(i64, (black_box(f64::NAN) as i64));
+    check!(u64, (black_box(f64::NAN) as u64));
+
+    check!(i16, (black_box(f32::MIN) as i16));
+    check!(i16, (black_box(f32::MAX) as i16));
+}