]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Cast return value of generic type accessor functions
authorRico Tzschichholz <ricotz@ubuntu.com>
Sun, 5 Feb 2023 18:33:15 +0000 (19:33 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sun, 5 Feb 2023 19:05:30 +0000 (20:05 +0100)
Found by -Wincompatible-function-pointer-types

See https://gitlab.gnome.org/GNOME/vala/issues/1408

codegen/valagtypemodule.vala
tests/generics/bug640330.c-expected
tests/objects/interface-async-captured-generic.c-expected

index b3d7d247fadcf04d3b16356cfd3e823229d7f75d..0d9fae48269da53f51d49c8b76a74449b0505977 100644 (file)
@@ -1404,7 +1404,7 @@ public class Vala.GTypeModule : GErrorModule {
                var this_type = SemanticAnalyzer.get_data_type_for_symbol (cl);
                function.add_parameter (new CCodeParameter ("self", get_ccode_name (this_type)));
                push_function (function);
-               ccode.add_return (expression);
+               ccode.add_return (new CCodeCastExpression (expression, return_type));
                pop_function ();
                cfile.add_function (function);
 
index 4b9d88858bbf417847e466056a804bed13711192..22aafedeb77e30ac11331a82e280deea809d531f 100644 (file)
@@ -210,19 +210,19 @@ bar_class_init (BarClass * klass,
 static GType
 bar_foo_get_g_type (Bar* self)
 {
-       return self->priv->g_type;
+       return (GType) self->priv->g_type;
 }
 
 static GBoxedCopyFunc
 bar_foo_get_g_dup_func (Bar* self)
 {
-       return self->priv->g_dup_func;
+       return (GBoxedCopyFunc) self->priv->g_dup_func;
 }
 
 static GDestroyNotify
 bar_foo_get_g_destroy_func (Bar* self)
 {
-       return self->priv->g_destroy_func;
+       return (GDestroyNotify) self->priv->g_destroy_func;
 }
 
 static void
index ed43ffed9bb15f6cbae6c85c6f700dfbaa55ee48..ece032b760a8a853cd3614a2f76175918773a2ea 100644 (file)
@@ -223,19 +223,19 @@ foo_class_init (FooClass * klass,
 static GType
 foo_ifoo_get_g_type (Foo* self)
 {
-       return G_TYPE_STRING;
+       return (GType) G_TYPE_STRING;
 }
 
 static GBoxedCopyFunc
 foo_ifoo_get_g_dup_func (Foo* self)
 {
-       return g_strdup;
+       return (GBoxedCopyFunc) g_strdup;
 }
 
 static GDestroyNotify
 foo_ifoo_get_g_destroy_func (Foo* self)
 {
-       return g_free;
+       return (GDestroyNotify) g_free;
 }
 
 static void