From: Rico Tzschichholz Date: Sun, 5 Apr 2020 20:24:58 +0000 (+0200) Subject: codegen: Don't pass CCodeCastExpression to NULL-aware free macro X-Git-Tag: 0.49.1~197 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4591fa50d2de24bac94347c477ccb25314179b15;p=thirdparty%2Fvala.git 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 --- 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 () + }; +}