-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow multiple annotations, but check for duplicate targets. (#3808)
Resolves #3804. Enables multiple `stub_verified(TARGET)` annotations on a harness, but still detect and report duplicate targets. Adds positive and negative tests. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses. --------- Co-authored-by: Remi Delmas <[email protected]> Co-authored-by: Celina G. Val <[email protected]> Co-authored-by: Felipe R. Monteiro <[email protected]>
- Loading branch information
1 parent
ecbdb14
commit cc07375
Showing
6 changed files
with
92 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
tests/expected/function-contract/missing_contract_for_replace.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
tests/expected/function-contract/multiple_replace_fail.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
warning: Multiple occurrences of `stub_verified(one)`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright Kani Contributors | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
// kani-flags: -Zfunction-contracts | ||
|
||
#[kani::ensures(|result : &u32| *result == 1)] | ||
fn one() -> u32 { | ||
1 | ||
} | ||
|
||
#[kani::proof_for_contract(one)] | ||
fn check_one() { | ||
let _ = one(); | ||
} | ||
|
||
#[kani::ensures(|result : &u32| *result == 1)] | ||
fn one_too() -> u32 { | ||
1 | ||
} | ||
|
||
#[kani::proof_for_contract(one_too)] | ||
fn check_one_too() { | ||
let _ = one_too(); | ||
} | ||
|
||
#[kani::proof] | ||
#[kani::stub_verified(one)] | ||
#[kani::stub_verified(one)] | ||
#[kani::stub_verified(one_too)] | ||
fn main() { | ||
assert_eq!(one(), one_too()); | ||
} |
1 change: 1 addition & 0 deletions
1
tests/expected/function-contract/multiple_replace_pass.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
VERIFICATION:- SUCCESSFUL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright Kani Contributors | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
// kani-flags: -Zfunction-contracts | ||
|
||
#[kani::ensures(|result : &u32| *result == 1)] | ||
fn one() -> u32 { | ||
1 | ||
} | ||
|
||
#[kani::proof_for_contract(one)] | ||
fn check_one() { | ||
let _ = one(); | ||
} | ||
|
||
#[kani::ensures(|result : &u32| *result == 1)] | ||
fn one_too() -> u32 { | ||
1 | ||
} | ||
|
||
#[kani::proof_for_contract(one_too)] | ||
fn check_one_too() { | ||
let _ = one_too(); | ||
} | ||
|
||
#[kani::proof] | ||
#[kani::stub_verified(one)] | ||
#[kani::stub_verified(one_too)] | ||
fn main() { | ||
assert_eq!(one(), one_too()); | ||
} |