File tree 4 files changed +58
-0
lines changed
regression/crangler/assigns-clause-syntax
4 files changed +58
-0
lines changed Original file line number Diff line number Diff line change
1
+ int foo (int * arr , int size );
2
+
3
+ int foo (int * arr , int size )
4
+ // clang-format off
5
+ __CPROVER_requires (size > 0 && __CPROVER_is_fresh (arr , size ))
6
+ __CPROVER_assigns (
7
+ arr [0 ], arr [size - 1 ];
8
+ size >= 10 : arr [5 ];
9
+ )
10
+ __CPROVER_ensures (arr [0 ] == 0 && arr [size - 1 ] == 0 )
11
+ __CPROVER_ensures (size >= 10 == > arr [5 ] == __CPROVER_return_value )
12
+ // clang-format on
13
+ ;
14
+
15
+ int foo (int * arr , int size )
16
+ {
17
+ arr [0 ] = 0 ;
18
+ arr [size - 1 ] = 0 ;
19
+ return size < 10 ? 0 : arr [5 ];
20
+ }
21
+
22
+ int main ()
23
+ {
24
+ int arr [10 ];
25
+ int retval = foo (arr , 10 );
26
+ __CPROVER_assert (retval == arr [5 ], "should succeed" );
27
+ return 0 ;
28
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ test.json
3
+
4
+ __CPROVER_assigns
5
+ ^EXIT=0$
6
+ ^SIGNAL=0$
7
+ --
8
+ --
9
+ Make sure the semicolon in assigns clauses does not trip up parsing.
Original file line number Diff line number Diff line change
1
+ {
2
+ "sources" : [
3
+ " main-contract-after-declaration.c"
4
+ ],
5
+ "output" : " stdout"
6
+ }
Original file line number Diff line number Diff line change @@ -282,12 +282,27 @@ mini_c_parsert::tokenst mini_c_parsert::parse_post_declarator()
282
282
// 3) '=' (initializer)
283
283
284
284
tokenst result;
285
+ std::size_t open_parentheses = 0 ;
285
286
286
287
while (true )
287
288
{
288
289
if (eof ())
289
290
return result;
290
291
292
+ if (peek () == ' (' )
293
+ {
294
+ ++open_parentheses;
295
+ result.push_back (consume_token ());
296
+ continue ;
297
+ }
298
+ else if (open_parentheses > 0 )
299
+ {
300
+ if (peek () == ' )' )
301
+ --open_parentheses;
302
+ result.push_back (consume_token ());
303
+ continue ;
304
+ }
305
+
291
306
if (peek () == ' ;' || peek () == ' {' || peek () == ' =' )
292
307
return result;
293
308
You can’t perform that action at this time.
0 commit comments