authorgravatar for jacoblevgw@gmail.comJacob G-W <jacoblevgw@gmail.com> 2021-11-13 12:52:17-05:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-11-19 09:38:36+01:00
log149bc79486907745c8ffb12a69f65189b26c6dbe
treeee6c5033e669d2f48974ecd33617a1b6ae4a0643
parent8fc3a707a44368f3f5c0ded0cc1b7080bf056761

add tests for previous commit


2 files changed, 33 insertions(+), 1 deletions(-)

src/link/Elf.zig+1-1
...@@ -2604,7 +2604,7 @@ fn addDbgInfoType(self: *Elf, ty: Type, dbg_info_buffer: *std.ArrayList(u8)) !vo...@@ -2604,7 +2604,7 @@ fn addDbgInfoType(self: *Elf, ty: Type, dbg_info_buffer: *std.ArrayList(u8)) !vo
2604 // DW.AT.name, DW.FORM.string2604 // DW.AT.name, DW.FORM.string
2605 try dbg_info_buffer.writer().print("{}\x00", .{ty});2605 try dbg_info_buffer.writer().print("{}\x00", .{ty});
2606 } else {2606 } else {
2607 log.err("TODO implement .debug_info for type '{}'", .{ty});2607 log.warn("TODO implement .debug_info for type '{}'", .{ty});
2608 try dbg_info_buffer.append(abbrev_pad1);2608 try dbg_info_buffer.append(abbrev_pad1);
2609 }2609 }
2610 },2610 },
test/cases.zig+32
...@@ -1819,4 +1819,36 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -1819,4 +1819,36 @@ pub fn addCases(ctx: *TestContext) !void {
1819 ":2:28: error: cannot set address space of local variable 'foo'",1819 ":2:28: error: cannot set address space of local variable 'foo'",
1820 });1820 });
1821 }1821 }
1822 {
1823 var case = ctx.exe("issue 10138: callee preserved regs working", linux_x64);
1824 case.addCompareOutput(
1825 \\pub fn main() void {
1826 \\ const fd = open();
1827 \\ _ = write(fd, "a", 1);
1828 \\ _ = close(fd);
1829 \\}
1830 \\
1831 \\fn open() usize {
1832 \\ return 42;
1833 \\}
1834 \\
1835 \\fn write(fd: usize, a: [*]const u8, len: usize) usize {
1836 \\ return syscall4(.WRITE, fd, @ptrToInt(a), len);
1837 \\}
1838 \\
1839 \\fn syscall4(n: enum { WRITE }, a: usize, b: usize, c: usize) usize {
1840 \\ _ = n;
1841 \\ _ = a;
1842 \\ _ = b;
1843 \\ _ = c;
1844 \\ return 23;
1845 \\}
1846 \\
1847 \\fn close(fd: usize) usize {
1848 \\ if (fd != 42)
1849 \\ unreachable;
1850 \\ return 0;
1851 \\}
1852 , "");
1853 }
1822}1854}