File: ShiftRight.java

package info (click to toggle)
checker-framework-java 3.2.0%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 23,104 kB
  • sloc: java: 145,916; xml: 839; sh: 518; makefile: 404; perl: 26
file content (27 lines) | stat: -rw-r--r-- 963 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Test case for kelloggm 214
// https://github.com/kelloggm/checker-framework/issues/214

import org.checkerframework.checker.index.qual.IndexFor;
import org.checkerframework.checker.index.qual.IndexOrHigh;
import org.checkerframework.checker.index.qual.LTLengthOf;

public class ShiftRight {
    void indexFor(Object[] a, @IndexFor("#1") int i) {
        @IndexFor("a") int o = i >> 2;
        @IndexFor("a") int p = i >>> 2;
    }

    void indexOrHigh(Object[] a, @IndexOrHigh("#1") int i) {
        @IndexOrHigh("a") int o = i >> 2;
        @IndexOrHigh("a") int p = i >>> 2;
        // Not true if a.length == 0
        // :: error: (assignment.type.incompatible)
        @IndexFor("a") int q = i >> 2;
    }

    void negative(Object[] a, @LTLengthOf(value = "#1", offset = "100") int i) {
        // Not true for some negative i
        // :: error: (assignment.type.incompatible)
        @LTLengthOf(value = "#1", offset = "100") int q = i >> 2;
    }
}