Skip to content

Commit 7f662a3

Browse files
committed
allow an empty assigns clause
This adds support for an explicit empty assigns clause, denoting a pure function.
1 parent 437675a commit 7f662a3

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

regression/contracts/assigns_enforce_15/main.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,16 @@ int baz() __CPROVER_ensures(__CPROVER_return_value == global)
2020
return global;
2121
}
2222

23+
void qux(void) __CPROVER_assigns()
24+
{
25+
global = global + 1;
26+
}
27+
2328
int main()
2429
{
2530
int n;
2631
n = foo(&n);
2732
n = baz();
33+
qux();
2834
return 0;
2935
}

regression/contracts/assigns_enforce_15/test.desc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ main.c
33
--enforce-all-contracts
44
^EXIT=10$
55
^SIGNAL=0$
6-
^\[bar.1\] line \d+ .*: FAILURE$
7-
^\[baz.1\] line \d+ .*: FAILURE$
6+
^\[bar\.1\] line \d+ .*: FAILURE$
7+
^\[baz\.1\] line \d+ .*: FAILURE$
8+
^\[qux\.1\] line \d+ .*: FAILURE$
89
^VERIFICATION FAILED$
910
--
1011
--

src/ansi-c/parser.y

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3250,6 +3250,12 @@ cprover_contract:
32503250
parser_stack($3).id(ID_target_list);
32513251
mto($$, $3);
32523252
}
3253+
| TOK_CPROVER_ASSIGNS '(' ')'
3254+
{
3255+
$$=$1;
3256+
set($$, ID_C_spec_assigns);
3257+
parser_stack($$).add_to_operands(exprt(ID_target_list));
3258+
}
32533259
;
32543260

32553261
cprover_contract_sequence:

0 commit comments

Comments
 (0)