]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Explicitly include <glib.h> as needed for null-literal 07803d9328c2294fa1864b3f910c680c26646a7d
authorRico Tzschichholz <ricotz@ubuntu.com>
Sat, 1 Feb 2020 15:37:36 +0000 (16:37 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sat, 1 Feb 2020 15:40:17 +0000 (16:40 +0100)
codegen/valaccodebasemodule.vala
tests/Makefile.am
tests/basic-types/null.vala [new file with mode: 0644]

index ee1c4fbb15dc2997efbc338731751b7d67f0f1f4..f8ff16872340b86d67969137422002f7a0d26a61 100644 (file)
@@ -4308,7 +4308,9 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
        }
 
        public override void visit_null_literal (NullLiteral expr) {
-               if (context.profile != Profile.GOBJECT) {
+               if (context.profile == Profile.GOBJECT) {
+                       cfile.add_include ("glib.h");
+               } else {
                        cfile.add_include ("stddef.h");
                }
                set_cvalue (expr, new CCodeConstant ("NULL"));
index 7166e74e0e4dd4450adb912c94111b66c36e725e..8079e335a4eb0e5a6e9a97ae6b46400112774c89 100644 (file)
@@ -37,6 +37,7 @@ TESTS = \
        basic-types/gptrarray.vala \
        basic-types/gvariants.vala \
        basic-types/gvariants-unboxing-safe.vala \
+       basic-types/null.vala \
        basic-types/bug570846.test \
        basic-types/bug571486.vala \
        basic-types/bug591552.vala \
diff --git a/tests/basic-types/null.vala b/tests/basic-types/null.vala
new file mode 100644 (file)
index 0000000..c633e35
--- /dev/null
@@ -0,0 +1,3 @@
+void main () {
+       void* foo = null;
+}