Skip to content

enabling #pragma disable "pointer-primitive" #6395

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 1 commit into from
Nov 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/cprover-manual/properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ The goto-instrument program supports these checks:
| `--bounds-check` | add array bounds checks |
| `--div-by-zero-check` | add division by zero checks |
| `--pointer-check` | add pointer checks |
| `--pointer-primitive-check` | add pointer primitive checks |
| `--signed-overflow-check` | add arithmetic over- and underflow checks |
| `--unsigned-overflow-check` | add arithmetic over- and underflow checks |
| `--undefined-shift-check` | add range checks for shift distances |
Expand Down
20 changes: 20 additions & 0 deletions regression/cbmc/pragma_cprover3/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <stdlib.h>

int main()
{
char *p = malloc(sizeof(*p));
char *q;

#pragma CPROVER check push
#pragma CPROVER check disable "pointer-primitive"
// do not generate checks for the following statements
if(__CPROVER_same_object(p, q))
{
}
#pragma CPROVER check pop

// generate check and fail on the following statements
if(__CPROVER_same_object(p, q))
{
}
}
16 changes: 16 additions & 0 deletions regression/cbmc/pragma_cprover3/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
CORE
main.c
--pointer-primitive-check
^main.c function main$
^\[main.pointer_primitives.\d+\] line 17 pointer invalid in POINTER_OBJECT\(\(const void \*\)p\): SUCCESS$
^\[main.pointer_primitives.\d+\] line 17 deallocated dynamic object in POINTER_OBJECT\(\(const void \*\)p\): SUCCESS$
^\[main.pointer_primitives.\d+\] line 17 dead object in POINTER_OBJECT\(\(const void \*\)p\): SUCCESS$
^\[main.pointer_primitives.\d+\] line 17 pointer outside object bounds in POINTER_OBJECT\(\(const void \*\)p\): SUCCESS$
^\[main.pointer_primitives.\d+\] line 17 pointer invalid in POINTER_OBJECT\(\(const void \*\)q\): FAILURE$
^\[main.pointer_primitives.\d+\] line 17 deallocated dynamic object in POINTER_OBJECT\(\(const void \*\)q\): SUCCESS$
^\[main.pointer_primitives.\d+\] line 17 dead object in POINTER_OBJECT\(\(const void \*\)q\): SUCCESS$
^\[main.pointer_primitives.\d+\] line 17 pointer outside object bounds in POINTER_OBJECT\(\(const void \*\)q\): FAILURE$
^VERIFICATION FAILED$
^EXIT=10$
^SIGNAL=0$
--
3 changes: 2 additions & 1 deletion src/ansi-c/scanner.l
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,10 @@ CPROVER_PREFIX "__CPROVER_"

arith_check ("conversion"|"undefined-shift"|"nan"|"div-by-zero")
enum_check "enum-range"
pointer_primitive "pointer-primitive"
memory_check ("bounds"|"pointer"|"memory_leak")
overflow_check ("signed"|"unsigned"|"pointer"|"float")"-overflow"
named_check ["]({arith_check}|{enum_check}|{memory_check}|{overflow_check})["]
named_check ["]({arith_check}|{enum_check}|{memory_check}|{overflow_check}|{pointer_primitive})["]

%x GRAMMAR
%x COMMENT1
Expand Down