Skip to content

Commit c78b8b4

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 d3f7c6a commit c78b8b4

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
@@ -634,6 +634,7 @@ void goto_convertt::do_enum_is_in_range(
634634

635635
code_assignt assignment(lhs, disjunction(disjuncts));
636636
assignment.add_source_location() = function.source_location();
637+
assignment.add_source_location().add_pragma("disable:enum-range-check");
637638
copy(assignment, ASSIGN, dest);
638639
}
639640

0 commit comments

Comments
 (0)