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



commit 62ac470108294da888912323ec8af386480b6c1e
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 b759d63..d130235 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -2024,7 +2024,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 ef71b55..0d6e165 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -51,6 +51,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]