Skip to content

Commit 9c875f2

Browse files
author
Remi Delmas
committed
Adding pointer-primitive to the list of named checks that can be disabled using pragmas.
1 parent 038a53b commit 9c875f2

File tree

4 files changed

+39
-1
lines changed

4 files changed

+39
-1
lines changed

doc/cprover-manual/properties.md

+1
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ The goto-instrument program supports these checks:
122122
| `--bounds-check` | add array bounds checks |
123123
| `--div-by-zero-check` | add division by zero checks |
124124
| `--pointer-check` | add pointer checks |
125+
| `--pointer-primitive-check` | add pointer primitive checks |
125126
| `--signed-overflow-check` | add arithmetic over- and underflow checks |
126127
| `--unsigned-overflow-check` | add arithmetic over- and underflow checks |
127128
| `--undefined-shift-check` | add range checks for shift distances |
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include <stdlib.h>
2+
3+
int main()
4+
{
5+
char *p = malloc(sizeof(*p));
6+
char *q;
7+
8+
#pragma CPROVER check push
9+
#pragma CPROVER check disable "pointer-primitive"
10+
// do not generate checks for the following statements
11+
if(__CPROVER_same_object(p, q))
12+
{
13+
}
14+
#pragma CPROVER check pop
15+
16+
// generate check and fail on the following statements
17+
if(__CPROVER_same_object(p, q))
18+
{
19+
}
20+
}
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
CORE
2+
main.c
3+
--pointer-primitive-check
4+
^main.c function main$
5+
^\[main.pointer_primitives.\d+\] line 17 pointer invalid in POINTER_OBJECT\(\(const void \*\)p\): SUCCESS$
6+
^\[main.pointer_primitives.\d+\] line 17 deallocated dynamic object in POINTER_OBJECT\(\(const void \*\)p\): SUCCESS$
7+
^\[main.pointer_primitives.\d+\] line 17 dead object in POINTER_OBJECT\(\(const void \*\)p\): SUCCESS$
8+
^\[main.pointer_primitives.\d+\] line 17 pointer outside object bounds in POINTER_OBJECT\(\(const void \*\)p\): SUCCESS$
9+
^\[main.pointer_primitives.\d+\] line 17 pointer invalid in POINTER_OBJECT\(\(const void \*\)q\): FAILURE$
10+
^\[main.pointer_primitives.\d+\] line 17 deallocated dynamic object in POINTER_OBJECT\(\(const void \*\)q\): SUCCESS$
11+
^\[main.pointer_primitives.\d+\] line 17 dead object in POINTER_OBJECT\(\(const void \*\)q\): SUCCESS$
12+
^\[main.pointer_primitives.\d+\] line 17 pointer outside object bounds in POINTER_OBJECT\(\(const void \*\)q\): FAILURE$
13+
^VERIFICATION FAILED$
14+
^EXIT=10$
15+
^SIGNAL=0$
16+
--

src/ansi-c/scanner.l

+2-1
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,10 @@ CPROVER_PREFIX "__CPROVER_"
234234

235235
arith_check ("conversion"|"undefined-shift"|"nan"|"div-by-zero")
236236
enum_check "enum-range"
237+
pointer_primitive "pointer-primitive"
237238
memory_check ("bounds"|"pointer"|"memory_leak")
238239
overflow_check ("signed"|"unsigned"|"pointer"|"float")"-overflow"
239-
named_check ["]({arith_check}|{enum_check}|{memory_check}|{overflow_check})["]
240+
named_check ["]({arith_check}|{enum_check}|{memory_check}|{overflow_check}|{pointer_primitive})["]
240241

241242
%x GRAMMAR
242243
%x COMMENT1

0 commit comments

Comments
 (0)