Commit d62229e3ad
Changed files (3)
src
test
behavior
src/Module.zig
@@ -1210,6 +1210,7 @@ pub const Union = struct {
return @intCast(u32, most_index);
}
+ /// Returns 0 if the union is represented with 0 bits at runtime.
pub fn abiAlignment(u: Union, target: Target, have_tag: bool) u32 {
var max_align: u32 = 0;
if (have_tag) max_align = u.tag_ty.abiAlignment(target);
@@ -1225,7 +1226,6 @@ pub const Union = struct {
};
max_align = @maximum(max_align, field_align);
}
- assert(max_align != 0);
return max_align;
}
test/behavior/floatop.zig
@@ -155,15 +155,14 @@ test "@sin" {
fn testSin() !void {
// stage1 emits an incorrect compile error for `@as(ty, std.math.pi / 2)`
- // so skip the rest of the tests.
- if (builtin.zig_backend != .stage1) {
- inline for ([_]type{ f16, f32, f64 }) |ty| {
- const eps = epsForType(ty);
- try expect(@sin(@as(ty, 0)) == 0);
- try expect(math.approxEqAbs(ty, @sin(@as(ty, std.math.pi)), 0, eps));
- try expect(math.approxEqAbs(ty, @sin(@as(ty, std.math.pi / 2)), 1, eps));
- try expect(math.approxEqAbs(ty, @sin(@as(ty, std.math.pi / 4)), 0.7071067811865475, eps));
- }
+ if (builtin.zig_backend == .stage1) return error.SkipZigTest;
+
+ inline for ([_]type{ f16, f32, f64 }) |ty| {
+ const eps = epsForType(ty);
+ try expect(@sin(@as(ty, 0)) == 0);
+ try expect(math.approxEqAbs(ty, @sin(@as(ty, std.math.pi)), 0, eps));
+ try expect(math.approxEqAbs(ty, @sin(@as(ty, std.math.pi / 2)), 1, eps));
+ try expect(math.approxEqAbs(ty, @sin(@as(ty, std.math.pi / 4)), 0.7071067811865475, eps));
}
{
@@ -183,15 +182,14 @@ test "@cos" {
fn testCos() !void {
// stage1 emits an incorrect compile error for `@as(ty, std.math.pi / 2)`
- // so skip the rest of the tests.
- if (builtin.zig_backend != .stage1) {
- inline for ([_]type{ f16, f32, f64 }) |ty| {
- const eps = epsForType(ty);
- try expect(@cos(@as(ty, 0)) == 1);
- try expect(math.approxEqAbs(ty, @cos(@as(ty, std.math.pi)), -1, eps));
- try expect(math.approxEqAbs(ty, @cos(@as(ty, std.math.pi / 2)), 0, eps));
- try expect(math.approxEqAbs(ty, @cos(@as(ty, std.math.pi / 4)), 0.7071067811865475, eps));
- }
+ if (builtin.zig_backend == .stage1) return error.SkipZigTest;
+
+ inline for ([_]type{ f16, f32, f64 }) |ty| {
+ const eps = epsForType(ty);
+ try expect(@cos(@as(ty, 0)) == 1);
+ try expect(math.approxEqAbs(ty, @cos(@as(ty, std.math.pi)), -1, eps));
+ try expect(math.approxEqAbs(ty, @cos(@as(ty, std.math.pi / 2)), 0, eps));
+ try expect(math.approxEqAbs(ty, @cos(@as(ty, std.math.pi / 4)), 0.7071067811865475, eps));
}
{
test/behavior/union.zig
@@ -648,7 +648,9 @@ fn testEnumWithSpecifiedAndUnspecifiedTagValues(x: MultipleChoice2) !void {
}
test "switch on union with only 1 field" {
- if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
+ if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
+ if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
+ if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
var r: PartialInst = undefined;
r = PartialInst.Compiled;