From 6be61aa19c82935be2ed048ff4af2b7ebbf14db9 Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Fri, 15 Sep 2023 08:18:14 +0200 Subject: [PATCH] Fixed asm parsing issue. Use of pointer as argument. --- src/compiler/llvm_codegen_stmt.c | 2 +- src/compiler/parse_stmt.c | 7 ++++++- src/compiler/sema_asm.c | 2 +- src/version.h | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/compiler/llvm_codegen_stmt.c b/src/compiler/llvm_codegen_stmt.c index b81bd2387..22b258a1c 100644 --- a/src/compiler/llvm_codegen_stmt.c +++ b/src/compiler/llvm_codegen_stmt.c @@ -1139,7 +1139,7 @@ static inline void llvm_emit_asm_block_stmt(GenContext *c, Ast *ast) result_types[result_count++] = llvm_get_type(c, decl->type); FOREACH_END(); - FOREACH_BEGIN(ExprAsmArg * val, block->input) + FOREACH_BEGIN(ExprAsmArg *val, block->input) BEValue value; codegen_new_constraint(&clobber_list); pointer_type[param_count] = NULL; diff --git a/src/compiler/parse_stmt.c b/src/compiler/parse_stmt.c index 20e307146..558958870 100644 --- a/src/compiler/parse_stmt.c +++ b/src/compiler/parse_stmt.c @@ -228,7 +228,12 @@ static inline bool parse_asm_addr(ParseContext *c, ExprAsmArg *asm_arg) if (type == TOKEN_MINUS) asm_arg->neg_offset = true; // If it's an integer, then it's [foo + 123] or [foo - 213] - if (tok_is(c, TOKEN_INTEGER)) return parse_asm_offset(c, asm_arg); + if (tok_is(c, TOKEN_INTEGER)) + { + if (!parse_asm_offset(c, asm_arg)) return false; + CONSUME_OR_RET(TOKEN_RBRACKET, false); + return true; + } // Otherwise we expect the index. ASSIGN_EXPRID_OR_RET(asm_arg->idx, parse_asm_expr(c), false); diff --git a/src/compiler/sema_asm.c b/src/compiler/sema_asm.c index 9801afa17..c98d5ac59 100644 --- a/src/compiler/sema_asm.c +++ b/src/compiler/sema_asm.c @@ -434,7 +434,7 @@ static inline bool sema_check_asm_arg_value(SemaContext *context, AsmInlineBlock return false; } Type *type = type_flatten(inner->type); - if (type_is_pointer(type)) type = type_uptr; + if (type_is_pointer(type)) type = type_uptr->canonical; if (type_is_integer(type)) { if (!sema_reg_int_suported_type(arg_type, type)) diff --git a/src/version.h b/src/version.h index b6a58d12a..bd9375475 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define COMPILER_VERSION "0.4.644" \ No newline at end of file +#define COMPILER_VERSION "0.4.645" \ No newline at end of file