aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobin Voetter <robin@voetter.nl>2021-10-25 03:41:23 +0200
committerRobin Voetter <robin@voetter.nl>2021-10-25 20:41:15 +0200
commit4eb7b28700b23d8465a36e364e60394b2a1da41b (patch)
treecb46cfbbd0a3efc2dc2862cee7a871c593427e9b /src
parent7062c8a8865bbd2fb8181b579da552295cd68e6a (diff)
downloadzig-4eb7b28700b23d8465a36e364e60394b2a1da41b.tar.gz
zig-4eb7b28700b23d8465a36e364e60394b2a1da41b.zip
stage2: generate correct constants for zero-sized arrays
Diffstat (limited to 'src')
-rw-r--r--src/codegen/llvm.zig6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig
index 80f2d8b653..646633a90d 100644
--- a/src/codegen/llvm.zig
+++ b/src/codegen/llvm.zig
@@ -762,7 +762,7 @@ pub const DeclGen = struct {
}
const llvm_addrspace = dg.llvmAddressSpace(t.ptrAddressSpace());
const elem_ty = t.childType();
- const llvm_elem_ty = if (elem_ty.hasCodeGenBits())
+ const llvm_elem_ty = if (elem_ty.hasCodeGenBits() or elem_ty.zigTypeTag() == .Array)
try dg.llvmType(elem_ty)
else
dg.context.intType(8);
@@ -1475,7 +1475,7 @@ pub const DeclGen = struct {
}
const llvm_type = try self.llvmType(tv.ty);
- if (!tv.ty.childType().hasCodeGenBits()) {
+ if (!tv.ty.childType().hasCodeGenBits() or !decl.ty.hasCodeGenBits()) {
return self.lowerPtrToVoid(tv.ty);
}
@@ -1497,7 +1497,7 @@ pub const DeclGen = struct {
// for non-optional pointers. We also need to respect the alignment, even though
// the address will never be dereferenced.
const llvm_usize = try dg.llvmType(Type.usize);
- const llvm_ptr_ty = dg.context.intType(8).pointerType(0);
+ const llvm_ptr_ty = try dg.llvmType(ptr_ty);
if (alignment != 0) {
return llvm_usize.constInt(alignment, .False).constIntToPtr(llvm_ptr_ty);
}