-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6986 from tautschnig/bugfixes/crangler-assigns-cl…
…auses Crangler: support semicolon in post-declarator expressions
- Loading branch information
Showing
4 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
regression/crangler/assigns-clause-syntax/main-contract-after-declaration.c
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,28 @@ | ||
int foo(int *arr, int size); | ||
|
||
int foo(int *arr, int size) | ||
// clang-format off | ||
__CPROVER_requires(size > 0 && __CPROVER_is_fresh(arr, size)) | ||
__CPROVER_assigns( | ||
arr[0], arr[size-1]; | ||
size >= 10: arr[5]; | ||
) | ||
__CPROVER_ensures(arr[0] == 0 && arr[size-1] == 0) | ||
__CPROVER_ensures(size >= 10 ==> arr[5] == __CPROVER_return_value) | ||
// clang-format on | ||
; | ||
|
||
int foo(int *arr, int size) | ||
{ | ||
arr[0] = 0; | ||
arr[size - 1] = 0; | ||
return size < 10 ? 0 : arr[5]; | ||
} | ||
|
||
int main() | ||
{ | ||
int arr[10]; | ||
int retval = foo(arr, 10); | ||
__CPROVER_assert(retval == arr[5], "should succeed"); | ||
return 0; | ||
} |
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,9 @@ | ||
CORE | ||
test.json | ||
|
||
__CPROVER_assigns | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
-- | ||
-- | ||
Make sure the semicolon in assigns clauses does not trip up parsing. |
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,6 @@ | ||
{ | ||
"sources": [ | ||
"main-contract-after-declaration.c" | ||
], | ||
"output": "stdout" | ||
} |
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