Debian Codegraph @

framework/tests/value-ignore-range-overflow/TransferDivide.java

raw
1 import org.checkerframework.common.value.qual.*;
2
3 public class TransferDivide {
4
5 void test() {
6 int a = -1;
7 int b = 0;
8 int c = 1;
9 int d = 2;
10
11 /** literals */
12 @IntRange(from = 1) int e = -1 / -1;
13
14 /** 0 / * -> NN */
15 @IntRange(from = 0) int f = 0 / a;
16 @IntRange(from = 0) int g = 0 / d;
17
18 /** * / 1 -> * */
19 @IntRange(from = -1) int h = a / 1;
20 @IntRange(from = 0) int i = b / 1;
21 @IntRange(from = 1) int j = c / 1;
22 @IntRange(from = 1) int k = d / 1;
23
24 /** pos / pos -> nn */
25 @IntRange(from = 0) int l = d / c;
26 @IntRange(from = 0) int m = c / d;
27 // :: error: (assignment.type.incompatible)
28 @IntRange(from = 1) int n = c / d;
29
30 /** nn / pos -> nn */
31 @IntRange(from = 0) int o = b / c;
32 // :: error: (assignment.type.incompatible)
33 @IntRange(from = 1) int p = b / d;
34
35 /** pos / nn -> nn */
36 @IntRange(from = 0) int q = d / l;
37 // :: error: (assignment.type.incompatible)
38 @IntRange(from = 1) int r = c / l;
39
40 /** nn / nn -> nn */
41 @IntRange(from = 0) int s = b / q;
42 // :: error: (assignment.type.incompatible)
43 @IntRange(from = 1) int t = b / q;
44
45 /** n1p / pos -> n1p */
46 @IntRange(from = -1) int u = a / d;
47 @IntRange(from = -1) int v = a / c;
48 // :: error: (assignment.type.incompatible)
49 @IntRange(from = 0) int w = a / c;
50
51 /** n1p / nn -> n1p */
52 @IntRange(from = -1) int x = a / l;
53 }
54
55 void testDivideByTwo(@IntRange(from = 0) int x) {
56 @IntRange(from = 0) int y = x / 2;
57 }
58 }