From: Rico Tzschichholz Date: Tue, 18 Feb 2020 16:12:19 +0000 (+0100) Subject: vala: Handle PointerType and VoidType in Constant.check_const_type() X-Git-Tag: 0.47.92~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4f5221e7fe44ee5fb1a1df422d6e317ccd87d6ac;p=thirdparty%2Fvala.git vala: Handle PointerType and VoidType in Constant.check_const_type() This caused criticals like: vala_typesymbol_is_subtype_of: assertion 'self != NULL' failed --- diff --git a/tests/Makefile.am b/tests/Makefile.am index f683d18c7..071935bd1 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 index 000000000..23235c23e --- /dev/null +++ b/tests/semantic/constant-pointer.test @@ -0,0 +1,6 @@ +Invalid Code + +const int* FOO = 0; + +void main () { +} diff --git a/vala/valaconstant.vala b/vala/valaconstant.vala index 3ff4bf3c4..809cb883d 100644 --- a/vala/valaconstant.vala +++ b/vala/valaconstant.vala @@ -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);