-
Notifications
You must be signed in to change notification settings - Fork 274
Cprover enum is in range #5808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Cprover enum is in range #5808
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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,26 @@ | ||
#include <assert.h> | ||
|
||
enum my_enum | ||
{ | ||
first, | ||
second, | ||
third, | ||
fourth, | ||
fifth | ||
}; | ||
|
||
int main() | ||
{ | ||
enum my_enum ev1; | ||
enum my_enum ev2; | ||
ev1 = first; | ||
ev2 = fifth; | ||
int i = 0; | ||
while(i < 10) | ||
{ | ||
ev1++; | ||
assert(__CPROVER_enum_is_in_range(i)); | ||
i++; | ||
} | ||
return 0; | ||
} |
This file contains hidden or 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,12 @@ | ||
CORE | ||
enum_test10.c | ||
|
||
^EXIT=(6|70)$ | ||
^SIGNAL=0$ | ||
^file enum_test10.c line \d+ function main: __CPROVER_enum_is_in_range expects enum, but \(i\) has type `signed int`$ | ||
-- | ||
^\[main.assertion.1\] line \d+ assertion __CPROVER_enum_is_in_range\(i\): SUCCESS$ | ||
^\[main.assertion.1\] line \d+ assertion __CPROVER_enum_is_in_range\(i\): FAILURE$ | ||
^\*\*\*\* WARNING: no body for function __CPROVER_enum_is_in_range$ | ||
-- | ||
This test the type checking of argument for __CPROVER_enum_is_in_range |
This file contains hidden or 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,20 @@ | ||
#include <assert.h> | ||
|
||
enum my_enum | ||
{ | ||
first, | ||
second, | ||
third, | ||
fourth, | ||
fifth | ||
}; | ||
|
||
int main() | ||
{ | ||
enum my_enum ev1; | ||
enum my_enum ev2; | ||
ev1 = first; | ||
ev2 = fifth; | ||
assert(__CPROVER_enum_is_in_range(ev1, ev2)); | ||
return 0; | ||
} |
This file contains hidden or 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,12 @@ | ||
CORE | ||
enum_test12.c | ||
|
||
^EXIT=(6|70)$ | ||
^SIGNAL=0$ | ||
^file enum_test12.c line \d+ function main: __CPROVER_enum_is_in_range takes exactly 1 argument, but 2 were provided$ | ||
-- | ||
^\[main.assertion.1\] line \d+ assertion __CPROVER_enum_is_in_range\(.*\): SUCCESS$ | ||
^\[main.assertion.1\] line \d+ assertion __CPROVER_enum_is_in_range\(.*\): FAILURE$ | ||
^\*\*\*\* WARNING: no body for function __CPROVER_enum_is_in_range$ | ||
-- | ||
This test the type checking of argument for __CPROVER_enum_is_in_range |
This file contains hidden or 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,24 @@ | ||
#include <assert.h> | ||
|
||
enum my_enum | ||
{ | ||
first, | ||
second, | ||
third, | ||
fourth, | ||
fifth | ||
}; | ||
|
||
int main() | ||
{ | ||
enum my_enum ev1; | ||
enum my_enum ev2; | ||
ev1 = first; | ||
ev2 = fifth; | ||
while(ev1 != ev2) | ||
{ | ||
ev1++; | ||
assert(__CPROVER_enum_is_in_range(ev1)); | ||
} | ||
return 0; | ||
} |
This file contains hidden or 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,11 @@ | ||
CORE | ||
enum_test3.c | ||
|
||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
^\[main.assertion.1\] line \d+ assertion __CPROVER_enum_is_in_range\(ev1\): SUCCESS | ||
-- | ||
^\*\*\*\* WARNING: no body for function __CPROVER_enum_is_in_range | ||
-- | ||
This test is for the enum_is_in_range working properly, the negation | ||
is if the function is not defined. |
This file contains hidden or 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,26 @@ | ||
#include <assert.h> | ||
|
||
enum my_enum | ||
{ | ||
first, | ||
second, | ||
third, | ||
fourth, | ||
fifth | ||
}; | ||
|
||
int main() | ||
{ | ||
enum my_enum ev1; | ||
enum my_enum ev2; | ||
ev1 = first; | ||
ev2 = fifth; | ||
int i = 0; | ||
while(i < 10) | ||
{ | ||
ev1++; | ||
assert(__CPROVER_enum_is_in_range(ev1)); | ||
i++; | ||
} | ||
return 0; | ||
} |
This file contains hidden or 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,13 @@ | ||
CORE | ||
enum_test4.c | ||
|
||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
^\[main.assertion.1\] line \d+ assertion __CPROVER_enum_is_in_range\(ev1\): FAILURE$ | ||
-- | ||
^\[main.assertion.1\] line \d+ assertion __CPROVER_enum_is_in_range\(ev1\): SUCCESS$ | ||
^\*\*\*\* WARNING: no body for function __CPROVER_enum_is_in_range$ | ||
-- | ||
This test is for the enum_is_in_range working properly and detecting | ||
when the enum is not in range. The negation tests are to ensure the | ||
out of range is detected, and if the function is not defined. |
This file contains hidden or 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,25 @@ | ||
#include <assert.h> | ||
|
||
enum my_enum | ||
{ | ||
first, | ||
second, | ||
third, | ||
fourth, | ||
fifth | ||
}; | ||
|
||
void testfun(enum my_enum ee) | ||
{ | ||
} | ||
|
||
int main() | ||
{ | ||
enum my_enum ev1; | ||
enum my_enum ev2; | ||
__CPROVER_assume(__CPROVER_enum_is_in_range(ev1)); | ||
enum my_enum ev3 = ev1; | ||
testfun(ev3); | ||
testfun(ev2); | ||
return 0; | ||
} |
This file contains hidden or 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,16 @@ | ||
CORE | ||
enum_test5.c | ||
--enum-range-check | ||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
^\[main.enum-range-check.6\] line \d+ enum range check in ev3: SUCCESS$ | ||
^\[main.enum-range-check.7\] line \d+ enum range check in ev2: FAILURE$ | ||
-- | ||
^\[main.enum-range-check.6\] line \d+ enum range check in ev3: FAILURE$ | ||
^\*\*\*\* WARNING: no body for function __CPROVER_enum_is_in_range$ | ||
-- | ||
This test is for the enum_is_in_range working in assume statements | ||
(and also value passing through assignments of enums). The failure | ||
test case is checking that range checks do work on enums. | ||
The negation tests are to ensure the assumption is taken into account | ||
for ev1 and thus ev3, and if the function is not defined. |
This file contains hidden or 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,24 @@ | ||
#include <assert.h> | ||
|
||
typedef enum | ||
{ | ||
first, | ||
second, | ||
third, | ||
fourth, | ||
fifth | ||
} my_enum; | ||
|
||
int main() | ||
{ | ||
my_enum ev1; | ||
my_enum ev2; | ||
ev1 = first; | ||
ev2 = fifth; | ||
while(!(ev1 == ev2)) | ||
{ | ||
ev1++; | ||
assert(__CPROVER_enum_is_in_range(ev1)); | ||
} | ||
return 0; | ||
} |
This file contains hidden or 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,11 @@ | ||
CORE | ||
enum_test7.c | ||
|
||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
^\[main.assertion.1\] line \d+ assertion __CPROVER_enum_is_in_range\(ev1\): SUCCESS | ||
-- | ||
^\*\*\*\* WARNING: no body for function __CPROVER_enum_is_in_range | ||
-- | ||
This test is for the enum_is_in_range working properly, the negation | ||
is if the function is not defined. |
This file contains hidden or 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,26 @@ | ||
#include <assert.h> | ||
|
||
typedef enum | ||
{ | ||
first, | ||
second, | ||
third, | ||
fourth, | ||
fifth | ||
} my_enum; | ||
|
||
int main() | ||
{ | ||
my_enum ev1; | ||
my_enum ev2; | ||
ev1 = first; | ||
ev2 = fifth; | ||
int i = 0; | ||
while(i < 10) | ||
{ | ||
ev1++; | ||
assert(__CPROVER_enum_is_in_range(ev1)); | ||
i++; | ||
} | ||
return 0; | ||
} |
This file contains hidden or 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,13 @@ | ||
CORE | ||
enum_test8.c | ||
|
||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
^\[main.assertion.1\] line \d+ assertion __CPROVER_enum_is_in_range\(ev1\): FAILURE$ | ||
-- | ||
^\[main.assertion.1\] line \d+ assertion __CPROVER_enum_is_in_range\(ev1\): SUCCESS$ | ||
^\*\*\*\* WARNING: no body for function __CPROVER_enum_is_in_range$ | ||
-- | ||
This test is for the enum_is_in_range working properly and detecting | ||
when the enum is not in range. The negation tests are to ensure the | ||
out of range is detected, and if the function is not defined. |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.