yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
5055de0bb
master
1//DIAGNOSTIC_TEST:SIMPLE: 2 3int doSomething(int a) 4{ 5 // No warning, literal will be interpreted as 64 bit. 6 uint64_t c0 = 0x800000000; 7 8 // No warning as top bits are just ignored 9 int c1 = -1ll; 10 11 int c2 = int(-1u); 12 13 // Should sign extend 14 int c3 = 0x80000000; 15 16 // No warning, hex literal will be interpreted as an unsigned 64 integer then signed with negative operator. 17 int64_t c4 = -0xfffffffff; 18 19 a += (int)c0 + c1 + c2; 20 21 int64_t b = 0; 22 23 // Ok 24 b += 0x800000000ll; 25 26 uint64_t c5 = -2ull; 27 28 // Warning, integer literal is too large for signed 64 bit, must be interpreted as unsigned. 29 uint64_t d0 = 18446744073709551615; 30 31 // Warning, integer literal is too small for signed 64 bit, must be interpreted as unsigned. 32 uint64_t d1 = -9223372036854775809; 33 34 // This is INT64_MIN and valid negative signed integer, but warning will be emitted as negative(-) is scanned 35 // separately in the lexer, and the positive literal portion will emit a warning. 36 // The final value will still be correctly set as INT64_MIN. 37 // 38 // To not have this warning the lexer must scan the negative operator and number together. 39 uint64_t d2 = -9223372036854775808; 40 41 // Warning, integer literal is too large for signed 64 bit, must be interpreted as unsigned. 42 int x4 = 0xFFFFFFFFFFFFFFFF; 43 44 return a + int(b); 45} 46