Skip to content

Commit ef74099

Browse files
kroeningfeliperodri
authored andcommitted
Allow multiple assigns clauses
This changes the parser to allow multiple assigns clauses in a contract. The meaning of multiple clauses is the same as the meaning of one clause that contains the concatenation of the target lists of the given clauses.
1 parent 10ddca0 commit ef74099

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

regression/contracts/assigns_enforce_03/main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ void f2(int *x2, int *y2, int *z2) __CPROVER_assigns(*x2, *y2, *z2)
88
f3(x2, y2, z2);
99
}
1010

11-
void f3(int *x3, int *y3, int *z3) __CPROVER_assigns(*x3, *y3, *z3)
11+
void f3(int *x3, int *y3, int *z3) __CPROVER_assigns(*x3) __CPROVER_assigns(*y3)
12+
__CPROVER_assigns(*z3)
1213
{
1314
*x3 = *x3 + 1;
1415
*y3 = *y3 + 1;

src/ansi-c/ansi_c_convert_type.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,8 @@ void ansi_c_convert_typet::read_rec(const typet &type)
252252
{
253253
const exprt &as_expr =
254254
static_cast<const exprt &>(static_cast<const irept &>(type));
255-
assigns = to_unary_expr(as_expr).op();
256255

257-
for(const exprt &operand : assigns.operands())
256+
for(const exprt &operand : to_unary_expr(as_expr).op().operands())
258257
{
259258
if(
260259
operand.id() != ID_symbol && operand.id() != ID_ptrmember &&
@@ -265,6 +264,14 @@ void ansi_c_convert_typet::read_rec(const typet &type)
265264
throw 0;
266265
}
267266
}
267+
268+
if(assigns.is_nil())
269+
assigns = to_unary_expr(as_expr).op();
270+
else
271+
{
272+
for(auto &assignment : to_unary_expr(as_expr).op().operands())
273+
assigns.add_to_operands(std::move(assignment));
274+
}
268275
}
269276
else if(type.id() == ID_C_spec_ensures)
270277
{

0 commit comments

Comments
 (0)