invalid_const_promotion: check if we get the right signal

This commit is contained in:
Ralf Jung 2018-07-29 13:11:01 +02:00
parent 6998b369fa
commit c7f01aa175
1 changed files with 21 additions and 2 deletions

View File

@ -11,18 +11,37 @@
// ignore-wasm32
// ignore-emscripten
#![feature(const_fn)]
#![feature(const_fn, libc)]
#![allow(const_err)]
extern crate libc;
use std::env;
use std::process::{Command, Stdio};
// this will panic in debug mode
const fn bar() -> usize { 0 - 1 }
fn foo() {
let _: &'static _ = &bar();
}
#[cfg(unix)]
fn check_status(status: std::process::ExitStatus)
{
use libc;
use std::os::unix::process::ExitStatusExt;
assert!(status.signal() == Some(libc::SIGILL)
|| status.signal() == Some(libc::SIGABRT));
}
#[cfg(not(unix))]
fn check_status(status: std::process::ExitStatus)
{
assert!(!status.success());
}
fn main() {
let args: Vec<String> = env::args().collect();
if args.len() > 1 && args[1] == "test" {
@ -34,5 +53,5 @@ fn main() {
.stdout(Stdio::piped())
.stdin(Stdio::piped())
.arg("test").output().unwrap();
assert!(!p.status.success());
check_status(p.status);
}