File tree 7 files changed +101
-2
lines changed
7 files changed +101
-2
lines changed Original file line number Diff line number Diff line change
1
+ int foo (int * arr , int size )
2
+ {
3
+ arr [0 ] = 0 ;
4
+ arr [size - 1 ] = 0 ;
5
+
6
+ for (int i = 0 ; i < 2 ; i ++ )
7
+ {
8
+ arr [i ] = 0 ;
9
+ }
10
+
11
+ int i = 0 ;
12
+ while (i < 2 )
13
+ {
14
+ arr [i ] = 0 ;
15
+ i ++ ;
16
+ }
17
+
18
+ return size < 10 ? 0 : arr [5 ];
19
+ }
20
+
21
+ int main ()
22
+ {
23
+ int arr [10 ];
24
+ int retval = foo (arr , 10 );
25
+ __CPROVER_assert (retval == arr [5 ], "should succeed" );
26
+ return 0 ;
27
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ test.json
3
+
4
+ ^\s+while\(i \< 2\) \_\_CPROVER\_loop\_invariant
5
+ ^EXIT=0$
6
+ ^SIGNAL=0$
7
+ --
8
+ ^\s+for\(int i = 0; i \< 2; i\+\+\) \_\_CPROVER
9
+ --
10
+ Annotate loop invariant only to the for-loop.
Original file line number Diff line number Diff line change
1
+ {
2
+ "sources" : [
3
+ " main.c"
4
+ ],
5
+ "functions" : [
6
+ {
7
+ "foo" : [
8
+ " while 1 invariant 1==1"
9
+ ]
10
+ }
11
+ ],
12
+ "output" : " stdout"
13
+ }
Original file line number Diff line number Diff line change
1
+ int foo (int * arr , int size )
2
+ {
3
+ arr [0 ] = 0 ;
4
+ arr [size - 1 ] = 0 ;
5
+ for (int i = 0 ; i < 2 ; i ++ )
6
+ {
7
+ arr [i ] = 0 ;
8
+ }
9
+
10
+ int i = 0 ;
11
+ while (i < 2 )
12
+ {
13
+ arr [i ] = 0 ;
14
+ i ++ ;
15
+ }
16
+
17
+ return size < 10 ? 0 : arr [5 ];
18
+ }
19
+
20
+ int main ()
21
+ {
22
+ int arr [10 ];
23
+ int retval = foo (arr , 10 );
24
+ __CPROVER_assert (retval == arr [5 ], "should succeed" );
25
+ return 0 ;
26
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ test.json
3
+
4
+ ^\s+for\(int i = 0; i \< 2; i\+\+\) \_\_CPROVER\_loop\_invariant
5
+ ^EXIT=0$
6
+ ^SIGNAL=0$
7
+ --
8
+ ^\s+while\(i \< 2\) \_\_CPROVER
9
+ --
10
+ Annotate loop invariant only to the while-loop.
Original file line number Diff line number Diff line change
1
+ {
2
+ "sources" : [
3
+ " main.c"
4
+ ],
5
+ "functions" : [
6
+ {
7
+ "foo" : [
8
+ " for 1 invariant 1==1"
9
+ ]
10
+ }
11
+ ],
12
+ "output" : " stdout"
13
+ }
Original file line number Diff line number Diff line change @@ -456,8 +456,8 @@ static void mangle_function(
456
456
auto t_end = match_bracket (t, ' (' , ' )' );
457
457
for (; t != t_end; t++)
458
458
out << t->text ;
459
- out << ' ' << CPROVER_PREFIX << " invariant( " << defines (invariant)
460
- << ' )' ;
459
+ out << ' ' << CPROVER_PREFIX << " loop_invariant( "
460
+ << defines (invariant) << ' )' ;
461
461
}
462
462
}
463
463
}
You can’t perform that action at this time.
0 commit comments