Commit 135d9c99 authored by Rico Tzschichholz's avatar Rico Tzschichholz

codegen: Don't apply address-of operator on literals when casting to array

Regression of 5f316333

https://bugzilla.gnome.org/show_bug.cgi?id=777194
parent 2b86cba8
...@@ -5440,7 +5440,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator { ...@@ -5440,7 +5440,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
expr.inner.value_type is ValueType && expr.inner.value_type.nullable) { 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 // nullable integer or float or boolean or struct or enum cast to non-nullable
innercexpr = new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, innercexpr); 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) { && expr.inner.value_type is ValueType && !expr.inner.value_type.nullable) {
// integer or float or boolean or struct or enum to array cast // integer or float or boolean or struct or enum to array cast
innercexpr = new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, innercexpr); innercexpr = new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, innercexpr);
......
...@@ -229,6 +229,7 @@ TESTS = \ ...@@ -229,6 +229,7 @@ TESTS = \
structs/bug764041.test \ structs/bug764041.test \
structs/bug775761.vala \ structs/bug775761.vala \
structs/bug777194.vala \ structs/bug777194.vala \
structs/bug777194-2.vala \
delegates/casting.vala \ delegates/casting.vala \
delegates/compatible.vala \ delegates/compatible.vala \
delegates/delegate_only.vala \ delegates/delegate_only.vala \
......
[CCode (array_length = false)]
unowned int[] foo;
void main () {
foo = (int[]) 0;
assert (foo == null);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment