]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Don't use simple struct initializer if local is a GValue
authorLuca Bruno <lucabru@src.gnome.org>
Wed, 11 May 2011 07:47:51 +0000 (09:47 +0200)
committerJürg Billeter <j@bitron.ch>
Sun, 29 May 2011 10:44:50 +0000 (12:44 +0200)
Fixes bug 621176.

codegen/valaccodebasemodule.vala
tests/Makefile.am
tests/structs/bug621176.vala [new file with mode: 0644]

index b759d632c641ba90b7a2fffffec27708053edeee..d130235a670bdf227b67cbc0abdc9280d1964cfc 100644 (file)
@@ -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;
index ef71b559bda082bbd8af40920b59cce010298b1f..0d6e165022c06a0d050d6e2f33f0252edf7aaa31 100644 (file)
@@ -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 (file)
index 0000000..5487208
--- /dev/null
@@ -0,0 +1,8 @@
+struct Foo {
+       int i;
+}
+
+void main () {
+       Value v = Foo ();
+       assert (v.type() == typeof (Foo));
+}