[vala/0.46] vala: Don't allow "va_list" as return-type or type of fields
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.46] vala: Don't allow "va_list" as return-type or type of fields
- Date: Wed, 5 Feb 2020 10:03:01 +0000 (UTC)
commit 6cee4d12013cd465db42d504c9101dba219fedf3
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Tue Dec 3 13:02:13 2019 +0100
vala: Don't allow "va_list" as return-type or type of fields
Fixes https://gitlab.gnome.org/GNOME/vala/issues/884
tests/Makefile.am | 4 ++++
tests/semantic/delegate-return-valist.test | 6 ++++++
tests/semantic/field-valist.test | 6 ++++++
tests/semantic/method-return-valist.test | 8 ++++++++
tests/semantic/signal-return-valist.test | 8 ++++++++
vala/valadelegate.vala | 6 ++++++
vala/valafield.vala | 6 ++++++
vala/valamethod.vala | 6 ++++++
vala/valasignal.vala | 6 ++++++
9 files changed, 56 insertions(+)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index cd76b9a58..dea336291 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -698,6 +698,7 @@ TESTS = \
semantic/constant-value-type.test \
semantic/constant-void.test \
semantic/construct-without-gobject.test \
+ semantic/delegate-return-valist.test \
semantic/delegate-too-few-type-arguments.test \
semantic/delegate-too-many-type-arguments.test \
semantic/enum-empty.test \
@@ -711,6 +712,7 @@ TESTS = \
semantic/field-non-constant.test \
semantic/field-owned-to-unowned.test \
semantic/field-static-instance-access.test \
+ semantic/field-valist.test \
semantic/field-void.test \
semantic/floating-reference.vala \
semantic/foreach-iterator-args.test \
@@ -764,6 +766,7 @@ TESTS = \
semantic/method-private-virtual.test \
semantic/method-protected.test \
semantic/method-return-accessibility.test \
+ semantic/method-return-valist.test \
semantic/method-too-few-type-arguments.test \
semantic/method-too-many-type-arguments.test \
semantic/method-virtual.test \
@@ -806,6 +809,7 @@ TESTS = \
semantic/signal-detail-non-string.test \
semantic/struct-derived.test \
semantic/signal-disconnect-invalid.test \
+ semantic/signal-return-valist.test \
semantic/struct-field-initializer.test \
semantic/struct-invalid-base.test \
semantic/struct-recursive.test \
diff --git a/tests/semantic/delegate-return-valist.test b/tests/semantic/delegate-return-valist.test
new file mode 100644
index 000000000..b8300c952
--- /dev/null
+++ b/tests/semantic/delegate-return-valist.test
@@ -0,0 +1,6 @@
+Invalid Code
+
+delegate va_list Foo ();
+
+void main () {
+}
diff --git a/tests/semantic/field-valist.test b/tests/semantic/field-valist.test
new file mode 100644
index 000000000..9ba207aa0
--- /dev/null
+++ b/tests/semantic/field-valist.test
@@ -0,0 +1,6 @@
+Invalid Code
+
+va_list foo;
+
+void main () {
+}
diff --git a/tests/semantic/method-return-valist.test b/tests/semantic/method-return-valist.test
new file mode 100644
index 000000000..af0d56611
--- /dev/null
+++ b/tests/semantic/method-return-valist.test
@@ -0,0 +1,8 @@
+Invalid Code
+
+va_list foo () {
+ return {};
+}
+
+void main () {
+}
diff --git a/tests/semantic/signal-return-valist.test b/tests/semantic/signal-return-valist.test
new file mode 100644
index 000000000..98aca1313
--- /dev/null
+++ b/tests/semantic/signal-return-valist.test
@@ -0,0 +1,8 @@
+Invalid Code
+
+class Foo : Object {
+ public signal va_list bar ();
+}
+
+void main () {
+}
diff --git a/vala/valadelegate.vala b/vala/valadelegate.vala
index 4b4e7074a..125011e12 100644
--- a/vala/valadelegate.vala
+++ b/vala/valadelegate.vala
@@ -305,6 +305,12 @@ public class Vala.Delegate : TypeSymbol, Callable {
return_type.check (context);
+ if (return_type.data_type == context.analyzer.va_list_type.data_type) {
+ error = true;
+ Report.error (source_reference, "`%s' not supported as return type".printf
(return_type.data_type.get_full_name ()));
+ return false;
+ }
+
foreach (Parameter param in parameters) {
param.check (context);
}
diff --git a/vala/valafield.vala b/vala/valafield.vala
index 715d60935..3be9a7d9a 100644
--- a/vala/valafield.vala
+++ b/vala/valafield.vala
@@ -98,6 +98,12 @@ public class Vala.Field : Variable, Lockable {
return false;
}
+ if (variable_type.data_type == context.analyzer.va_list_type.data_type) {
+ error = true;
+ Report.error (source_reference, "`%s' not supported as field type".printf
(variable_type.data_type.get_full_name ()));
+ return false;
+ }
+
variable_type.check (context);
// check whether field type is at least as accessible as the field
diff --git a/vala/valamethod.vala b/vala/valamethod.vala
index 73e22c3ff..ee0e5d37f 100644
--- a/vala/valamethod.vala
+++ b/vala/valamethod.vala
@@ -786,6 +786,12 @@ public class Vala.Method : Subroutine, Callable {
return_type.floating_reference = returns_floating_reference;
return_type.check (context);
+ if (return_type.data_type == context.analyzer.va_list_type.data_type) {
+ error = true;
+ Report.error (source_reference, "`%s' not supported as return type".printf
(return_type.data_type.get_full_name ()));
+ return false;
+ }
+
var init_attr = get_attribute ("ModuleInit");
if (init_attr != null) {
source_reference.file.context.module_init_method = this;
diff --git a/vala/valasignal.vala b/vala/valasignal.vala
index fa32cbe64..de2c9a07c 100644
--- a/vala/valasignal.vala
+++ b/vala/valasignal.vala
@@ -205,6 +205,12 @@ public class Vala.Signal : Symbol, Callable {
return_type.check (context);
+ if (return_type.data_type == context.analyzer.va_list_type.data_type) {
+ error = true;
+ Report.error (source_reference, "`%s' not supported as return type".printf
(return_type.data_type.get_full_name ()));
+ return false;
+ }
+
foreach (Parameter param in parameters) {
if (param.ellipsis) {
Report.error (param.source_reference, "Signals with variable argument lists
are not supported");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]