Skip to content

Commit c186c10

Browse files
author
Remi Delmas
committed
Fix handling of enable pragmas
Check instructions generated by goto_check received a "disable" pragma to prevent them being instrumented by later passes of goto-instrument or cbmc. When the source instruction carried an "enable" pragma, the check instruction would receive both "enable" and "disable" pragmas which is considered erroneous. For the generated check instructions, we replace the "disable" pragmas with "checked" pragmas which is compatible with the "enable" pragma of their source, while still inhibiting the generation of secondary check instructions from theses check instructions.
1 parent 3ee2b3a commit c186c10

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed
Lines changed: 10 additions & 0 deletions
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+
}
Lines changed: 11 additions & 0 deletions
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

Lines changed: 6 additions & 6 deletions
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)