]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Handle PointerType and VoidType in Constant.check_const_type()
authorRico Tzschichholz <ricotz@ubuntu.com>
Tue, 18 Feb 2020 16:12:19 +0000 (17:12 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Tue, 18 Feb 2020 16:19:27 +0000 (17:19 +0100)
This caused criticals like:

  vala_typesymbol_is_subtype_of: assertion 'self != NULL' failed

tests/Makefile.am
tests/semantic/constant-pointer.test [new file with mode: 0644]
vala/valaconstant.vala

index f683d18c7ac8ba049bf72cf20fd9595137c501e8..071935bd1f1e0680ad9aac298eead81640ffa41e 100644 (file)
@@ -733,6 +733,7 @@ TESTS = \
        semantic/class-too-few-type-arguments.test \
        semantic/class-too-many-type-arguments.test \
        semantic/constant-extern.test \
+       semantic/constant-pointer.test \
        semantic/constant-value.test \
        semantic/constant-value-missing.test \
        semantic/constant-value-type.test \
diff --git a/tests/semantic/constant-pointer.test b/tests/semantic/constant-pointer.test
new file mode 100644 (file)
index 0000000..23235c2
--- /dev/null
@@ -0,0 +1,6 @@
+Invalid Code
+
+const int* FOO = 0;
+
+void main () {
+}
index 3ff4bf3c4f994018498672051c91c2a8d8c8c2be..809cb883dba241133afe6e4ffe49e207bd0a1f6e 100644 (file)
@@ -185,6 +185,8 @@ public class Vala.Constant : Symbol {
        bool check_const_type (DataType type, CodeContext context) {
                if (type is ValueType) {
                        return true;
+               } else if (type is VoidType || type is PointerType) {
+                       return false;
                } else if (type is ArrayType) {
                        unowned ArrayType array_type = (ArrayType) type;
                        return check_const_type (array_type.element_type, context);