[vala] Fix local variable initialization of basic types



commit c3abd714298cd9cb3d37fc3391afac983c851e4a
Author: Jürg Billeter <j bitron ch>
Date:   Mon Apr 20 16:30:16 2009 +0200

    Fix local variable initialization of basic types
---
 gobject/valaccodebasemodule.vala |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/gobject/valaccodebasemodule.vala b/gobject/valaccodebasemodule.vala
index 6ba6e17..625a8aa 100644
--- a/gobject/valaccodebasemodule.vala
+++ b/gobject/valaccodebasemodule.vala
@@ -3722,9 +3722,11 @@ internal class Vala.CCodeBaseModule : CCodeModule {
 	}
 
 	public CCodeExpression? default_value_for_type (DataType type, bool initializer_expression) {
+		var st = type.data_type as Struct;
 		var array_type = type as ArrayType;
-		if (initializer_expression && (type.data_type is Struct ||
-		    (array_type != null && array_type.fixed_length))) {
+		if (initializer_expression &&
+		    ((st != null && !st.is_simple_type ()) ||
+		     (array_type != null && array_type.fixed_length))) {
 			// 0-initialize struct with struct initializer { 0 }
 			// only allowed as initializer expression in C
 			var clist = new CCodeInitializerList ();



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