From 736d14fd5fa5feea83a6efce8b606b62bf165033 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 22 Sep 2021 21:02:24 -0700 Subject: stage2: fix AstGen for some struct syntaxes * AstGen: fix not emitting `struct_init_empty` when an explicit type is present in struct initialization syntax. * AstGen: these two syntaxes now lower to identical ZIR: - `var a = A{ .b = c };` - `var a = @as(A, .{ .b = c });` * Zir: clarify `auto_enum_tag` in the doc comments. * LLVM Backend: fix lowering of function return types when the type has 0 bits. --- src/codegen/llvm.zig | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/codegen') diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index 0d3bca2b03..6daf720961 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -563,8 +563,13 @@ pub const DeclGen = struct { } } + const llvm_ret_ty = if (!return_type.hasCodeGenBits()) + self.context.voidType() + else + try self.llvmType(return_type); + const fn_type = llvm.functionType( - try self.llvmType(return_type), + llvm_ret_ty, llvm_param_buffer.ptr, llvm_params_len, .False, -- cgit v1.2.3