Fix issue where in error messages, integers were assumed to be unicode characters.

This commit is contained in:
Christoffer Lerno
2023-10-09 00:41:31 +02:00
parent ebddbfb416
commit 31bc766944
6 changed files with 13 additions and 5 deletions

View File

@@ -3388,6 +3388,7 @@ INLINE void expr_rewrite_const_int(Expr *expr, Type *type, uint64_t v)
}
(&expr->const_expr)->ixx.i.low = v;
(&expr->const_expr)->ixx.type = kind;
(&expr->const_expr)->is_character = false;
(&expr->const_expr)->const_kind = CONST_INTEGER;
}

View File

@@ -857,6 +857,7 @@ Expr *expr_new_const_int(SourceSpan span, Type *type, uint64_t v)
}
expr->const_expr.ixx.i.low = v;
expr->const_expr.ixx.type = kind;
expr->const_expr.is_character = false;
expr->const_expr.const_kind = CONST_INTEGER;
expr->resolve_status = RESOLVE_DONE;
return expr;

View File

@@ -1402,6 +1402,7 @@ EXIT:
return poisoned_expr;
}
expr_int->const_expr.const_kind = CONST_INTEGER;
expr_int->const_expr.is_character = false;
expr_int->const_expr.is_hex = hex_characters > 0;
Type *type_base = NULL;
if (type_bits)

View File

@@ -1297,10 +1297,11 @@ static void vector_const_initializer_convert_to_type(ConstInitializer *initializ
if (is_neg_conversion)
{
bool is_true = initializer->init_value->const_expr.b;
initializer->init_value->const_expr.const_kind = CONST_INTEGER;
initializer->init_value->const_expr.ixx = (Int)
{ .i = is_true ? (Int128) { UINT64_MAX, UINT64_MAX } : (Int128) { 0, 0 },
.type = to_flat->type_kind };
initializer->init_value->const_expr = (ExprConst)
{
.const_kind = CONST_INTEGER,
.ixx = (Int) { .i = is_true ? (Int128) { UINT64_MAX, UINT64_MAX } : (Int128) { 0, 0 }, .type = to_flat->type_kind },
};
initializer->init_value->type = to_type;
}
else
@@ -1368,6 +1369,7 @@ static void cast_float_to_int(Expr *expr, Type *type)
Real d = expr->const_expr.fxx.f;
expr->const_expr.ixx = int_from_real(d, type_flatten(type)->type_kind);
expr->const_expr.const_kind = CONST_INTEGER;
expr->const_expr.is_character = false;
expr->type = type;
expr->const_expr.is_hex = false;
}

View File

@@ -3295,6 +3295,7 @@ static inline bool sema_create_const_min(SemaContext *context, Expr *expr, Type
{
expr->expr_kind = EXPR_CONST;
expr->const_expr.const_kind = CONST_INTEGER;
expr->const_expr.is_character = false;
expr->type = type;
expr->resolve_status = RESOLVE_DONE;
expr->const_expr.ixx.type = flat->type_kind;
@@ -3398,6 +3399,7 @@ static inline bool sema_create_const_max(SemaContext *context, Expr *expr, Type
{
expr->expr_kind = EXPR_CONST;
expr->const_expr.const_kind = CONST_INTEGER;
expr->const_expr.is_character = false;
expr->type = type;
expr->resolve_status = RESOLVE_DONE;
expr->const_expr.ixx.type = flat->type_kind;
@@ -4959,6 +4961,7 @@ static bool sema_expr_analyse_enum_add_sub(SemaContext *context, Expr *expr, Exp
expr->const_expr.ixx = int_add(left->const_expr.ixx, right->const_expr.ixx);
}
expr->const_expr.const_kind = CONST_INTEGER;
expr->const_expr.is_character = false;
expr->expr_kind = EXPR_CONST;
}
return true;

View File

@@ -1 +1 @@
#define COMPILER_VERSION "0.4.673"
#define COMPILER_VERSION "0.4.674"