]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Fix postconditions for methods returning structs
authorAdam Folmert <afolmert@gmail.com>
Sun, 14 Feb 2010 02:57:37 +0000 (03:57 +0100)
committerJürg Billeter <j@bitron.ch>
Sun, 21 Mar 2010 23:12:00 +0000 (00:12 +0100)
Fixes bug 602927.

codegen/valaccodememberaccessmodule.vala

index edfa1333b608d525ee37012e3cb37642e92b040e..f55da3605420a98e252a09d753e1ce5e3c4b3606 100644 (file)
@@ -355,7 +355,12 @@ internal class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
                        var local = (LocalVariable) expr.symbol_reference;
                        if (local.is_result) {
                                // used in postconditions
-                               expr.ccodenode = new CCodeIdentifier ("result");
+                               // structs are returned as out parameter
+                               if (local.variable_type != null && local.variable_type.is_real_non_null_struct_type ()) {
+                                       expr.ccodenode = new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, new CCodeIdentifier ("result"));
+                               } else {
+                                       expr.ccodenode = new CCodeIdentifier ("result");
+                               }
                        } else if (local.captured) {
                                // captured variables are stored on the heap
                                var block = (Block) local.parent_symbol;