[vala/0.34] vala: Enums require at least one value otherwise report an error
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.34] vala: Enums require at least one value otherwise report an error
- Date: Thu, 27 Apr 2017 18:25:12 +0000 (UTC)
commit 6b7941fab8db6cf5e02484c16dc1592257bf940d
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Mon Apr 24 08:44:09 2017 +0200
vala: Enums require at least one value otherwise report an error
vala/valaenum.vala | 6 ++++++
vala/valagirparser.vala | 6 ++++++
2 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/vala/valaenum.vala b/vala/valaenum.vala
index acb8eb3..add5107 100644
--- a/vala/valaenum.vala
+++ b/vala/valaenum.vala
@@ -171,6 +171,12 @@ public class Vala.Enum : TypeSymbol {
}
context.analyzer.current_symbol = this;
+ if (values.size <= 0) {
+ Report.error (source_reference, "Enum `%s' requires at least one value".printf
(get_full_name ()));
+ error = true;
+ return false;
+ }
+
foreach (EnumValue value in values) {
value.check (context);
}
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index ac823db..bc7a094 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -2293,6 +2293,7 @@ public class Vala.GirParser : CodeVisitor {
sym.access = SymbolAccessibility.PUBLIC;
string common_prefix = null;
+ bool has_member = false;
next ();
@@ -2305,6 +2306,7 @@ public class Vala.GirParser : CodeVisitor {
}
if (reader.name == "member") {
+ has_member = true;
if (error_domain) {
parse_error_member ();
calculate_common_prefix (ref common_prefix, old_current.get_cname ());
@@ -2323,6 +2325,10 @@ public class Vala.GirParser : CodeVisitor {
pop_metadata ();
}
+ if (!has_member) {
+ Report.error (get_current_src (), "%s `%s' has no members".printf (element_name,
current.name));
+ }
+
if (common_prefix != null) {
sym.set_attribute_string ("CCode", "cprefix", common_prefix);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]