[vala/0.40] codegen: Don't apply address-of operator on literals when casting to array
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.40] codegen: Don't apply address-of operator on literals when casting to array
- Date: Mon, 21 Jan 2019 16:58:51 +0000 (UTC)
commit ed89b25c8d8d647a77a22f1ebcf062c7e07079a0
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sun Jan 20 19:23:43 2019 +0100
codegen: Don't apply address-of operator on literals when casting to array
Regression of 5f316333d6a803e4240b5cccc95a6abd2294137b
https://bugzilla.gnome.org/show_bug.cgi?id=777194
codegen/valaccodebasemodule.vala | 2 +-
tests/Makefile.am | 1 +
tests/structs/bug777194-2.vala | 7 +++++++
3 files changed, 9 insertions(+), 1 deletion(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 556cb06bd..afd007dae 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -5335,7 +5335,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);
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 777e45dea..ccf7ef0ef 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -215,6 +215,7 @@ TESTS = \
structs/bug764041.test \
structs/bug775761.vala \
structs/bug777194.vala \
+ structs/bug777194-2.vala \
delegates/casting.vala \
delegates/compatible.vala \
delegates/delegates.vala \
diff --git a/tests/structs/bug777194-2.vala b/tests/structs/bug777194-2.vala
new file mode 100644
index 000000000..5caa9e8dd
--- /dev/null
+++ b/tests/structs/bug777194-2.vala
@@ -0,0 +1,7 @@
+[CCode (array_length = false)]
+unowned int[] foo;
+
+void main () {
+ foo = (int[]) 0;
+ assert (foo == null);
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]