Skip to content

Commit e1365a6

Browse files
authored
Merge pull request #6177 from diffblue/empty_assigns_clause
Allow an empty assigns clause
2 parents dd77754 + 7f662a3 commit e1365a6

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
@@ -3272,6 +3272,12 @@ cprover_contract_assigns_opt:
32723272
parser_stack($3).id(ID_target_list);
32733273
mto($$, $3);
32743274
}
3275+
| TOK_CPROVER_ASSIGNS '(' ')'
3276+
{
3277+
$$=$1;
3278+
set($$, ID_C_spec_assigns);
3279+
parser_stack($$).add_to_operands(exprt(ID_target_list));
3280+
}
32753281
;
32763282

32773283
cprover_function_contract_sequence:

0 commit comments

Comments
 (0)