aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/std/event/group.zig2
-rw-r--r--lib/std/event/locked.zig2
-rw-r--r--lib/std/net/test.zig3
-rw-r--r--src/codegen/llvm.zig7
-rw-r--r--test/behavior/union.zig19
5 files changed, 26 insertions, 7 deletions
diff --git a/lib/std/event/group.zig b/lib/std/event/group.zig
index 85eeeaf2b7..639d90b12a 100644
--- a/lib/std/event/group.zig
+++ b/lib/std/event/group.zig
@@ -35,7 +35,7 @@ pub fn Group(comptime ReturnType: type) type {
return Self{
.frame_stack = Stack.init(),
.alloc_stack = AllocStack.init(),
- .lock = Lock.init(),
+ .lock = .{},
.allocator = allocator,
};
}
diff --git a/lib/std/event/locked.zig b/lib/std/event/locked.zig
index e921803447..66495c3772 100644
--- a/lib/std/event/locked.zig
+++ b/lib/std/event/locked.zig
@@ -22,7 +22,7 @@ pub fn Locked(comptime T: type) type {
pub fn init(data: T) Self {
return Self{
- .lock = Lock.init(),
+ .lock = .{},
.private_data = data,
};
}
diff --git a/lib/std/net/test.zig b/lib/std/net/test.zig
index 710eb91376..5d350be7e0 100644
--- a/lib/std/net/test.zig
+++ b/lib/std/net/test.zig
@@ -5,7 +5,6 @@ const mem = std.mem;
const testing = std.testing;
test "parse and render IPv6 addresses" {
- if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest;
if (builtin.os.tag == .wasi) return error.SkipZigTest;
var buffer: [100]u8 = undefined;
@@ -68,7 +67,6 @@ test "invalid but parseable IPv6 scope ids" {
}
test "parse and render IPv4 addresses" {
- if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest;
if (builtin.os.tag == .wasi) return error.SkipZigTest;
var buffer: [18]u8 = undefined;
@@ -93,7 +91,6 @@ test "parse and render IPv4 addresses" {
}
test "parse and render UNIX addresses" {
- if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest;
if (builtin.os.tag == .wasi) return error.SkipZigTest;
if (!net.has_unix_sockets) return error.SkipZigTest;
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig
index 37d6d2c52b..529cd206ac 100644
--- a/src/codegen/llvm.zig
+++ b/src/codegen/llvm.zig
@@ -2708,7 +2708,10 @@ pub const DeclGen = struct {
if (layout.most_aligned_field_size == layout.payload_size) {
break :t llvm_aligned_field_ty;
}
- const padding_len = @intCast(c_uint, layout.payload_size - layout.most_aligned_field_size);
+ const padding_len = if (layout.tag_size == 0)
+ @intCast(c_uint, layout.abi_size - layout.most_aligned_field_size)
+ else
+ @intCast(c_uint, layout.payload_size - layout.most_aligned_field_size);
const fields: [2]*const llvm.Type = .{
llvm_aligned_field_ty,
dg.context.intType(8).arrayType(padding_len),
@@ -5757,7 +5760,7 @@ pub const FuncGen = struct {
// First set the non-null bit.
const indices: [2]*const llvm.Value = .{
index_type.constNull(), // dereference the pointer
- index_type.constInt(1, .False), // second field is the payload
+ index_type.constInt(1, .False), // second field is the non-null bit
};
const non_null_ptr = self.builder.buildInBoundsGEP(operand, &indices, indices.len, "");
_ = self.builder.buildStore(non_null_bit, non_null_ptr);
diff --git a/test/behavior/union.zig b/test/behavior/union.zig
index 3c8874e3a8..be01b3a048 100644
--- a/test/behavior/union.zig
+++ b/test/behavior/union.zig
@@ -1194,3 +1194,22 @@ test "union tag is set when initiated as a temporary value at runtime" {
var b: u32 = 1;
try (U{ .b = b }).doTheTest();
}
+
+test "extern union most-aligned field is smaller" {
+ if (builtin.zig_backend == .stage1) return error.SkipZigTest;
+ if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
+ if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
+ if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
+
+ const U = extern union {
+ in6: extern struct {
+ family: u16,
+ port: u16,
+ flowinfo: u32,
+ addr: [20]u8,
+ },
+ un: [110]u8,
+ };
+ var a: ?U = .{ .un = [_]u8{0} ** 110 };
+ try expect(a != null);
+}