aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/rust
diff options
context:
space:
mode:
authorbadumbatish <tanghocle456@gmail.com>2024-08-02 11:36:04 -0700
committerArthur Cohen <arthur.cohen@embecosm.com>2025-03-19 15:32:07 +0100
commit8b810b2c5d0e880759280bfa63afe2494d85ff8a (patch)
tree3791ef1ac2a878b8fed3dc26cbaa902302926caf /gcc/testsuite/rust
parent0bad7500da4f08d03e668cbba8935a9f0803664c (diff)
downloadgcc-8b810b2c5d0e880759280bfa63afe2494d85ff8a.zip
gcc-8b810b2c5d0e880759280bfa63afe2494d85ff8a.tar.gz
gcc-8b810b2c5d0e880759280bfa63afe2494d85ff8a.tar.bz2
gccrs: Added noreturn checking for nevertype, new test
gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Added noreturn checking for nevertype gcc/testsuite/ChangeLog: * rust/compile/inline_asm_typecheck.rs: New test.
Diffstat (limited to 'gcc/testsuite/rust')
-rw-r--r--gcc/testsuite/rust/compile/inline_asm_typecheck.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/gcc/testsuite/rust/compile/inline_asm_typecheck.rs b/gcc/testsuite/rust/compile/inline_asm_typecheck.rs
new file mode 100644
index 0000000..22b7fb1
--- /dev/null
+++ b/gcc/testsuite/rust/compile/inline_asm_typecheck.rs
@@ -0,0 +1,21 @@
+#![feature(rustc_attrs)]
+
+#[rustc_builtin_macro]
+macro_rules! asm {
+ () => {};
+}
+
+fn main() {
+ let mut _num1: i32 = 10;
+ let mut _num2: i32 = 10;
+ unsafe {
+ // This demonstrates that asm!'s is inferred with a unit type is parsed correctly.
+ let _ = asm!("nop");
+
+ // This errors out per rust spec
+ // The asm! block never returns, and its return type is defined as ! (never).
+ // Behavior is undefined if execution falls through past the end of the asm code.
+ // A noreturn asm block behaves just like a function which doesn't return; notably, local variables in scope are not dropped before it is invoked.
+ let _ = asm!("nop", options(noreturn));
+ }
+}