Skip to content

Commit 4166069

Browse files
celinvaltedinski
authored andcommitted
Hide --lib-c and add assume-false to unknown fns (rust-lang#964)
- Support to --lib-c is not well tested. Keep it as experiemental. - Change how CBMC behaves when a function that is not defined is reachable. This mitigates issues rust-lang#576. We should still add an unimplemented assertion so we can flip the results of other checks to undetermined.
1 parent 0fa05a4 commit 4166069

File tree

5 files changed

+29
-4
lines changed

5 files changed

+29
-4
lines changed

src/cargo-kani/src/args.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,9 @@ pub struct KaniArgs {
7575
/// Entry point for verification
7676
#[structopt(long, default_value = "main")]
7777
pub function: String,
78-
/// Link external C files referenced by Rust code
79-
#[structopt(long, parse(from_os_str))]
78+
/// Link external C files referenced by Rust code.
79+
/// This is an experimental feature.
80+
#[structopt(long, parse(from_os_str), hidden = true)]
8081
pub c_lib: Vec<PathBuf>,
8182
/// Enable test function verification. Only use this option when the entry point is a test function.
8283
#[structopt(long)]

src/cargo-kani/src/call_goto_instrument.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl KaniSession {
7979
fn undefined_functions(&self, file: &Path) -> Result<()> {
8080
let args: Vec<OsString> = vec![
8181
"--generate-function-body-options".into(),
82-
"assert-false".into(),
82+
"assert-false-assume-false".into(),
8383
"--generate-function-body".into(),
8484
".*".into(),
8585
"--drop-unused-functions".into(),

tests/ui/cbmc_checks/float-overflow/check_message.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use kani::any;
88

99
// Use the result so rustc doesn't optimize them away.
1010
fn dummy(result: f32) -> f32 {
11-
result.round()
11+
result
1212
}
1313

1414
#[kani::proof]

tests/ui/missing-function/expected

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Status: UNREACHABLE\
2+
Description: "assertion failed: x == 5"
3+
4+
VERIFICATION:- FAILED
5+

tests/ui/missing-function/extern_c.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0 OR MIT
3+
4+
// kani-flags: --function harness
5+
6+
// This test is to check Kani's error handling for missing functions.
7+
// TODO: Verify that this prints a compiler warning:
8+
// - https://github.com/model-checking/kani/issues/576
9+
10+
11+
extern "C" {
12+
fn missing_function() -> u32;
13+
}
14+
15+
#[kani::proof]
16+
fn harness() {
17+
let x = unsafe { missing_function() };
18+
assert!(x == 5);
19+
}

0 commit comments

Comments
 (0)