]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Fix 64-bit negative integer literals
authorJürg Billeter <j@bitron.ch>
Mon, 22 Jun 2015 16:50:47 +0000 (18:50 +0200)
committerJürg Billeter <j@bitron.ch>
Mon, 22 Jun 2015 16:51:23 +0000 (18:51 +0200)
tests/basic-types/bug643612.vala
vala/valaintegerliteral.vala

index 470e1f1e72ff7fda81b11fa1d6dca312ff3c3e3d..fca9d75adaa783af8184ee44a9cdacdf6991e4d3 100644 (file)
@@ -1,4 +1,8 @@
 void main() {
        int8 test1 = -128;
        int8 test2 = +127;
-}
\ No newline at end of file
+
+       /* 64-bit integer literals */
+       assert(0x80000000 == 0x80000000ll);
+       assert(-0x80000001 == -0x80000001ll);
+}
index 879bd2a7c0bf2f44355e02d04d4479d1aa41cb0a..77a5bc836decd4cd1380f9ba196fc8e29d74926b 100644 (file)
@@ -79,10 +79,10 @@ public class Vala.IntegerLiteral : Literal {
                }
                
                int64 n = int64.parse (value);
-               if (!u && n > 0x7fffffff) {
+               if (!u && (n > int.MAX || n < int.MIN)) {
                        // value doesn't fit into signed 32-bit
                        l = 2;
-               } else if (u && n > 0xffffffff) {
+               } else if (u && n > uint.MAX) {
                        // value doesn't fit into unsigned 32-bit
                        l = 2;
                }