From: Florian Brosch Date: Sat, 21 Jan 2012 11:55:11 +0000 (+0100) Subject: tag sizeof as constant X-Git-Tag: 0.15.1~30 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=714bfd1429db327940541f03022ee8374c22db62;p=thirdparty%2Fvala.git tag sizeof as constant --- diff --git a/tests/Makefile.am b/tests/Makefile.am index 39e49ce9e..41760d88b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 index 000000000..931891f28 --- /dev/null +++ b/tests/basic-types/sizeof.vala @@ -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)); +} + + + diff --git a/vala/valasizeofexpression.vala b/vala/valasizeofexpression.vala index 01fda86c5..42c1ee599 100644 --- a/vala/valasizeofexpression.vala +++ b/vala/valasizeofexpression.vala @@ -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;