]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Skip StructRegisterFunction for boolean/integer/floating types
authorRico Tzschichholz <ricotz@ubuntu.com>
Fri, 24 Jan 2020 22:29:01 +0000 (23:29 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sat, 25 Jan 2020 17:52:59 +0000 (18:52 +0100)
Fixes https://gitlab.gnome.org/GNOME/vala/issues/901

codegen/valaccodestructmodule.vala
codegen/valagtypemodule.vala
tests/Makefile.am
tests/structs/struct-no-gtype-inherit.vala [new file with mode: 0644]

index 2cd56bb67f56824d873cb5878850bbc25e0f74e7..c2882047da4227f03f8b4bc5ffdc9f6ee205f1b4 100644 (file)
@@ -31,6 +31,7 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
                }
 
                if (st.is_boolean_type () || st.is_integer_type () || st.is_floating_type ()) {
+                       // See GTypeModule.visit_struct()
                        if (st.base_struct != null) {
                                generate_struct_declaration (st.base_struct, decl_space);
                                decl_space.add_type_declaration (new CCodeTypeDefinition (get_ccode_name (st.base_struct), new CCodeVariableDeclarator (get_ccode_name (st))));
index 72007249bd75e1f4ad16d3087e88b6bcf0fb2c88..cbb38398e55deb7ff05f713122b0efd04633c3e8 100644 (file)
@@ -2242,6 +2242,12 @@ public class Vala.GTypeModule : GErrorModule {
        public override void visit_struct (Struct st) {
                base.visit_struct (st);
 
+               if (st.is_boolean_type () || st.is_integer_type () || st.is_floating_type ()) {
+                       // Skip GType handling for these struct types,
+                       // like in CCodeStructModule.generate_struct_declaration()
+                       return;
+               }
+
                if (get_ccode_has_type_id (st)) {
                        push_line (st.source_reference);
                        var type_fun = new StructRegisterFunction (st);
index 24f9d16224f374c52f5b93ddf1a061603eac7e82..81cde2fe9e093a6829d40a034eb0191153d239a6 100644 (file)
@@ -241,6 +241,7 @@ TESTS = \
        structs/struct-base-types.vala \
        structs/struct-empty-still.test \
        structs/struct-no-gtype.vala \
+       structs/struct-no-gtype-inherit.vala \
        structs/struct-static-field-initializer.vala \
        structs/struct-static-field-initializer.test \
        structs/struct-static-property-initializer.test \
diff --git a/tests/structs/struct-no-gtype-inherit.vala b/tests/structs/struct-no-gtype-inherit.vala
new file mode 100644 (file)
index 0000000..3dc3e8c
--- /dev/null
@@ -0,0 +1,11 @@
+[SimpleType]
+[IntegerType (rank = 6, signed = true, width = 32)]
+[CCode (has_type_id = false)]
+struct foo_t {
+}
+
+struct bar_t : foo_t {
+}
+
+void main () {
+}