[vala/staging] codegen: Explicitly include <glib.h> as needed for null-literal



commit 07803d9328c2294fa1864b3f910c680c26646a7d
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sat Feb 1 16:37:36 2020 +0100

    codegen: Explicitly include <glib.h> as needed for null-literal

 codegen/valaccodebasemodule.vala | 4 +++-
 tests/Makefile.am                | 1 +
 tests/basic-types/null.vala      | 3 +++
 3 files changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index ee1c4fbb1..f8ff16872 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -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"));
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 7166e74e0..8079e335a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -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
index 000000000..c633e355b
--- /dev/null
+++ b/tests/basic-types/null.vala
@@ -0,0 +1,3 @@
+void main () {
+       void* foo = null;
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]