Fix enumerated array contiguous error

This commit is contained in:
gingerBill
2019-12-28 16:31:15 +00:00
parent a50b2d5d04
commit 9ba2926e7e
2 changed files with 13 additions and 18 deletions
-3
View File
@@ -8125,14 +8125,11 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type
} }
} }
if (t->kind == Type_EnumeratedArray) {
if (cl->elems.count > 0 && cl->elems[0]->kind != Ast_FieldValue) { if (cl->elems.count > 0 && cl->elems[0]->kind != Ast_FieldValue) {
if (0 < max && max < t->EnumeratedArray.count) { if (0 < max && max < t->EnumeratedArray.count) {
error(node, "Expected %lld values for this enumerated array literal, got %lld", cast(long long)t->EnumeratedArray.count, cast(long long)max); error(node, "Expected %lld values for this enumerated array literal, got %lld", cast(long long)t->EnumeratedArray.count, cast(long long)max);
} }
} }
}
break; break;
} }
+1 -3
View File
@@ -3252,8 +3252,7 @@ bool check_type_internal(CheckerContext *ctx, Ast *e, Type **type, Type *named_t
} }
} }
if (t->EnumeratedArray.count != bt->Enum.fields.count) { if (!is_partial && t->EnumeratedArray.count > bt->Enum.fields.count) {
if (!is_partial) {
error(e, "Non-contiguous enumeration used as an index in an enumerated array"); 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 ea_count = cast(long long)t->EnumeratedArray.count;
long long enum_count = cast(long long)t->Enum.fields.count; long long enum_count = cast(long long)t->Enum.fields.count;
@@ -3265,7 +3264,6 @@ bool check_type_internal(CheckerContext *ctx, Ast *e, Type **type, Type *named_t
error_line("\t this warning will be removed if #partial is applied\n"); error_line("\t this warning will be removed if #partial is applied\n");
} }
} }
}
*type = t; *type = t;