| 1 |
// all control paths return, extra returns |
| 2 |
|
| 3 |
fun int foo( int a, int b ) |
| 4 |
{ |
| 5 |
if( a == 1 ) |
| 6 |
{ |
| 7 |
if( b == 1 ) |
| 8 |
{ |
| 9 |
return 1; |
| 10 |
} |
| 11 |
else |
| 12 |
{ |
| 13 |
return 2; |
| 14 |
} |
| 15 |
|
| 16 |
// unreachable but okay |
| 17 |
return -1; |
| 18 |
} |
| 19 |
else if( a == 2 ) |
| 20 |
{ |
| 21 |
if( b == 1 ) |
| 22 |
{ |
| 23 |
return 3; |
| 24 |
} |
| 25 |
else |
| 26 |
{ |
| 27 |
return 4; |
| 28 |
} |
| 29 |
} |
| 30 |
else |
| 31 |
{ |
| 32 |
if( b == 1 ) |
| 33 |
{ |
| 34 |
return 5; |
| 35 |
} |
| 36 |
else |
| 37 |
{ |
| 38 |
return 6; |
| 39 |
} |
| 40 |
} |
| 41 |
} |
| 42 |
|
| 43 |
foo( 1, 1 ) => int r1; |
| 44 |
foo( 1, 2 ) => int r2; |
| 45 |
foo( 2, 1 ) => int r3; |
| 46 |
foo( 2, 2 ) => int r4; |
| 47 |
foo( 3, 1 ) => int r5; |
| 48 |
foo( 3, 2 ) => int r6; |
| 49 |
|
| 50 |
// success condition |
| 51 |
if( r1 == 1 && r2 == 2 && r3 == 3 && r4 == 4 && r5 == 5 && r6 == 6 ) |
| 52 |
<<< "success" >>>; |