Skip to content

Commit 8756346

Browse files
authored
Merge pull request #7037 from nwetzler/contract-coverage
CONTRACTS: Populate function name in source locations
2 parents acb58e7 + 83abf73 commit 8756346

File tree

39 files changed

+148
-44
lines changed

39 files changed

+148
-44
lines changed

regression/contracts/assigns_repeated_ignored/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CORE
22
main.c
33
--enforce-contract foo
4-
^Ignored duplicate expression '\*x' in assigns clause spec at file main.c line \d+$
4+
^Ignored duplicate expression '\*x' in assigns clause spec at file main.c line \d+ function .*$
55
^EXIT=0$
66
^SIGNAL=0$
77
^VERIFICATION SUCCESSFUL$

regression/contracts/assigns_validity_pointer_02/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ main.c
33
--enforce-contract foo
44
^EXIT=0$
55
^SIGNAL=0$
6-
^\[postcondition.\d+\] file main.c line \d+ Check ensures clause: SUCCESS$
6+
^\[foo.postcondition.\d+\] line \d+ Check ensures clause: SUCCESS$
77
^\[bar.assigns.\d+\] line \d+ Check that \*x is assignable: SUCCESS$
88
^\[bar.assigns.\d+\] line \d+ Check that \*y is assignable: SUCCESS$
99
^\[baz.assigns.\d+\] line \d+ Check that \*z is assignable: SUCCESS$

regression/contracts/contracts_with_function_pointers/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ main.c
33
--enforce-contract bar
44
^EXIT=0$
55
^SIGNAL=0$
6-
^\[postcondition.\d+\] file main.c line \d+ Check ensures clause: SUCCESS$
6+
^\[bar.postcondition.\d+\] line \d+ Check ensures clause: SUCCESS$
77
^\[bar.assigns.\d+\] line \d+ Check that \*return\_value\_baz is assignable: SUCCESS$
88
^\[foo.assigns.\d+\] line \d+ Check that \*y is assignable: SUCCESS$
99
^VERIFICATION SUCCESSFUL$
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
typedef void (*fun_ptr_t)(int x);
2+
3+
void bar(int x)
4+
{
5+
return;
6+
}
7+
8+
void foo(void (*fun_ptr)(int x) __CPROVER_requires(x != 0))
9+
{
10+
return;
11+
}
12+
13+
void main()
14+
{
15+
fun_ptr_t fun_ptr = bar;
16+
foo(fun_ptr);
17+
return;
18+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
main.c
3+
4+
^.*: Function contracts allowed only at top-level declarations. .*$
5+
^PARSING ERROR$
6+
^EXIT=(1|64)$
7+
^SIGNAL=0$
8+
--
9+
--
10+
Checks if function contracts can be attached to function pointers
11+
(with non-empty parameter lists) in function parameters. This should
12+
fail. Exit code 64 for Windows servers.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
typedef int (*fun_ptr_t)();
2+
3+
int bar()
4+
{
5+
return 1;
6+
}
7+
8+
void foo(int (*fun_ptr)() __CPROVER_ensures(__CPROVER_return_value == 1))
9+
{
10+
return;
11+
}
12+
13+
void main()
14+
{
15+
fun_ptr_t fun_ptr = bar;
16+
foo(fun_ptr);
17+
return;
18+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
main.c
3+
4+
^.*: Function contracts allowed only at top-level declarations. .*$
5+
^PARSING ERROR$
6+
^EXIT=(1|64)$
7+
^SIGNAL=0$
8+
--
9+
--
10+
Checks if function contracts can be attached to function pointers
11+
(with empty parameter lists) in function parameters. This should
12+
fail. Exit code 64 for Windows servers.

regression/contracts/function-calls-05/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ main.c
33
--enforce-contract foo
44
^EXIT=0$
55
^SIGNAL=0$
6-
\[postcondition.\d+\] file main.c line \d+ Check ensures clause: SUCCESS
6+
\[foo.postcondition.\d+\] line \d+ Check ensures clause: SUCCESS
77
\[main.assertion.\d+\] line \d+ assertion foo\(\&x, \&y\) \=\= 10: SUCCESS
88
^VERIFICATION SUCCESSFUL$
99
--

regression/contracts/function-pointer-contracts-replace/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CORE
22
main.c
33
--replace-call-with-contract foo
4-
^\[precondition.\d+] file main.c line 19 Assert function pointer 'infun' obeys contract 'contract': SUCCESS$
4+
^\[foo.precondition.\d+] line 19 Assert function pointer 'infun' obeys contract 'contract': SUCCESS$
55
^\[main.assertion.\d+].* assertion outfun1 == contract: SUCCESS$
66
^\[main.assertion.\d+].* assertion outfun2 == contract: SUCCESS$
77
^EXIT=0$

regression/contracts/history-pointer-enforce-09/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ main.c
33
--enforce-contract foo
44
^EXIT=0$
55
^SIGNAL=0$
6-
^\[postcondition.\d+\] file main.c line \d+ Check ensures clause: SUCCESS$
6+
^\[foo.postcondition.\d+\] line \d+ Check ensures clause: SUCCESS$
77
^\[foo.assigns.\d+\] line \d+ Check that p->y is assignable: SUCCESS$
88
^VERIFICATION SUCCESSFUL$
99
--

0 commit comments

Comments
 (0)