From: Rico Tzschichholz Date: Fri, 24 Jan 2020 22:29:01 +0000 (+0100) Subject: codegen: Skip StructRegisterFunction for boolean/integer/floating types X-Git-Tag: 0.47.4~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=83acacae8a6afc59093714ba8b3454abc87b7d45;p=thirdparty%2Fvala.git codegen: Skip StructRegisterFunction for boolean/integer/floating types Fixes https://gitlab.gnome.org/GNOME/vala/issues/901 --- diff --git a/codegen/valaccodestructmodule.vala b/codegen/valaccodestructmodule.vala index 2cd56bb67..c2882047d 100644 --- a/codegen/valaccodestructmodule.vala +++ b/codegen/valaccodestructmodule.vala @@ -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)))); diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala index 72007249b..cbb38398e 100644 --- a/codegen/valagtypemodule.vala +++ b/codegen/valagtypemodule.vala @@ -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); diff --git a/tests/Makefile.am b/tests/Makefile.am index 24f9d1622..81cde2fe9 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 index 000000000..3dc3e8c0a --- /dev/null +++ b/tests/structs/struct-no-gtype-inherit.vala @@ -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 () { +}