File tree 12 files changed +156
-0
lines changed
jbmc/regression/jbmc/exception-cleanup
12 files changed +156
-0
lines changed Original file line number Diff line number Diff line change
1
+ public class Test {
2
+
3
+ public static void main (int unknown ) {
4
+
5
+ try {
6
+ mayThrow (unknown % 7 == 5 );
7
+ }
8
+ catch (Exception e ) {
9
+ }
10
+
11
+ // This test checks that symex can tell there is no exception in flight
12
+ // (i.e. @inflight_exception is null) at this point, requiring it to
13
+ // converge the `if @inflight_exception == null` test on mayThrow's return
14
+ // with the explicit `@inflight_exception = null;` assignment that concludes
15
+ // the catch block.
16
+
17
+ // If it knows that, it will also know the following catch block is
18
+ // unreachable; if not it will pursue both paths.
19
+ try {
20
+ mayThrow (false );
21
+ }
22
+ catch (Exception e ) {
23
+ unreachable ();
24
+ }
25
+
26
+ // Try it once more, to check we also know after an unreachable catch that
27
+ // there is still no inflight exception
28
+ try {
29
+ mayThrow (false );
30
+ }
31
+ catch (Exception e ) {
32
+ unreachable ();
33
+ }
34
+
35
+ }
36
+
37
+ public static void mayThrow (boolean shouldThrow ) throws Exception {
38
+ if (shouldThrow )
39
+ throw new Exception ();
40
+ }
41
+
42
+ public static void unreachable () { assert false ; }
43
+
44
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ Test.class
3
+ --function Test.main
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION SUCCESSFUL$
7
+ 1 remaining after simplification$
8
+ --
9
+ ^warning: ignoring
10
+ --
11
+ The function "unreachable" should be successfully noted as unreachable by symex,
12
+ but the final uncaught-exception test in __CPROVER__start is not yet decidable
13
+ in symex, as it requires symex to note that within a catch block
14
+ @inflight_exception is definitely *not* null, which it can't just yet.
Original file line number Diff line number Diff line change
1
+ CORE
2
+ Test.class
3
+ --function Test.main --show-vcc
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ file Test\.java line 6 function java::Test.main:\(I\)V
7
+ no uncaught exception
8
+ --
9
+ file Test\.java line 42 function java::Test\.unreachable:\(\)V bytecode-index 5
10
+ assertion at file Test\.java line 42 function java::Test\.unreachable:\(\)V bytecode-index 5
11
+ java::Test\.unreachable:\(\)V
12
+ ^warning: ignoring
13
+ --
14
+ Supplemental to test.desc, check that the right condition remains to be tested by the solver,
15
+ and the unreachable function indeed does not occur in the VCCs.
Original file line number Diff line number Diff line change
1
+ int main (int argc , char * * argv )
2
+ {
3
+ if (argc == 1 )
4
+ assert (argc == 1 );
5
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ test.c
3
+
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION SUCCESSFUL$
7
+ 0 remaining after simplification$
8
+ --
9
+ ^warning: ignoring
10
+ --
11
+ Assumption and GOTO condition propagation means this test should be
12
+ entirely decided by symex.
Original file line number Diff line number Diff line change
1
+ int main (int argc , char * * argv )
2
+ {
3
+ __CPROVER_assume (argc == 1 );
4
+ assert (argc == 1 );
5
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ test.c
3
+
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION SUCCESSFUL$
7
+ 0 remaining after simplification$
8
+ --
9
+ ^warning: ignoring
10
+ --
11
+ Assumption and GOTO condition propagation means this test should be
12
+ entirely decided by symex.
Original file line number Diff line number Diff line change
1
+ int main (int argc , char * * argv )
2
+ {
3
+ if (argc != 1 )
4
+ {
5
+ }
6
+ else
7
+ {
8
+ assert (argc == 1 );
9
+ }
10
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ test.c
3
+
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION SUCCESSFUL$
7
+ 0 remaining after simplification$
8
+ --
9
+ ^warning: ignoring
10
+ --
11
+ Assumption and GOTO condition propagation means this test should be
12
+ entirely decided by symex.
Original file line number Diff line number Diff line change
1
+ int main (int argc , char * * argv )
2
+ {
3
+ int unknown ;
4
+
5
+ if (argc != 1 )
6
+ {
7
+ }
8
+ else
9
+ {
10
+ if (unknown == argc )
11
+ {
12
+ assert (unknown == 1 );
13
+ }
14
+ }
15
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ test.c
3
+
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION SUCCESSFUL$
7
+ 0 remaining after simplification$
8
+ --
9
+ ^warning: ignoring
10
+ --
11
+ Assumption and GOTO condition propagation means this test should be
12
+ entirely decided by symex.
You can’t perform that action at this time.
0 commit comments