[vala] codegen: Don't use simple struct initializer if local is a GValue



commit 77730a80c70d948e29d3eee0566ae558bad7170d
Author: Luca Bruno <lucabru src gnome org>
Date:   Wed May 11 09:47:51 2011 +0200

    codegen: Don't use simple struct initializer if local is a GValue
    
    Fixes bug 621176.

 codegen/valaccodebasemodule.vala |    2 +-
 tests/Makefile.am                |    1 +
 tests/structs/bug621176.vala     |    8 ++++++++
 3 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index b0a9324..9b86093 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -2003,7 +2003,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 		var st = local.variable_type.data_type as Struct;
 		var initializer = local.initializer as ObjectCreationExpression;
 		if (st != null && (!st.is_simple_type () || st.get_cname () == "va_list") && !local.variable_type.nullable &&
-		    initializer != null && initializer.get_object_initializer ().size == 0) {
+		    local.variable_type.data_type != gvalue_type && initializer != null && initializer.get_object_initializer ().size == 0) {
 			return true;
 		} else {
 			return false;
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 1cb60fc..95cb9ea 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -52,6 +52,7 @@ TESTS = \
 	structs/bug606202.vala \
 	structs/bug613513.vala \
 	structs/bug613825.vala \
+	structs/bug621176.vala \
 	structs/bug622422.vala \
 	delegates/delegates.vala \
 	delegates/bug595610.vala \
diff --git a/tests/structs/bug621176.vala b/tests/structs/bug621176.vala
new file mode 100644
index 0000000..5487208
--- /dev/null
+++ b/tests/structs/bug621176.vala
@@ -0,0 +1,8 @@
+struct Foo {
+	int i;
+}
+
+void main () {
+	Value v = Foo ();
+	assert (v.type() == typeof (Foo));
+}



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