[vala/0.40] vala: Handle PointerType and VoidType in Constant.check_const_type()
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.40] vala: Handle PointerType and VoidType in Constant.check_const_type()
- Date: Thu, 5 Mar 2020 18:44:22 +0000 (UTC)
commit 092a296296a3311698e683237fa922d764f288c7
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Tue Feb 18 17:12:19 2020 +0100
vala: Handle PointerType and VoidType in Constant.check_const_type()
This caused criticals like:
vala_typesymbol_is_subtype_of: assertion 'self != NULL' failed
tests/Makefile.am | 1 +
tests/semantic/constant-pointer.test | 6 ++++++
vala/valaconstant.vala | 2 ++
3 files changed, 9 insertions(+)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f3d97b2d3..711103c40 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -638,6 +638,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 1599b267f..e96b047e0 100644
--- a/vala/valaconstant.vala
+++ b/vala/valaconstant.vala
@@ -195,6 +195,8 @@ public class Vala.Constant : Symbol, Lockable {
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) {
var array_type = type as ArrayType;
return check_const_type (array_type.element_type, context);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]