[vala] codegen: fix generating struct equal function
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] codegen: fix generating struct equal function
- Date: Sun, 21 Jun 2015 10:24:03 +0000 (UTC)
commit 207e696f08247510c12ef671344bf5af026559ea
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sun Jun 21 12:23:02 2015 +0200
codegen: fix generating struct equal function
Fixes bug 749952
codegen/valaccodebasemodule.vala | 8 ++++----
tests/Makefile.am | 1 +
tests/structs/bug749952.vala | 14 ++++++++++++++
3 files changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index e1c6a63..78e52dc 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -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;
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 32026c8..343da51 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -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
index 0000000..212edc5
--- /dev/null
+++ b/tests/structs/bug749952.vala
@@ -0,0 +1,14 @@
+struct Foo {
+ int i;
+}
+
+struct Bar : Foo {
+}
+
+void main () {
+ Bar b1 = {};
+ Bar b2 = {};
+
+ assert (b1 == b2);
+ assert (b2 == b1);
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]