Skip to content

Commit df2a662

Browse files
committed
__CPROVER_enum_is_in_range should not yield redundant assertions
The assertions generated by --enum-range-check must not apply to the expansion of __CPROVER_enum_is_in_range, for those would assert exactly the same. Also, those expressions are rather costly: for N enum values, N assertions would be generated.
1 parent b8585bf commit df2a662

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

regression/cbmc/enum_is_in_range/no_duplicate.desc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@ no_duplicate.c
55
^EXIT=0$
66
^SIGNAL=0$
77
--
8+
line 17 enum range check in e: SUCCESS$
89
--
10+
Test that enum range checks aren't applied to function-call left-hand sides, and
11+
that no extra checks are generated for uses of __CPROVER_enum_is_in_range.

src/goto-programs/builtin_functions.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,7 @@ void goto_convertt::do_enum_is_in_range(
638638

639639
code_assignt assignment(lhs, disjunction(disjuncts));
640640
assignment.add_source_location() = function.source_location();
641+
assignment.add_source_location().add_pragma("disable:enum-range-check");
641642
copy(assignment, ASSIGN, dest);
642643
}
643644

0 commit comments

Comments
 (0)