More on comparison that is always false due to being out of type range on implicit type conversion (IDEA-124210)

This commit is contained in:
peter
2014-04-22 14:34:31 +02:00
parent b6bccb78e0
commit 0bd06e5e39
2 changed files with 10 additions and 2 deletions
@@ -470,10 +470,12 @@ public class StandardInstructionVisitor extends InstructionVisitor {
}
if (opSign == LT && constantValue <= minValue) return alwaysFalse(instruction, runner, memState);
if ((opSign == LT || opSign == LE) && constantValue > maxValue) return alwaysTrue(instruction, runner, memState);
if (opSign == LT && constantValue > maxValue) return alwaysTrue(instruction, runner, memState);
if (opSign == LE && constantValue >= maxValue) return alwaysTrue(instruction, runner, memState);
if (opSign == GT && constantValue >= maxValue) return alwaysFalse(instruction, runner, memState);
if ((opSign == GT || opSign == GE) && constantValue < minValue) return alwaysTrue(instruction, runner, memState);
if (opSign == GT && constantValue < minValue) return alwaysTrue(instruction, runner, memState);
if (opSign == GE && constantValue <= minValue) return alwaysTrue(instruction, runner, memState);
return null;
}
@@ -16,4 +16,10 @@ class Foo {
boolean a = <warning descr="Condition 'i < 0x80000000L' is always 'true'">i < 0x80000000L</warning>;
boolean f = <warning descr="Condition 'i > 0x7fffffff' is always 'false'">i > 0x7fffffff</warning>;
}
void f(int k) {
if (<warning descr="Condition 'k <= Integer.MAX_VALUE' is always 'true'">k <= Integer.MAX_VALUE</warning>);
if (<warning descr="Condition 'k > Integer.MAX_VALUE' is always 'false'">k > Integer.MAX_VALUE</warning>);
if (<warning descr="Condition 'k >= Integer.MIN_VALUE' is always 'true'">k >= Integer.MIN_VALUE</warning>);
}
}