b0d93ccc90
Now that we know the minimum and maximum values of a given integer Type, we can check for assigment statements or variable initial-values that exceed those bounds and report it as an error. This check should work on anything that can be optimized or folded down to an IntLiteral, but isn't meant to be 100% exhaustive. Change-Id: I4473b5b003e1b8e3385943ce60e303e95664e8ba Bug: skia:10932 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/413437 Commit-Queue: John Stiles <johnstiles@google.com> Auto-Submit: John Stiles <johnstiles@google.com> Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
29 lines
816 B
Plaintext
29 lines
816 B
Plaintext
// Expect 10 errors
|
|
|
|
const int intMin = -2147483648;
|
|
const int intMinMinusOne = -2147483649; // error
|
|
const int intMax = 2147483647;
|
|
const int intMaxPlusOne = 2147483648; // error
|
|
|
|
void main() {
|
|
ushort4 us4 = ushort4(-1, // error
|
|
0,
|
|
65535,
|
|
65536); // error
|
|
|
|
short4 s4 = short4(-32768,
|
|
-32769, // error
|
|
32768, // error
|
|
32767);
|
|
|
|
int4 i4 = int4(intMin,
|
|
intMinMinusOne, // error
|
|
intMax,
|
|
intMaxPlusOne); // error
|
|
|
|
uint4 ui4 = uint4(intMin, // error
|
|
intMinMinusOne, // error
|
|
intMax,
|
|
intMaxPlusOne);
|
|
}
|