authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-11-10 17:56:30-05:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-11-10 18:04:09-05:00
log89cac88e91cd0ff98acffc48c4791a8da0c39ae9
tree077c043926ee7b9728a628d021535878dfec625f
parent59375b3c22ff6694a20847e87a162705dbbc632a

behavior: add testing for LLVM SROA bugs


1 files changed, 17 insertions(+), 0 deletions(-)

test/behavior/union.zig+17
...@@ -2042,3 +2042,20 @@ test "circular dependency through pointer field of a union" {...@@ -2042,3 +2042,20 @@ test "circular dependency through pointer field of a union" {
2042 try expect(outer.u.outer == null);2042 try expect(outer.u.outer == null);
2043 try expect(outer.u.inner == null);2043 try expect(outer.u.inner == null);
2044}2044}
2045
2046test "pass nested union with rls" {
2047 const Union = union(enum) {
2048 a: u32,
2049 b: union(enum) {
2050 c: u7,
2051 d: u3,
2052 },
2053
2054 fn getC(u: @This()) u7 {
2055 return u.b.c;
2056 }
2057 };
2058
2059 var c: u7 = 32;
2060 try expectEqual(@as(u7, 32), Union.getC(.{ .b = .{ .c = c } }));
2061}