]>
Commit | Line | Data |
---|---|---|
416331ca XL |
1 | // run-pass |
2 | ||
ba9703b0 | 3 | #![feature(llvm_asm)] |
0bf4aa26 | 4 | #![allow(dead_code)] |
ff7c6d11 XL |
5 | |
6 | use std::cell::Cell; | |
7 | ||
8 | #[repr(C)] | |
9 | struct NoisyDrop<'a>(&'a Cell<&'static str>); | |
10 | impl<'a> Drop for NoisyDrop<'a> { | |
11 | fn drop(&mut self) { | |
12 | self.0.set("destroyed"); | |
13 | } | |
14 | } | |
15 | ||
16 | #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] | |
17 | fn main() { | |
18 | let status = Cell::new("alive"); | |
19 | { | |
20 | let _y: Box<NoisyDrop>; | |
21 | let x = Box::new(NoisyDrop(&status)); | |
22 | unsafe { | |
ba9703b0 | 23 | llvm_asm!("mov $1, $0" : "=r"(_y) : "r"(x)); |
ff7c6d11 XL |
24 | } |
25 | assert_eq!(status.get(), "alive"); | |
26 | } | |
27 | assert_eq!(status.get(), "destroyed"); | |
28 | } | |
29 | ||
30 | #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))] | |
31 | fn main() {} |