diff --git a/releasenotes.md b/releasenotes.md index 9469971a0..f31dfe32a 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -3,6 +3,7 @@ ## 0.5.0 Change List ### Changes / improvements +- Asm string blocks use AT&T syntax for better reliability. - Distinct methods changed to separate syntax. - 'exec' directive to run scripts at compile time. - Project key descriptions in --list command. @@ -174,6 +175,7 @@ - Added posix socket functions. ### Fixes +- Naked functions now correctly handles `asm`. - Indexing into arrays would not always widen the index safely. - Macros with implicit return didn't correctly deduct the return type. - Reevaluating a bitstruct (due to checked) would break. diff --git a/src/compiler/llvm_codegen_stmt.c b/src/compiler/llvm_codegen_stmt.c index 3ceacef82..110529785 100644 --- a/src/compiler/llvm_codegen_stmt.c +++ b/src/compiler/llvm_codegen_stmt.c @@ -1222,7 +1222,7 @@ static inline void llvm_emit_asm_block_stmt(GenContext *c, Ast *ast) strlen(clobbers), ast->asm_block_stmt.is_volatile, true, - ast->asm_block_stmt.is_string ? LLVMInlineAsmDialectIntel : LLVMInlineAsmDialectATT, + LLVMInlineAsmDialectATT, /* can throw */ false ); LLVMValueRef res = LLVMBuildCall2(c->builder, asm_fn_type, asm_fn, args, param_count, ""); diff --git a/src/compiler/sema_stmts.c b/src/compiler/sema_stmts.c index 4e1d47f4d..5723dd88b 100644 --- a/src/compiler/sema_stmts.c +++ b/src/compiler/sema_stmts.c @@ -3115,6 +3115,7 @@ bool sema_analyse_function_body(SemaContext *context, Decl *func) } } assert_first = 0; + if (!sema_analyse_compound_statement_no_scope(context, body)) return false; } else { diff --git a/src/version.h b/src/version.h index 61142e672..90c29cc5f 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define COMPILER_VERSION "0.4.681" \ No newline at end of file +#define COMPILER_VERSION "0.4.682" \ No newline at end of file diff --git a/test/test_suite/asm/naked.c3t b/test/test_suite/asm/naked.c3t index 9bd8b6e55..68a3b532e 100644 --- a/test/test_suite/asm/naked.c3t +++ b/test/test_suite/asm/naked.c3t @@ -1,11 +1,19 @@ // #target: macos-x64 module testing; -import std::io; -fn void test() @naked @export("hello") -{ - asm("nop"); +fn void start() @export("_start") @naked @nostrip { + asm { + movq $rax, 0x3c; + movq $rdi, 42; + syscall; + } } -fn void main() -{ -} \ No newline at end of file + +/* #expect: testing.ll + +define void @_start() #0 { +entry: + call void asm alignstack "movq $$60, %rax\0Amovq $$42, %rdi\0Asyscall \0A", "~{cc},~{rax},~{rcx},~{r8},~{r11},~{flags},~{dirflag},~{fspr}"() + ret void +} +