]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Don't apply address-of operator on literals when casting to array
authorRico Tzschichholz <ricotz@ubuntu.com>
Sun, 20 Jan 2019 18:23:43 +0000 (19:23 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Mon, 21 Jan 2019 12:59:27 +0000 (13:59 +0100)
Regression of 5f316333d6a803e4240b5cccc95a6abd2294137b

https://bugzilla.gnome.org/show_bug.cgi?id=777194

codegen/valaccodebasemodule.vala
tests/Makefile.am
tests/structs/bug777194-2.vala [new file with mode: 0644]

index 89ed181a8c7a23943eda875996f70e6f53297360..2e77ea30d6a64f50c617afa7133710f333980409 100644 (file)
@@ -5414,7 +5414,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                                expr.inner.value_type is ValueType && expr.inner.value_type.nullable) {
                                // nullable integer or float or boolean or struct or enum cast to non-nullable
                                innercexpr = new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, innercexpr);
-                       } else if (expr.type_reference is ArrayType
+                       } else if (expr.type_reference is ArrayType && !(expr.inner is Literal)
                            && expr.inner.value_type is ValueType && !expr.inner.value_type.nullable) {
                                // integer or float or boolean or struct or enum to array cast
                                innercexpr = new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, innercexpr);
index 93cbe1611528a085b729a92b419250a90a1ce5b5..144a095da65c0499e487c52d5db5518f9b866947 100644 (file)
@@ -223,6 +223,7 @@ TESTS = \
        structs/bug764041.test \
        structs/bug775761.vala \
        structs/bug777194.vala \
+       structs/bug777194-2.vala \
        delegates/casting.vala \
        delegates/compatible.vala \
        delegates/delegate_only.vala \
diff --git a/tests/structs/bug777194-2.vala b/tests/structs/bug777194-2.vala
new file mode 100644 (file)
index 0000000..5caa9e8
--- /dev/null
@@ -0,0 +1,7 @@
+[CCode (array_length = false)]
+unowned int[] foo;
+
+void main () {
+       foo = (int[]) 0;
+       assert (foo == null);
+}