]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: fix generating struct equal function
authorRico Tzschichholz <ricotz@ubuntu.com>
Sun, 21 Jun 2015 10:23:02 +0000 (12:23 +0200)
committerLuca Bruno <lucabru@src.gnome.org>
Sun, 21 Jun 2015 11:21:32 +0000 (13:21 +0200)
Fixes bug 749952

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

index e1c6a6357fa74c3bd4172612c4ec25748696650c..78e52dc07937c7e86c3abb956153876b0e1bacf5 100644 (file)
@@ -2736,6 +2736,10 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
        }
 
        private string generate_struct_equal_function (Struct st) {
+               if (st.base_struct != null) {
+                       return generate_struct_equal_function (st.base_struct);
+               }
+
                string equal_func = "_%sequal".printf (get_ccode_lower_case_prefix (st));
 
                if (!add_wrapper (equal_func)) {
@@ -2743,10 +2747,6 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                        return equal_func;
                }
 
-               if (st.base_struct != null) {
-                       return generate_struct_equal_function (st.base_struct);
-               }
-
                var function = new CCodeFunction (equal_func, "gboolean");
                function.modifiers = CCodeModifiers.STATIC;
 
index 32026c8b86a0d0acac377ee2778f816214700824..343da516e70afd315b2b10040e52c5da8b0abc25 100644 (file)
@@ -112,6 +112,7 @@ TESTS = \
        structs/bug685177.vala \
        structs/bug686190.vala \
        structs/bug690380.vala \
+       structs/bug749952.vala \
        delegates/delegates.vala \
        delegates/bug539166.vala \
        delegates/bug595610.vala \
diff --git a/tests/structs/bug749952.vala b/tests/structs/bug749952.vala
new file mode 100644 (file)
index 0000000..212edc5
--- /dev/null
@@ -0,0 +1,14 @@
+struct Foo {
+       int i;
+}
+
+struct Bar : Foo {
+}
+
+void main () {
+       Bar b1 = {};
+       Bar b2 = {};
+
+       assert (b1 == b2);
+       assert (b2 == b1);
+}