From: Rico Tzschichholz Date: Mon, 24 Apr 2017 06:44:09 +0000 (+0200) Subject: vala: Enums require at least one value otherwise report an error X-Git-Tag: 0.37.1~52 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=955ef3e1d216e84b1a88ca1273d069f21bc093d1;p=thirdparty%2Fvala.git vala: Enums require at least one value otherwise report an error --- diff --git a/vala/valaenum.vala b/vala/valaenum.vala index acb8eb35c..add510783 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 6a30f33a5..9b4c0e8dc 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); }