]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Fix types of temporary variables when using GArray or va_list
authorJürg Billeter <j@bitron.ch>
Sun, 10 Oct 2010 20:59:03 +0000 (22:59 +0200)
committerJürg Billeter <j@bitron.ch>
Sun, 10 Oct 2010 20:59:03 +0000 (22:59 +0200)
codegen/valaccodemethodcallmodule.vala

index 0b5e879c4268b4faffe2db3d0211077cf729f69a..540a54ca622789ea4b9dbdf04672e8177a3f51d0 100644 (file)
@@ -793,7 +793,20 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
                if (expr.parent_node is ExpressionStatement) {
                        ccode.add_expression (ccall_expr);
                } else {
-                       var temp_var = get_temp_variable (itype.get_return_type ());
+                       var result_type = itype.get_return_type ();
+
+                       if (expr.formal_value_type is GenericType && !(expr.value_type is GenericType)) {
+                               var st = expr.formal_value_type.type_parameter.parent_symbol.parent_symbol as Struct;
+                               if (expr.formal_value_type.type_parameter.parent_symbol == garray_type ||
+                                   (st != null && st.get_cname () == "va_list")) {
+                                       // GArray and va_list don't use pointer-based generics
+                                       // above logic copied from visit_expression ()
+                                       // TODO avoid code duplication
+                                       result_type = expr.value_type;
+                               }
+                       }
+
+                       var temp_var = get_temp_variable (result_type);
                        var temp_ref = get_variable_cexpression (temp_var.name);
 
                        emit_temp_var (temp_var);