[vala/staging: 1/4] Revert "Always initialize temp variables to fix fatal warnings of GCC 4.8"
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging: 1/4] Revert "Always initialize temp variables to fix fatal warnings of GCC 4.8"
- Date: Thu, 10 Nov 2016 09:51:40 +0000 (UTC)
commit e2422670e9438153faa697c5aedc7653289f7354
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Thu Nov 10 09:21:19 2016 +0100
Revert "Always initialize temp variables to fix fatal warnings of GCC 4.8"
This reverts commit eeb861dfba147bc37cfc7a9c22e1b582cf20ff31.
codegen/valaccodebasemodule.vala | 29 +++++++++++++++++------------
vala/valalocalvariable.vala | 1 -
2 files changed, 17 insertions(+), 13 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index adccba7..3921b0e 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -3471,27 +3471,32 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
public void emit_temp_var (LocalVariable local) {
+ var init = !(local.name.has_prefix ("*") || local.no_init);
if (is_in_coroutine ()) {
closure_struct.add_field (get_ccode_name (local.variable_type), local.name);
// even though closure struct is zerod, we need to initialize temporary variables
// as they might be used multiple times when declared in a loop
- var initializer = default_value_for_type (local.variable_type, false);
- if (initializer == null) {
- cfile.add_include ("string.h");
- var memset_call = new CCodeFunctionCall (new CCodeIdentifier ("memset"));
- memset_call.add_argument (new CCodeUnaryExpression
(CCodeUnaryOperator.ADDRESS_OF, get_variable_cexpression (local.name)));
- memset_call.add_argument (new CCodeConstant ("0"));
- memset_call.add_argument (new CCodeIdentifier ("sizeof (%s)".printf
(get_ccode_name (local.variable_type))));
- ccode.add_expression (memset_call);
- } else {
- ccode.add_assignment (get_variable_cexpression (local.name), initializer);
+ if (init) {
+ var initializer = default_value_for_type (local.variable_type, false);
+ if (initializer == null) {
+ cfile.add_include ("string.h");
+ var memset_call = new CCodeFunctionCall (new CCodeIdentifier
("memset"));
+ memset_call.add_argument (new CCodeUnaryExpression
(CCodeUnaryOperator.ADDRESS_OF, get_variable_cexpression (local.name)));
+ memset_call.add_argument (new CCodeConstant ("0"));
+ memset_call.add_argument (new CCodeIdentifier ("sizeof (%s)".printf
(get_ccode_name (local.variable_type))));
+ ccode.add_expression (memset_call);
+ } else {
+ ccode.add_assignment (get_variable_cexpression (local.name),
initializer);
+ }
}
} else {
var cvar = new CCodeVariableDeclarator (local.name, null, get_ccode_declarator_suffix
(local.variable_type));
- cvar.initializer = default_value_for_type (local.variable_type, true);
- cvar.init0 = true;
+ if (init) {
+ cvar.initializer = default_value_for_type (local.variable_type, true);
+ cvar.init0 = true;
+ }
ccode.add_declaration (get_ccode_name (local.variable_type), cvar);
}
}
diff --git a/vala/valalocalvariable.vala b/vala/valalocalvariable.vala
index a7979f7..db172e3 100644
--- a/vala/valalocalvariable.vala
+++ b/vala/valalocalvariable.vala
@@ -30,7 +30,6 @@ public class Vala.LocalVariable : Variable {
public bool captured { get; set; }
- /* Currently ignored due to GCC 4.8 being strict on possibly uninitialized variables */
public bool no_init { get; set; }
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]