mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 15:18:49 +00:00
+40
-44
@@ -10335,52 +10335,48 @@ gb_internal ExprKind check_compound_literal(CheckerContext *c, Operand *o, Ast *
|
|||||||
is_constant = false;
|
is_constant = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cl->elems[0]->kind == Ast_FieldValue) {
|
for (Ast *elem : cl->elems) {
|
||||||
error(cl->elems[0], "'field = value' in a bit_set a literal is not allowed");
|
if (elem->kind == Ast_FieldValue) {
|
||||||
is_constant = false;
|
error(elem, "'field = value' in a bit_set literal is not allowed");
|
||||||
} else {
|
is_constant = false;
|
||||||
for (Ast *elem : cl->elems) {
|
continue;
|
||||||
if (elem->kind == Ast_FieldValue) {
|
}
|
||||||
error(elem, "'field = value' in a bit_set a literal is not allowed");
|
|
||||||
|
check_expr_with_type_hint(c, o, elem, et);
|
||||||
|
|
||||||
|
if (is_constant) {
|
||||||
|
is_constant = o->mode == Addressing_Constant;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (elem->kind == Ast_BinaryExpr) {
|
||||||
|
switch (elem->BinaryExpr.op.kind) {
|
||||||
|
case Token_Or:
|
||||||
|
{
|
||||||
|
gbString x = expr_to_string(elem->BinaryExpr.left);
|
||||||
|
gbString y = expr_to_string(elem->BinaryExpr.right);
|
||||||
|
gbString e = expr_to_string(elem);
|
||||||
|
error(elem, "Was the following intended? '%s, %s'; if not, surround the expression with parentheses '(%s)'", x, y, e);
|
||||||
|
gb_string_free(e);
|
||||||
|
gb_string_free(y);
|
||||||
|
gb_string_free(x);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
check_assignment(c, o, t->BitSet.elem, str_lit("bit_set literal"));
|
||||||
|
if (o->mode == Addressing_Constant) {
|
||||||
|
i64 lower = t->BitSet.lower;
|
||||||
|
i64 upper = t->BitSet.upper;
|
||||||
|
i64 v = exact_value_to_i64(o->value);
|
||||||
|
if (lower <= v && v <= upper) {
|
||||||
|
// okay
|
||||||
|
} else {
|
||||||
|
gbString s = expr_to_string(o->expr);
|
||||||
|
error(elem, "Bit field value out of bounds, %s (%lld) not in the range %lld .. %lld", s, v, lower, upper);
|
||||||
|
gb_string_free(s);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
check_expr_with_type_hint(c, o, elem, et);
|
|
||||||
|
|
||||||
if (is_constant) {
|
|
||||||
is_constant = o->mode == Addressing_Constant;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (elem->kind == Ast_BinaryExpr) {
|
|
||||||
switch (elem->BinaryExpr.op.kind) {
|
|
||||||
case Token_Or:
|
|
||||||
{
|
|
||||||
gbString x = expr_to_string(elem->BinaryExpr.left);
|
|
||||||
gbString y = expr_to_string(elem->BinaryExpr.right);
|
|
||||||
gbString e = expr_to_string(elem);
|
|
||||||
error(elem, "Was the following intended? '%s, %s'; if not, surround the expression with parentheses '(%s)'", x, y, e);
|
|
||||||
gb_string_free(e);
|
|
||||||
gb_string_free(y);
|
|
||||||
gb_string_free(x);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
check_assignment(c, o, t->BitSet.elem, str_lit("bit_set literal"));
|
|
||||||
if (o->mode == Addressing_Constant) {
|
|
||||||
i64 lower = t->BitSet.lower;
|
|
||||||
i64 upper = t->BitSet.upper;
|
|
||||||
i64 v = exact_value_to_i64(o->value);
|
|
||||||
if (lower <= v && v <= upper) {
|
|
||||||
// okay
|
|
||||||
} else {
|
|
||||||
gbString s = expr_to_string(o->expr);
|
|
||||||
error(elem, "Bit field value out of bounds, %s (%lld) not in the range %lld .. %lld", s, v, lower, upper);
|
|
||||||
gb_string_free(s);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user