| author | |
| committer | |
| log | b0f80ef0d5517b5ce8ba60dfae6dd986346f8d4c |
| tree | 14dbc30206ceed6282ee010685de8da1ede4167d |
| parent | df7d6d263e4ad6adb302856235641ae9ceb142b6 |
The LLVM backend no longer needs this hack! However, the other backends
still do. So there are still some traces of this workaround in use for now.5 files changed, 23 insertions(+), 17 deletions(-)
lib/std/special/compiler_rt.zig+1-1| ... | @@ -2,7 +2,7 @@ const std = @import("std"); | ... | @@ -2,7 +2,7 @@ const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const is_test = builtin.is_test; | 3 | const is_test = builtin.is_test; |
| 4 | const os_tag = builtin.os.tag; | 4 | const os_tag = builtin.os.tag; |
| 5 | const arch = builtin.stage2_arch; | 5 | const arch = builtin.cpu.arch; |
| 6 | const abi = builtin.abi; | 6 | const abi = builtin.abi; |
| 7 | 7 | ||
| 8 | const is_gnu = abi.isGnu(); | 8 | const is_gnu = abi.isGnu(); |
src/Sema.zig+18-11| ... | @@ -10186,7 +10186,7 @@ fn validateVarType( | ... | @@ -10186,7 +10186,7 @@ fn validateVarType( |
| 10186 | is_extern: bool, | 10186 | is_extern: bool, |
| 10187 | ) CompileError!void { | 10187 | ) CompileError!void { |
| 10188 | var ty = var_ty; | 10188 | var ty = var_ty; |
| 10189 | const ok: bool = while (true) switch (ty.zigTypeTag()) { | 10189 | while (true) switch (ty.zigTypeTag()) { |
| 10190 | .Bool, | 10190 | .Bool, |
| 10191 | .Int, | 10191 | .Int, |
| 10192 | .Float, | 10192 | .Float, |
| ... | @@ -10194,7 +10194,7 @@ fn validateVarType( | ... | @@ -10194,7 +10194,7 @@ fn validateVarType( |
| 10194 | .Enum, | 10194 | .Enum, |
| 10195 | .Frame, | 10195 | .Frame, |
| 10196 | .AnyFrame, | 10196 | .AnyFrame, |
| 10197 | => break true, | 10197 | => return, |
| 10198 | 10198 | ||
| 10199 | .BoundFn, | 10199 | .BoundFn, |
| 10200 | .ComptimeFloat, | 10200 | .ComptimeFloat, |
| ... | @@ -10205,14 +10205,14 @@ fn validateVarType( | ... | @@ -10205,14 +10205,14 @@ fn validateVarType( |
| 10205 | .Void, | 10205 | .Void, |
| 10206 | .Undefined, | 10206 | .Undefined, |
| 10207 | .Null, | 10207 | .Null, |
| 10208 | => break false, | 10208 | => break, |
| 10209 | 10209 | ||
| 10210 | .Pointer => { | 10210 | .Pointer => { |
| 10211 | const elem_ty = ty.childType(); | 10211 | const elem_ty = ty.childType(); |
| 10212 | if (elem_ty.zigTypeTag() == .Opaque) return; | 10212 | if (elem_ty.zigTypeTag() == .Opaque) return; |
| 10213 | ty = elem_ty; | 10213 | ty = elem_ty; |
| 10214 | }, | 10214 | }, |
| 10215 | .Opaque => break is_extern, | 10215 | .Opaque => if (is_extern) return else break, |
| 10216 | 10216 | ||
| 10217 | .Optional => { | 10217 | .Optional => { |
| 10218 | var buf: Type.Payload.ElemType = undefined; | 10218 | var buf: Type.Payload.ElemType = undefined; |
| ... | @@ -10223,15 +10223,17 @@ fn validateVarType( | ... | @@ -10223,15 +10223,17 @@ fn validateVarType( |
| 10223 | 10223 | ||
| 10224 | .ErrorUnion => ty = ty.errorUnionPayload(), | 10224 | .ErrorUnion => ty = ty.errorUnionPayload(), |
| 10225 | 10225 | ||
| 10226 | .Fn => @panic("TODO fn validateVarType"), | 10226 | .Fn, .Struct, .Union => { |
| 10227 | .Struct, .Union => { | ||
| 10228 | const resolved_ty = try sema.resolveTypeFields(block, src, ty); | 10227 | const resolved_ty = try sema.resolveTypeFields(block, src, ty); |
| 10229 | break !resolved_ty.requiresComptime(); | 10228 | if (resolved_ty.requiresComptime()) { |
| 10229 | break; | ||
| 10230 | } else { | ||
| 10231 | return; | ||
| 10232 | } | ||
| 10230 | }, | 10233 | }, |
| 10231 | } else unreachable; // TODO should not need else unreachable | 10234 | } else unreachable; // TODO should not need else unreachable |
| 10232 | if (!ok) { | 10235 | |
| 10233 | return sema.fail(block, src, "variable of type '{}' must be const or comptime", .{var_ty}); | 10236 | return sema.fail(block, src, "variable of type '{}' must be const or comptime", .{var_ty}); |
| 10234 | } | ||
| 10235 | } | 10237 | } |
| 10236 | 10238 | ||
| 10237 | pub const PanicId = enum { | 10239 | pub const PanicId = enum { |
| ... | @@ -11273,7 +11275,12 @@ fn coerce( | ... | @@ -11273,7 +11275,12 @@ fn coerce( |
| 11273 | 11275 | ||
| 11274 | const in_memory_result = coerceInMemoryAllowed(dest_type, inst_ty, false, target); | 11276 | const in_memory_result = coerceInMemoryAllowed(dest_type, inst_ty, false, target); |
| 11275 | if (in_memory_result == .ok) { | 11277 | if (in_memory_result == .ok) { |
| 11276 | return sema.bitCast(block, dest_type, inst, inst_src); | 11278 | if (try sema.resolveMaybeUndefVal(block, inst_src, inst)) |val| { |
| 11279 | // Keep the comptime Value representation; take the new type. | ||
| 11280 | return sema.addConstant(dest_type, val); | ||
| 11281 | } | ||
| 11282 | try sema.requireRuntimeBlock(block, inst_src); | ||
| 11283 | return block.addTyOp(.bitcast, dest_type, inst); | ||
| 11277 | } | 11284 | } |
| 11278 | 11285 | ||
| 11279 | // undefined to anything | 11286 | // undefined to anything |
src/type.zig+1-2| ... | @@ -1458,7 +1458,7 @@ pub const Type = extern union { | ... | @@ -1458,7 +1458,7 @@ pub const Type = extern union { |
| 1458 | } | 1458 | } |
| 1459 | }, | 1459 | }, |
| 1460 | .union_tagged => { | 1460 | .union_tagged => { |
| 1461 | const union_obj = self.castTag(.@"union").?.data; | 1461 | const union_obj = self.castTag(.union_tagged).?.data; |
| 1462 | if (union_obj.tag_ty.hasCodeGenBits()) { | 1462 | if (union_obj.tag_ty.hasCodeGenBits()) { |
| 1463 | return true; | 1463 | return true; |
| 1464 | } | 1464 | } |
| ... | @@ -1470,7 +1470,6 @@ pub const Type = extern union { | ... | @@ -1470,7 +1470,6 @@ pub const Type = extern union { |
| 1470 | } | 1470 | } |
| 1471 | }, | 1471 | }, |
| 1472 | 1472 | ||
| 1473 | // TODO lazy types | ||
| 1474 | .array, .vector => self.elemType().hasCodeGenBits() and self.arrayLen() != 0, | 1473 | .array, .vector => self.elemType().hasCodeGenBits() and self.arrayLen() != 0, |
| 1475 | .array_u8 => self.arrayLen() != 0, | 1474 | .array_u8 => self.arrayLen() != 0, |
| 1476 | 1475 |
test/behavior/atomics.zig+1-1| ... | @@ -89,7 +89,7 @@ test "128-bit cmpxchg" { | ... | @@ -89,7 +89,7 @@ test "128-bit cmpxchg" { |
| 89 | 89 | ||
| 90 | fn test_u128_cmpxchg() !void { | 90 | fn test_u128_cmpxchg() !void { |
| 91 | if (builtin.zig_is_stage2) { | 91 | if (builtin.zig_is_stage2) { |
| 92 | if (builtin.stage2_arch != .x86_64) return error.SkipZigTest; | 92 | if (builtin.cpu.arch != .x86_64) return error.SkipZigTest; |
| 93 | if (!builtin.stage2_x86_cx16) return error.SkipZigTest; | 93 | if (!builtin.stage2_x86_cx16) return error.SkipZigTest; |
| 94 | } else { | 94 | } else { |
| 95 | if (builtin.cpu.arch != .x86_64) return error.SkipZigTest; | 95 | if (builtin.cpu.arch != .x86_64) return error.SkipZigTest; |
test/behavior/widening.zig+2-2| ... | @@ -30,8 +30,8 @@ test "float widening" { | ... | @@ -30,8 +30,8 @@ test "float widening" { |
| 30 | 30 | ||
| 31 | test "float widening f16 to f128" { | 31 | test "float widening f16 to f128" { |
| 32 | // TODO https://github.com/ziglang/zig/issues/3282 | 32 | // TODO https://github.com/ziglang/zig/issues/3282 |
| 33 | if (@import("builtin").stage2_arch == .aarch64) return error.SkipZigTest; | 33 | if (@import("builtin").cpu.arch == .aarch64) return error.SkipZigTest; |
| 34 | if (@import("builtin").stage2_arch == .powerpc64le) return error.SkipZigTest; | 34 | if (@import("builtin").cpu.arch == .powerpc64le) return error.SkipZigTest; |
| 35 | 35 | ||
| 36 | var x: f16 = 12.34; | 36 | var x: f16 = 12.34; |
| 37 | var y: f128 = x; | 37 | var y: f128 = x; |