aboutsummaryrefslogtreecommitdiff
path: root/src/check_type.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2019-12-28 16:31:15 +0000
committergingerBill <bill@gingerbill.org>2019-12-28 16:31:15 +0000
commit9ba2926e7e40e4f3ab7865f13fd57a16714433be (patch)
tree437f1f48f3e5dde1ddc798d432c12d8907ee5f04 /src/check_type.cpp
parenta50b2d5d043d34124b078f81572ddbf58d737434 (diff)
Fix enumerated array contiguous error
Diffstat (limited to 'src/check_type.cpp')
-rw-r--r--src/check_type.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/check_type.cpp b/src/check_type.cpp
index 098c4b76a..6521bd248 100644
--- a/src/check_type.cpp
+++ b/src/check_type.cpp
@@ -3252,18 +3252,16 @@ bool check_type_internal(CheckerContext *ctx, Ast *e, Type **type, Type *named_t
}
}
- if (t->EnumeratedArray.count != bt->Enum.fields.count) {
- if (!is_partial) {
- error(e, "Non-contiguous enumeration used as an index in an enumerated array");
- long long ea_count = cast(long long)t->EnumeratedArray.count;
- long long enum_count = cast(long long)t->Enum.fields.count;
- error_line("\tenumerated array length: %lld\n", ea_count);
- error_line("\tenum field count: %lld\n", enum_count);
- error_line("\tSuggestion: prepend #partial to the enumerated array to allow for non-named elements\n");
- if (2*enum_count < ea_count) {
- error_line("\tWarning: the number of named elements is much smaller than the length of the array, are you sure this is what you want?\n");
- error_line("\t this warning will be removed if #partial is applied\n");
- }
+ if (!is_partial && t->EnumeratedArray.count > bt->Enum.fields.count) {
+ error(e, "Non-contiguous enumeration used as an index in an enumerated array");
+ long long ea_count = cast(long long)t->EnumeratedArray.count;
+ long long enum_count = cast(long long)t->Enum.fields.count;
+ error_line("\tenumerated array length: %lld\n", ea_count);
+ error_line("\tenum field count: %lld\n", enum_count);
+ error_line("\tSuggestion: prepend #partial to the enumerated array to allow for non-named elements\n");
+ if (2*enum_count < ea_count) {
+ error_line("\tWarning: the number of named elements is much smaller than the length of the array, are you sure this is what you want?\n");
+ error_line("\t this warning will be removed if #partial is applied\n");
}
}