[vala] Fix 64-bit negative integer literals



commit 6a16ac94e0d8fd5918072e3c40d921882323fbbf
Author: Jürg Billeter <j bitron ch>
Date:   Mon Jun 22 18:50:47 2015 +0200

    Fix 64-bit negative integer literals

 tests/basic-types/bug643612.vala |    6 +++++-
 vala/valaintegerliteral.vala     |    4 ++--
 2 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/tests/basic-types/bug643612.vala b/tests/basic-types/bug643612.vala
index 470e1f1..fca9d75 100644
--- a/tests/basic-types/bug643612.vala
+++ b/tests/basic-types/bug643612.vala
@@ -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);
+}
diff --git a/vala/valaintegerliteral.vala b/vala/valaintegerliteral.vala
index 879bd2a..77a5bc8 100644
--- a/vala/valaintegerliteral.vala
+++ b/vala/valaintegerliteral.vala
@@ -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;
                }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]