[vala/staging] codegen: Don't pass CCodeCastExpression to NULL-aware free macro
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] codegen: Don't pass CCodeCastExpression to NULL-aware free macro
- Date: Sun, 5 Apr 2020 20:29:54 +0000 (UTC)
commit 4591fa50d2de24bac94347c477ccb25314179b15
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sun Apr 5 22:24:58 2020 +0200
codegen: Don't pass CCodeCastExpression to NULL-aware free macro
This resulted in invalid C code:
error: lvalue required as left operand of assignment
Fixes https://gitlab.gnome.org/GNOME/vala/issues/953
codegen/valaccodebasemodule.vala | 5 +++++
tests/Makefile.am | 1 +
tests/objects/member-initializer-property.vala | 15 +++++++++++++++
3 files changed, 21 insertions(+)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index f58985b9e..a921cd755 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -3678,6 +3678,11 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
cfile.add_type_declaration (new CCodeMacroReplacement.with_expression
("%s(var)".printf (free0_func), macro));
}
+ // FIXME this breaks in our macro, so this should not happen
+ if (cvar is CCodeCastExpression) {
+ cvar = ((CCodeCastExpression) cvar).inner;
+ }
+
ccall = new CCodeFunctionCall (new CCodeIdentifier (free0_func));
ccall.add_argument (cvar);
return ccall;
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 88aaac40a..1d9aa496a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -384,6 +384,7 @@ TESTS = \
objects/interface-property-override.vala \
objects/interface-virtual-override.vala \
objects/member-initializer-base-properties.vala \
+ objects/member-initializer-property.vala \
objects/member-initializer-property-owned-setter.vala \
objects/methods.vala \
objects/paramspec.vala \
diff --git a/tests/objects/member-initializer-property.vala b/tests/objects/member-initializer-property.vala
new file mode 100644
index 000000000..cd71ed010
--- /dev/null
+++ b/tests/objects/member-initializer-property.vala
@@ -0,0 +1,15 @@
+class Baz {
+}
+
+class Bar : Baz {
+}
+
+class Foo {
+ public Baz baz { get; set; }
+}
+
+void main() {
+ var foo = new Foo () {
+ baz = new Bar ()
+ };
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]