authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-10-24 14:46:14+03:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-10-27 01:31:18+03:00
log78a7bb108ad9f7bf59061675bcae8947d65afc3a
tree8ce9d6fbe2f9c4e40d9e1dbefb54646a333c15ab
parentdd437ae39948031dc04836f245c8b77d459a428a

llvm: handle namespace like packed structs

Closes #13159 Closes #13188

3 files changed, 16 insertions(+), 1 deletions(-)

src/codegen/llvm.zig+1-1
......@@ -1916,7 +1916,7 @@ pub const Object = struct {
19161916
19171917 if (ty.castTag(.@"struct")) |payload| {
19181918 const struct_obj = payload.data;
1919 if (struct_obj.layout == .Packed) {
1919 if (struct_obj.layout == .Packed and struct_obj.haveFieldTypes()) {
19201920 const info = struct_obj.backing_int_ty.intInfo(target);
19211921 const dwarf_encoding: c_uint = switch (info.signedness) {
19221922 .signed => DW.ATE.signed,
test/behavior.zig+1
......@@ -109,6 +109,7 @@ test {
109109 _ = @import("behavior/bugs/13128.zig");
110110 _ = @import("behavior/bugs/13164.zig");
111111 _ = @import("behavior/bugs/13171.zig");
112 _ = @import("behavior/bugs/13159.zig");
112113 _ = @import("behavior/byteswap.zig");
113114 _ = @import("behavior/byval_arg_var.zig");
114115 _ = @import("behavior/call.zig");
test/behavior/bugs/13159.zig created+14
......@@ -0,0 +1,14 @@
1const std = @import("std");
2const expect = std.testing.expect;
3
4const Bar = packed struct {
5 const Baz = enum {
6 fizz,
7 buzz,
8 };
9};
10
11test {
12 var foo = Bar.Baz.fizz;
13 try expect(foo == .fizz);
14}