From 31bc7669443ca80e55253edc459d62868b32024a Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Mon, 9 Oct 2023 00:41:31 +0200 Subject: [PATCH] Fix issue where in error messages, integers were assumed to be unicode characters. --- src/compiler/compiler_internal.h | 1 + src/compiler/expr.c | 1 + src/compiler/parse_expr.c | 1 + src/compiler/sema_casts.c | 10 ++++++---- src/compiler/sema_expr.c | 3 +++ src/version.h | 2 +- 6 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/compiler/compiler_internal.h b/src/compiler/compiler_internal.h index f3ee6fb3b..5ddfebfa2 100644 --- a/src/compiler/compiler_internal.h +++ b/src/compiler/compiler_internal.h @@ -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; } diff --git a/src/compiler/expr.c b/src/compiler/expr.c index 13c2bd71a..86ef7c39e 100644 --- a/src/compiler/expr.c +++ b/src/compiler/expr.c @@ -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; diff --git a/src/compiler/parse_expr.c b/src/compiler/parse_expr.c index 188cde5d9..955eec159 100644 --- a/src/compiler/parse_expr.c +++ b/src/compiler/parse_expr.c @@ -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) diff --git a/src/compiler/sema_casts.c b/src/compiler/sema_casts.c index 124f9fb47..6d8340881 100644 --- a/src/compiler/sema_casts.c +++ b/src/compiler/sema_casts.c @@ -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; } diff --git a/src/compiler/sema_expr.c b/src/compiler/sema_expr.c index 336bc394f..735b543de 100644 --- a/src/compiler/sema_expr.c +++ b/src/compiler/sema_expr.c @@ -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; diff --git a/src/version.h b/src/version.h index f504d7440..d034bd7da 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define COMPILER_VERSION "0.4.673" \ No newline at end of file +#define COMPILER_VERSION "0.4.674" \ No newline at end of file