Commit b0f80ef0d5
Changed files (5)
lib/std/special/compiler_rt.zig
@@ -2,7 +2,7 @@ const std = @import("std");
const builtin = @import("builtin");
const is_test = builtin.is_test;
const os_tag = builtin.os.tag;
-const arch = builtin.stage2_arch;
+const arch = builtin.cpu.arch;
const abi = builtin.abi;
const is_gnu = abi.isGnu();
src/Sema.zig
@@ -10186,7 +10186,7 @@ fn validateVarType(
is_extern: bool,
) CompileError!void {
var ty = var_ty;
- const ok: bool = while (true) switch (ty.zigTypeTag()) {
+ while (true) switch (ty.zigTypeTag()) {
.Bool,
.Int,
.Float,
@@ -10194,7 +10194,7 @@ fn validateVarType(
.Enum,
.Frame,
.AnyFrame,
- => break true,
+ => return,
.BoundFn,
.ComptimeFloat,
@@ -10205,14 +10205,14 @@ fn validateVarType(
.Void,
.Undefined,
.Null,
- => break false,
+ => break,
.Pointer => {
const elem_ty = ty.childType();
if (elem_ty.zigTypeTag() == .Opaque) return;
ty = elem_ty;
},
- .Opaque => break is_extern,
+ .Opaque => if (is_extern) return else break,
.Optional => {
var buf: Type.Payload.ElemType = undefined;
@@ -10223,15 +10223,17 @@ fn validateVarType(
.ErrorUnion => ty = ty.errorUnionPayload(),
- .Fn => @panic("TODO fn validateVarType"),
- .Struct, .Union => {
+ .Fn, .Struct, .Union => {
const resolved_ty = try sema.resolveTypeFields(block, src, ty);
- break !resolved_ty.requiresComptime();
+ if (resolved_ty.requiresComptime()) {
+ break;
+ } else {
+ return;
+ }
},
} else unreachable; // TODO should not need else unreachable
- if (!ok) {
- return sema.fail(block, src, "variable of type '{}' must be const or comptime", .{var_ty});
- }
+
+ return sema.fail(block, src, "variable of type '{}' must be const or comptime", .{var_ty});
}
pub const PanicId = enum {
@@ -11273,7 +11275,12 @@ fn coerce(
const in_memory_result = coerceInMemoryAllowed(dest_type, inst_ty, false, target);
if (in_memory_result == .ok) {
- return sema.bitCast(block, dest_type, inst, inst_src);
+ if (try sema.resolveMaybeUndefVal(block, inst_src, inst)) |val| {
+ // Keep the comptime Value representation; take the new type.
+ return sema.addConstant(dest_type, val);
+ }
+ try sema.requireRuntimeBlock(block, inst_src);
+ return block.addTyOp(.bitcast, dest_type, inst);
}
// undefined to anything
src/type.zig
@@ -1458,7 +1458,7 @@ pub const Type = extern union {
}
},
.union_tagged => {
- const union_obj = self.castTag(.@"union").?.data;
+ const union_obj = self.castTag(.union_tagged).?.data;
if (union_obj.tag_ty.hasCodeGenBits()) {
return true;
}
@@ -1470,7 +1470,6 @@ pub const Type = extern union {
}
},
- // TODO lazy types
.array, .vector => self.elemType().hasCodeGenBits() and self.arrayLen() != 0,
.array_u8 => self.arrayLen() != 0,
test/behavior/atomics.zig
@@ -89,7 +89,7 @@ test "128-bit cmpxchg" {
fn test_u128_cmpxchg() !void {
if (builtin.zig_is_stage2) {
- if (builtin.stage2_arch != .x86_64) return error.SkipZigTest;
+ if (builtin.cpu.arch != .x86_64) return error.SkipZigTest;
if (!builtin.stage2_x86_cx16) return error.SkipZigTest;
} else {
if (builtin.cpu.arch != .x86_64) return error.SkipZigTest;
test/behavior/widening.zig
@@ -30,8 +30,8 @@ test "float widening" {
test "float widening f16 to f128" {
// TODO https://github.com/ziglang/zig/issues/3282
- if (@import("builtin").stage2_arch == .aarch64) return error.SkipZigTest;
- if (@import("builtin").stage2_arch == .powerpc64le) return error.SkipZigTest;
+ if (@import("builtin").cpu.arch == .aarch64) return error.SkipZigTest;
+ if (@import("builtin").cpu.arch == .powerpc64le) return error.SkipZigTest;
var x: f16 = 12.34;
var y: f128 = x;