]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
tag sizeof as constant
authorFlorian Brosch <flo.brosch@gmail.com>
Sat, 21 Jan 2012 11:55:11 +0000 (12:55 +0100)
committerFlorian Brosch <flo.brosch@gmail.com>
Sat, 21 Jan 2012 13:02:58 +0000 (14:02 +0100)
tests/Makefile.am
tests/basic-types/sizeof.vala [new file with mode: 0644]
vala/valasizeofexpression.vala

index 39e49ce9ec776a2cf1541cba99e53a41cc2781fe..41760d88b7b2a86422ce9dd3fb5b22e1939c4ff3 100644 (file)
@@ -20,6 +20,7 @@ TESTS = \
        basic-types/strings.vala \
        basic-types/arrays.vala \
        basic-types/pointers.vala \
+       basic-types/sizeof.vala \
        basic-types/bug591552.vala \
        basic-types/bug595751.vala \
        basic-types/bug596637.vala \
diff --git a/tests/basic-types/sizeof.vala b/tests/basic-types/sizeof.vala
new file mode 100644 (file)
index 0000000..931891f
--- /dev/null
@@ -0,0 +1,12 @@
+
+
+public const size_t simple_size = sizeof (int);
+public const size_t composed_size = sizeof (int) + sizeof (size_t);
+
+static void main () {
+       assert (composed_size == (sizeof (int) + sizeof (size_t)));
+       assert (simple_size == sizeof (int));
+}
+
+
+
index 01fda86c51f59bf12aadd507d8dd29d870fc622d..42c1ee5991bbc130e26addc3da157fdb56d2eb82 100644 (file)
@@ -65,6 +65,10 @@ public class Vala.SizeofExpression : Expression {
                return true;
        }
 
+       public override bool is_constant () {
+               return true;
+       }
+
        public override void replace_type (DataType old_type, DataType new_type) {
                if (type_reference == old_type) {
                        type_reference = new_type;