]>
Commit | Line | Data |
---|---|---|
0bf4aa26 | 1 | #![allow(unused_mut)] |
94b46f34 XL |
2 | // ignore-wasm32 |
3 | // ignore-emscripten | |
4 | ||
b7449926 XL |
5 | // compile-flags: -C debug_assertions=yes |
6 | ||
0bf4aa26 | 7 | #![stable(feature = "rustc", since = "1.0.0")] |
0731742a | 8 | #![feature(const_fn, rustc_private, staged_api, rustc_attrs)] |
94b46f34 XL |
9 | #![allow(const_err)] |
10 | ||
8faf50e0 XL |
11 | extern crate libc; |
12 | ||
94b46f34 XL |
13 | use std::env; |
14 | use std::process::{Command, Stdio}; | |
15 | ||
b7449926 | 16 | // this will panic in debug mode and overflow in release mode |
0bf4aa26 XL |
17 | #[stable(feature = "rustc", since = "1.0.0")] |
18 | #[rustc_promotable] | |
94b46f34 XL |
19 | const fn bar() -> usize { 0 - 1 } |
20 | ||
21 | fn foo() { | |
22 | let _: &'static _ = &bar(); | |
23 | } | |
24 | ||
8faf50e0 XL |
25 | #[cfg(unix)] |
26 | fn check_status(status: std::process::ExitStatus) | |
27 | { | |
28 | use libc; | |
29 | use std::os::unix::process::ExitStatusExt; | |
30 | ||
31 | assert!(status.signal() == Some(libc::SIGILL) | |
a1dfa0c6 | 32 | || status.signal() == Some(libc::SIGTRAP) |
8faf50e0 XL |
33 | || status.signal() == Some(libc::SIGABRT)); |
34 | } | |
35 | ||
36 | #[cfg(not(unix))] | |
37 | fn check_status(status: std::process::ExitStatus) | |
38 | { | |
39 | assert!(!status.success()); | |
40 | } | |
41 | ||
94b46f34 XL |
42 | fn main() { |
43 | let args: Vec<String> = env::args().collect(); | |
44 | if args.len() > 1 && args[1] == "test" { | |
45 | foo(); | |
46 | return; | |
47 | } | |
48 | ||
49 | let mut p = Command::new(&args[0]) | |
50 | .stdout(Stdio::piped()) | |
51 | .stdin(Stdio::piped()) | |
52 | .arg("test").output().unwrap(); | |
8faf50e0 | 53 | check_status(p.status); |
94b46f34 | 54 | } |