Skip to content

Commit d9f2d01

Browse files
authored
Merge pull request #7565 from remi-delmas-3000/checked-pragma-fix
Fix handling of "enable:named-check" pragmas
2 parents a87783f + c186c10 commit d9f2d01

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
void main()
2+
{
3+
int a[2];
4+
#pragma CPROVER check push
5+
#pragma CPROVER check enable "bounds"
6+
a[0] = 1;
7+
a[1] = 2;
8+
a[2] = 3;
9+
#pragma CPROVER check pop
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
main.c
3+
4+
^\[main.array_bounds.\d+\] line \d+ array 'a' upper bound in a\[\(signed .* int\)2\]: FAILURE
5+
^VERIFICATION FAILED
6+
^EXIT=10$
7+
^SIGNAL=0$
8+
--
9+
--
10+
Checks that enable pragmas do not cause invariant failures when running goto-instrument
11+
and cbmc in sequence.

src/ansi-c/goto_check_c.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -308,10 +308,10 @@ class goto_check_ct
308308
/// on the given source location.
309309
void add_active_named_check_pragmas(source_locationt &source_location) const;
310310

311-
/// \brief Adds "disable" pragmas for all named checks
312-
/// on the given source location.
311+
/// \brief Adds "checked" pragmas for all named checks on the given source
312+
/// location (prevents any the instanciation of any ulterior check).
313313
void
314-
add_all_disable_named_check_pragmas(source_locationt &source_location) const;
314+
add_all_checked_named_check_pragmas(source_locationt &source_location) const;
315315

316316
/// activation statuses for named checks
317317
typedef enum
@@ -1726,7 +1726,7 @@ void goto_check_ct::add_guarded_property(
17261726
annotated_location.set_comment(comment + " in " + source_expr_string);
17271727
annotated_location.set_property_class(property_class);
17281728

1729-
add_all_disable_named_check_pragmas(annotated_location);
1729+
add_all_checked_named_check_pragmas(annotated_location);
17301730

17311731
if(enable_assert_to_assume)
17321732
{
@@ -2477,11 +2477,11 @@ void goto_check_ct::add_active_named_check_pragmas(
24772477
source_location.add_pragma("checked:" + id2string(entry.first));
24782478
}
24792479

2480-
void goto_check_ct::add_all_disable_named_check_pragmas(
2480+
void goto_check_ct::add_all_checked_named_check_pragmas(
24812481
source_locationt &source_location) const
24822482
{
24832483
for(const auto &entry : name_to_flag)
2484-
source_location.add_pragma("disable:" + id2string(entry.first));
2484+
source_location.add_pragma("checked:" + id2string(entry.first));
24852485
}
24862486

24872487
goto_check_ct::named_check_statust

0 commit comments

Comments
 (0)