[vala/wip/bug769229: 5/6] codegen: Avoid temporary variables for calls to [FormatArg] methods



commit 3267326016f52353c36a07ed12a88d09708c8b77
Author: Jürg Billeter <j bitron ch>
Date:   Tue Nov 1 18:03:17 2016 +0100

    codegen: Avoid temporary variables for calls to [FormatArg] methods
    
    This prevents bogus C compiler warnings with -Wformat-nonliteral.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=769229

 codegen/valaccodemethodcallmodule.vala |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala
index 2cd12b6..7786d1b 100644
--- a/codegen/valaccodemethodcallmodule.vala
+++ b/codegen/valaccodemethodcallmodule.vala
@@ -787,7 +787,9 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
                                }
                        }
 
-                       if (!return_result_via_out_param) {
+                       if (m != null && m.get_format_arg_index () >= 0) {
+                               set_cvalue (expr, ccall_expr);
+                       } else if (!return_result_via_out_param) {
                                var temp_var = get_temp_variable (result_type, result_type.value_owned);
                                var temp_ref = get_variable_cexpression (temp_var.name);
 
@@ -795,10 +797,11 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
 
                                ccode.add_assignment (temp_ref, ccall_expr);
                                set_cvalue (expr, temp_ref);
+                               ((GLibValue) expr.target_value).lvalue = true;
                        } else {
                                set_cvalue (expr, ccall_expr);
+                               ((GLibValue) expr.target_value).lvalue = true;
                        }
-                       ((GLibValue) expr.target_value).lvalue = true;
                }
 
                params_it = params.iterator ();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]