| author | |
| committer | |
| log | 0577069af5f5deb859762725736537d60c324453 |
| tree | f57aaa7713101bd2cabc82f505bdd156a988ac04 |
| parent | b48d8cce52369e7625f9dab8a37efe9c3a33186b |
6 files changed, 34 insertions(+), 10 deletions(-)
lib/std/fmt.zig-1| ... | @@ -762,7 +762,6 @@ fn formatFloatValue( | ... | @@ -762,7 +762,6 @@ fn formatFloatValue( |
| 762 | if (fmt.len == 0 or comptime std.mem.eql(u8, fmt, "e")) { | 762 | if (fmt.len == 0 or comptime std.mem.eql(u8, fmt, "e")) { |
| 763 | formatFloatScientific(value, options, buf_stream.writer()) catch |err| switch (err) { | 763 | formatFloatScientific(value, options, buf_stream.writer()) catch |err| switch (err) { |
| 764 | error.NoSpaceLeft => unreachable, | 764 | error.NoSpaceLeft => unreachable, |
| 765 | else => |e| return e, | ||
| 766 | }; | 765 | }; |
| 767 | } else if (comptime std.mem.eql(u8, fmt, "d")) { | 766 | } else if (comptime std.mem.eql(u8, fmt, "d")) { |
| 768 | formatFloatDecimal(value, options, buf_stream.writer()) catch |err| switch (err) { | 767 | formatFloatDecimal(value, options, buf_stream.writer()) catch |err| switch (err) { |
lib/std/os/linux.zig+2-7| ... | @@ -1080,13 +1080,8 @@ pub fn sigaction(sig: u6, noalias act: ?*const Sigaction, noalias oact: ?*Sigact | ... | @@ -1080,13 +1080,8 @@ pub fn sigaction(sig: u6, noalias act: ?*const Sigaction, noalias oact: ?*Sigact |
| 1080 | const mask_size = @sizeOf(@TypeOf(ksa.mask)); | 1080 | const mask_size = @sizeOf(@TypeOf(ksa.mask)); |
| 1081 | 1081 | ||
| 1082 | if (act) |new| { | 1082 | if (act) |new| { |
| 1083 | const restore_rt_ptr = if (builtin.zig_backend == .stage1) restore_rt else &syscall_bits.restore_rt; | 1083 | const restore_rt_ptr = if (builtin.zig_backend == .stage1) restore_rt else &restore_rt; |
| 1084 | // TODO https://github.com/ziglang/zig/issues/11227 | 1084 | const restore_ptr = if (builtin.zig_backend == .stage1) restore else &restore; |
| 1085 | const restore_ptr = if (builtin.zig_backend == .stage1) restore else switch (native_arch) { | ||
| 1086 | .arm, .thumb, .mips, .mipsel, .i386 => &syscall_bits.restore, | ||
| 1087 | .x86_64, .aarch64, .riscv64, .sparcv9, .powerpc, .powerpc64, .powerpc64le => &syscall_bits.restore_rt, | ||
| 1088 | else => unreachable, | ||
| 1089 | }; | ||
| 1090 | const restorer_fn = if ((new.flags & SA.SIGINFO) != 0) restore_rt_ptr else restore_ptr; | 1085 | const restorer_fn = if ((new.flags & SA.SIGINFO) != 0) restore_rt_ptr else restore_ptr; |
| 1091 | ksa = k_sigaction{ | 1086 | ksa = k_sigaction{ |
| 1092 | .handler = new.handler.handler, | 1087 | .handler = new.handler.handler, |
src/codegen/llvm.zig+11| ... | @@ -3073,6 +3073,17 @@ pub const DeclGen = struct { | ... | @@ -3073,6 +3073,17 @@ pub const DeclGen = struct { |
| 3073 | return self.context.constStruct(&fields, fields.len, .False); | 3073 | return self.context.constStruct(&fields, fields.len, .False); |
| 3074 | } | 3074 | } |
| 3075 | 3075 | ||
| 3076 | // In the case of something like: | ||
| 3077 | // fn foo() void {} | ||
| 3078 | // const bar = foo; | ||
| 3079 | // ... &bar; | ||
| 3080 | // `bar` is just an alias and we actually want to lower a reference to `foo`. | ||
| 3081 | if (decl.val.castTag(.function)) |func| { | ||
| 3082 | if (func.data.owner_decl != decl) { | ||
| 3083 | return self.lowerDeclRefValue(tv, func.data.owner_decl); | ||
| 3084 | } | ||
| 3085 | } | ||
| 3086 | |||
| 3076 | const is_fn_body = decl.ty.zigTypeTag() == .Fn; | 3087 | const is_fn_body = decl.ty.zigTypeTag() == .Fn; |
| 3077 | if (!is_fn_body and !decl.ty.hasRuntimeBitsIgnoreComptime()) { | 3088 | if (!is_fn_body and !decl.ty.hasRuntimeBitsIgnoreComptime()) { |
| 3078 | return self.lowerPtrToVoid(tv.ty); | 3089 | return self.lowerPtrToVoid(tv.ty); |
test/behavior.zig+1| ... | @@ -161,6 +161,7 @@ test { | ... | @@ -161,6 +161,7 @@ test { |
| 161 | builtin.zig_backend != .stage2_wasm and | 161 | builtin.zig_backend != .stage2_wasm and |
| 162 | builtin.zig_backend != .stage2_c) | 162 | builtin.zig_backend != .stage2_c) |
| 163 | { | 163 | { |
| 164 | _ = @import("behavior/bugs/11227.zig"); | ||
| 164 | _ = @import("behavior/export.zig"); | 165 | _ = @import("behavior/export.zig"); |
| 165 | _ = @import("behavior/export_self_referential_type_info.zig"); | 166 | _ = @import("behavior/export_self_referential_type_info.zig"); |
| 166 | } | 167 | } |
test/behavior/bugs/11227.zig created+13| ... | @@ -0,0 +1,13 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const builtin = @import("builtin"); | ||
| 3 | |||
| 4 | fn foo() u32 { | ||
| 5 | return 11227; | ||
| 6 | } | ||
| 7 | const bar = foo; | ||
| 8 | test "pointer to alias behaves same as pointer to function" { | ||
| 9 | if (builtin.zig_backend == .stage1) return error.SkipZigTest; // stage1 has different function pointers | ||
| 10 | |||
| 11 | var a = &bar; | ||
| 12 | try std.testing.expect(foo() == a()); | ||
| 13 | } | ||
test/behavior/bugs/1277.zig+7-2| ... | @@ -2,15 +2,20 @@ const std = @import("std"); | ... | @@ -2,15 +2,20 @@ const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | 3 | ||
| 4 | const S = struct { | 4 | const S = struct { |
| 5 | f: ?fn () i32, | 5 | f: ?*const fn () i32, |
| 6 | }; | 6 | }; |
| 7 | 7 | ||
| 8 | const s = S{ .f = f }; | 8 | const s = S{ .f = &f }; |
| 9 | 9 | ||
| 10 | fn f() i32 { | 10 | fn f() i32 { |
| 11 | return 1234; | 11 | return 1234; |
| 12 | } | 12 | } |
| 13 | 13 | ||
| 14 | test "don't emit an LLVM global for a const function when it's in an optional in a struct" { | 14 | test "don't emit an LLVM global for a const function when it's in an optional in a struct" { |
| 15 | if (builtin.zig_backend == .stage1) return error.SkipZigTest; // stage1 has different function pointers | ||
| 16 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | ||
| 17 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | ||
| 18 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO | ||
| 19 | |||
| 15 | try std.testing.expect(s.f.?() == 1234); | 20 | try std.testing.expect(s.f.?() == 1234); |
| 16 | } | 21 | } |