authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-01-15 04:28:54-05:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2020-01-15 04:28:54-05:00
log8d9d4a065820bfce0395465834cb9b7e01509a12
treeb202c2169b67404aaedbbaf59f97c6d78f36e4fe
parent7ee0e779af1f9b457afee259a4137e928e9627f8
parentc85afff5a82c2d67d12a85723bb73ec5368bf590
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #4182 from LemonBoy/mjeiorw

A bunch of patches

9 files changed, 25 insertions(+), 6 deletions(-)

lib/std/dynamic_library.zig+1-1
......@@ -24,7 +24,7 @@ pub const DynLib = switch (builtin.os) {
2424// fashion.
2525const LinkMap = extern struct {
2626 l_addr: usize,
27 l_name: [*]const u8,
27 l_name: [*:0]const u8,
2828 l_ld: ?*elf.Dyn,
2929 l_next: ?*LinkMap,
3030 l_prev: ?*LinkMap,
lib/std/os/bits/dragonfly.zig+1-1
......@@ -612,7 +612,7 @@ pub const sockaddr_storage = extern struct {
612612};
613613pub const dl_phdr_info = extern struct {
614614 dlpi_addr: usize,
615 dlpi_name: ?[*]const u8,
615 dlpi_name: ?[*:0]const u8,
616616 dlpi_phdr: [*]std.elf.Phdr,
617617 dlpi_phnum: u16,
618618};
lib/std/os/bits/freebsd.zig+1-1
......@@ -45,7 +45,7 @@ pub const RTLD_NOLOAD = 0x02000;
4545
4646pub const dl_phdr_info = extern struct {
4747 dlpi_addr: usize,
48 dlpi_name: ?[*]const u8,
48 dlpi_name: ?[*:0]const u8,
4949 dlpi_phdr: [*]std.elf.Phdr,
5050 dlpi_phnum: u16,
5151};
lib/std/os/bits/linux.zig+1-1
......@@ -992,7 +992,7 @@ pub const dirent64 = extern struct {
992992
993993pub const dl_phdr_info = extern struct {
994994 dlpi_addr: usize,
995 dlpi_name: ?[*]const u8,
995 dlpi_name: ?[*:0]const u8,
996996 dlpi_phdr: [*]std.elf.Phdr,
997997 dlpi_phnum: u16,
998998};
lib/std/os/bits/netbsd.zig+1-1
......@@ -16,7 +16,7 @@ pub const Kevent = extern struct {
1616
1717pub const dl_phdr_info = extern struct {
1818 dlpi_addr: usize,
19 dlpi_name: ?[*]const u8,
19 dlpi_name: ?[*:0]const u8,
2020 dlpi_phdr: [*]std.elf.Phdr,
2121 dlpi_phnum: u16,
2222};
lib/std/os/linux.zig+1-1
......@@ -1042,7 +1042,7 @@ pub fn uname(uts: *utsname) usize {
10421042}
10431043
10441044// XXX: This should be weak
1045extern const __ehdr_start: elf.Ehdr = undefined;
1045extern const __ehdr_start: elf.Ehdr;
10461046
10471047pub fn dl_iterate_phdr(comptime T: type, callback: extern fn (info: *dl_phdr_info, size: usize, data: ?*T) i32, data: ?*T) isize {
10481048 if (builtin.link_libc) {
src/ir.cpp+6
......@@ -16766,6 +16766,12 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio
1676616766 if (!symbol_name)
1676716767 return ira->codegen->invalid_instruction;
1676816768
16769 if (buf_len(symbol_name) < 1) {
16770 ir_add_error(ira, name_inst,
16771 buf_sprintf("exported symbol name cannot be empty"));
16772 return ira->codegen->invalid_instruction;
16773 }
16774
1676916775 GlobalLinkageId global_linkage_id;
1677016776 if (!ir_resolve_global_linkage(ira, linkage_inst, &global_linkage_id))
1677116777 return ira->codegen->invalid_instruction;
src/ir_print.cpp+4
......@@ -930,6 +930,10 @@ static void ir_print_set_float_mode(IrPrint *irp, IrInstructionSetFloatMode *ins
930930static void ir_print_array_type(IrPrint *irp, IrInstructionArrayType *instruction) {
931931 fprintf(irp->f, "[");
932932 ir_print_other_instruction(irp, instruction->size);
933 if (instruction->sentinel != nullptr) {
934 fprintf(irp->f, ":");
935 ir_print_other_instruction(irp, instruction->sentinel);
936 }
933937 fprintf(irp->f, "]");
934938 ir_print_other_instruction(irp, instruction->child_type);
935939}
test/compile_errors.zig+9
......@@ -2,6 +2,15 @@ const tests = @import("tests.zig");
22const builtin = @import("builtin");
33
44pub fn addCases(cases: *tests.CompileErrorContext) void {
5 cases.addTest("@export with empty name string",
6 \\pub export fn entry() void { }
7 \\comptime {
8 \\ @export(entry, .{ .name = "" });
9 \\}
10 , &[_][]const u8{
11 "tmp.zig:3:5: error: exported symbol name cannot be empty",
12 });
13
514 cases.addTest("switch ranges endpoints are validated",
615 \\pub export fn entry() void {
716 \\ var x: i32 = 0;