Fix to zero length strings and better error when using assert with a non-constant error value.

This commit is contained in:
Christoffer Lerno
2023-06-24 20:32:30 +02:00
parent b68b1e01b3
commit dcfbca076f
3 changed files with 3 additions and 4 deletions

View File

@@ -1252,8 +1252,7 @@ LLVMValueRef llvm_emit_string_const(GenContext *c, const char *str, const char *
LLVMValueRef llvm_emit_empty_string_const(GenContext *c)
{
LLVMValueRef data[2] = { LLVMConstNull(c->char_ptr_type), llvm_const_int(c, type_usz, 0) };
return llvm_get_struct_named(c->chars_type, data, 2);
return LLVMConstNull(c->chars_type);
}
LLVMValueRef llvm_emit_zstring(GenContext *c, const char *str)

View File

@@ -82,7 +82,7 @@ static inline bool sema_analyse_assert_stmt(SemaContext *context, Ast *statement
if (message_expr)
{
if (!sema_analyse_expr(context, message_expr)) return false;
if (!expr_is_const_string(message_expr)) RETURN_SEMA_ERROR(message_expr, "Expected a string as the error message.");
if (!expr_is_const_string(message_expr)) RETURN_SEMA_ERROR(message_expr, "Expected a constant string as the error message.");
FOREACH_BEGIN(Expr *e, statement->assert_stmt.args)
if (!sema_analyse_expr(context, e)) return false;
FOREACH_END();

View File

@@ -1 +1 @@
#define COMPILER_VERSION "0.4.539"
#define COMPILER_VERSION "0.4.540"