]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Add type declaration for implicit temporary local variable
authorRico Tzschichholz <ricotz@ubuntu.com>
Sat, 18 Sep 2021 21:30:31 +0000 (23:30 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sat, 18 Sep 2021 21:45:33 +0000 (23:45 +0200)
14 files changed:
codegen/valaccodebasemodule.vala
tests/Makefile.am
tests/annotations/description.c-expected
tests/asynchronous/catch-error-scope.c-expected
tests/asynchronous/catch-in-finally.c-expected
tests/delegates/implicit-local-variable.c-expected [new file with mode: 0644]
tests/delegates/implicit-local-variable.vala [new file with mode: 0644]
tests/enums/no_gtype_to_string.c-expected
tests/errors/bug639589.c-expected
tests/errors/catch-in-finally.c-expected
tests/errors/errors.c-expected
tests/generics/inference-static-function.c-expected
tests/methods/argument-named.c-expected
tests/namespace/unique.c-expected

index f7321b72a2542729a29cc2f2b1f6dd51b737c35d..06b74546361e842bac2a5dbf4eb5417ce8540863 100644 (file)
@@ -3993,6 +3993,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
        }
 
        public void emit_temp_var (LocalVariable local, bool on_error = false) {
+               generate_type_declaration (local.variable_type, cfile);
+
                var init = (!local.name.has_prefix ("*") && local.init);
                if (is_in_coroutine ()) {
                        closure_struct.add_field (get_ccode_name (local.variable_type), local.name, 0, get_ccode_declarator_suffix (local.variable_type));
index d84703e651e2384c6cf9132568dc3f69936cf4c2..ed1ef59801c997c0f6760ba1be132dec22ebc526 100644 (file)
@@ -403,6 +403,7 @@ TESTS = \
        delegates/fields.vala \
        delegates/fields-no-target.vala \
        delegates/gclosure-conversion.vala \
+       delegates/implicit-local-variable.vala \
        delegates/incompatible.test \
        delegates/incompatible-assignment.test \
        delegates/incompatible-initializer.test \
index 4dbb7e569cfc3baad47db62dbb584b5ccf840dae..51dbbc59299f66dc54ba257549c8ae05f3ad4678 100644 (file)
@@ -3,6 +3,8 @@
 
 #include <glib-object.h>
 #include <glib.h>
+#include <stdlib.h>
+#include <string.h>
 
 #if !defined(VALA_EXTERN)
 #if defined(_MSC_VER)
index 77d20d30b002ef080b86c8c9509387e656c2e293..289b790294ca5ed9c4f33f947633a566916be233 100644 (file)
@@ -3,6 +3,8 @@
 
 #include <glib.h>
 #include <gio/gio.h>
+#include <stdlib.h>
+#include <string.h>
 #include <glib-object.h>
 
 #if !defined(VALA_EXTERN)
index 3364392a04ff0559911d8449eda501d5dca1c833..9779a393a15ce327d237d1d906c1875532ccd522 100644 (file)
@@ -4,6 +4,8 @@
 #include <glib.h>
 #include <gio/gio.h>
 #include <glib-object.h>
+#include <stdlib.h>
+#include <string.h>
 
 #if !defined(VALA_EXTERN)
 #if defined(_MSC_VER)
diff --git a/tests/delegates/implicit-local-variable.c-expected b/tests/delegates/implicit-local-variable.c-expected
new file mode 100644 (file)
index 0000000..f38ba1d
--- /dev/null
@@ -0,0 +1,60 @@
+/* delegates_implicit_local_variable.c generated by valac, the Vala compiler
+ * generated from delegates_implicit_local_variable.vala, do not modify */
+
+#include <glib.h>
+
+typedef gboolean (*GSourceDispatchFunc) (GSource* source, GSourceFunc _callback, gpointer _callback_target);
+#define _g_source_unref0(var) ((var == NULL) ? NULL : (var = (g_source_unref (var), NULL)))
+
+static void _vala_main (void);
+static gboolean __lambda4_ (void);
+static gboolean ___lambda4__gsource_dispatch_func (GSource* source,
+                                            GSourceFunc _callback,
+                                            gpointer _callback_target);
+
+static gboolean
+__lambda4_ (void)
+{
+       gboolean result = FALSE;
+       result = FALSE;
+       return result;
+}
+
+static gboolean
+___lambda4__gsource_dispatch_func (GSource* source,
+                                   GSourceFunc _callback,
+                                   gpointer _callback_target)
+{
+       gboolean result;
+       result = __lambda4_ ();
+       return result;
+}
+
+static void
+_vala_main (void)
+{
+       GSourceFuncs foo = {0};
+       GSourceFuncs _tmp0_ = {0};
+       GSource* bar = NULL;
+       GSourceFuncs _tmp1_;
+       GSourceDispatchFunc _tmp2_;
+       _tmp0_.prepare = NULL;
+       _tmp0_.check = NULL;
+       _tmp0_.dispatch = ___lambda4__gsource_dispatch_func;
+       _tmp0_.finalize = NULL;
+       foo = _tmp0_;
+       bar = NULL;
+       _tmp1_ = foo;
+       _tmp2_ = _tmp1_.dispatch;
+       _tmp2_ (bar, NULL, NULL);
+       _g_source_unref0 (bar);
+}
+
+int
+main (int argc,
+      char ** argv)
+{
+       _vala_main ();
+       return 0;
+}
+
diff --git a/tests/delegates/implicit-local-variable.vala b/tests/delegates/implicit-local-variable.vala
new file mode 100644 (file)
index 0000000..ffe1d31
--- /dev/null
@@ -0,0 +1,6 @@
+void main () {
+       SourceFuncs foo = { null, null, () => { return false; }, null };
+       Source bar = null;
+
+       foo.dispatch (bar, null);
+}
index 872f19b853f92877ba2e2d4eab3b882afa41a07b..89201fa8b705cb488a937807a0e91af25ea2ba61 100644 (file)
@@ -3,6 +3,8 @@
 
 #include <glib.h>
 #include <glib-object.h>
+#include <stdlib.h>
+#include <string.h>
 
 typedef enum  {
        FOO_BAR,
index 59ebaf5083e0426d70499f2b7c40272be36db62b..f3e3c8212971f2222147f9f8945ca5e66a0c1d0d 100644 (file)
@@ -3,6 +3,8 @@
 
 #include <glib.h>
 #include <glib-object.h>
+#include <stdlib.h>
+#include <string.h>
 
 #if !defined(VALA_EXTERN)
 #if defined(_MSC_VER)
index 43991a3dc6eb5e6656ce9acab2f0c8fd9cb201e1..cecb359e85e09f4f1df597ca9e7c335f8b49e994 100644 (file)
@@ -2,6 +2,8 @@
  * generated from errors_catch_in_finally.vala, do not modify */
 
 #include <glib.h>
+#include <stdlib.h>
+#include <string.h>
 
 #if !defined(VALA_EXTERN)
 #if defined(_MSC_VER)
index 4578d64f7b448d4678dfd1f02f6e2f56a32bac39..f688fd06feb95637a675c067bd66919d72638afa 100644 (file)
@@ -4,6 +4,8 @@
 #include <glib.h>
 #include <glib-object.h>
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 
 #if !defined(VALA_EXTERN)
 #if defined(_MSC_VER)
index e01e2be62cd3bc41c0c0c10c68244fb58f2f5178..df21829822a63f9d683c9b81f834a956f25938cc 100644 (file)
@@ -4,6 +4,8 @@
 #include <glib-object.h>
 #include <glib.h>
 #include <gobject/gvaluecollector.h>
+#include <stdlib.h>
+#include <string.h>
 
 #if !defined(VALA_EXTERN)
 #if defined(_MSC_VER)
index b86950951efa4f7a417df696cee2b5370ce15f35..c44c032fa17ed05ff21eb280d87ef5035e801574 100644 (file)
@@ -4,6 +4,8 @@
 #include <glib-object.h>
 #include <glib.h>
 #include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
 #include <gobject/gvaluecollector.h>
 
 #if !defined(VALA_EXTERN)
index 10dd574b46cdce2cc85934a21a5d47b005746d13..41ed4a820dbd24edd15e985538860bda01a90ea7 100644 (file)
@@ -4,6 +4,8 @@
 #include <glib-object.h>
 #include <gobject/gvaluecollector.h>
 #include <glib.h>
+#include <stdlib.h>
+#include <string.h>
 
 #if !defined(VALA_EXTERN)
 #if defined(_MSC_VER)