diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2024-05-09 01:52:26 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2024-05-09 01:52:26 -0700 |
| commit | bcb534c295d5cc6fd63caa570cc08e6b148a507c (patch) | |
| tree | 0b17cb1e632d894f50f25e550d5113f232b0e877 /test | |
| parent | d9b00ee4ba48717ff6b306a6f9419e7b604ac04b (diff) | |
| parent | 74f52954b9cb40d59d80b839b45bb859146731a7 (diff) | |
| download | zig-bcb534c295d5cc6fd63caa570cc08e6b148a507c.tar.gz zig-bcb534c295d5cc6fd63caa570cc08e6b148a507c.zip | |
Merge branch 'llvm18'
Upgrades the LLVM, Clang, and LLD dependencies to LLVM 18.x
Related to #16270
Diffstat (limited to 'test')
| -rw-r--r-- | test/behavior/align.zig | 63 | ||||
| -rw-r--r-- | test/behavior/cast.zig | 7 | ||||
| -rw-r--r-- | test/behavior/error.zig | 10 | ||||
| -rw-r--r-- | test/behavior/shuffle.zig | 7 | ||||
| -rw-r--r-- | test/c_abi/cfuncs.c | 18 | ||||
| -rw-r--r-- | test/c_abi/main.zig | 75 |
6 files changed, 126 insertions, 54 deletions
diff --git a/test/behavior/align.zig b/test/behavior/align.zig index 36366fd52c..34d76fb4ba 100644 --- a/test/behavior/align.zig +++ b/test/behavior/align.zig @@ -114,77 +114,66 @@ test "alignment and size of structs with 128-bit fields" { .u129_size = 24, }, - .x86 => if (builtin.object_format == .c) .{ - .a_align = 16, - .a_size = 16, - - .b_align = 16, - .b_size = 32, - - .u128_align = 16, - .u128_size = 16, - .u129_align = 16, - .u129_size = 32, - } else switch (builtin.os.tag) { - .windows => .{ - .a_align = 8, + .mips64, + .mips64el, + .powerpc64, + .powerpc64le, + .sparc64, + => switch (builtin.object_format) { + .c => .{ + .a_align = 16, .a_size = 16, .b_align = 16, .b_size = 32, - .u128_align = 8, + .u128_align = 16, .u128_size = 16, - .u129_align = 8, - .u129_size = 24, + .u129_align = 16, + .u129_size = 32, }, else => .{ - .a_align = 4, + .a_align = 8, .a_size = 16, .b_align = 16, .b_size = 32, - .u128_align = 4, + .u128_align = 8, .u128_size = 16, - .u129_align = 4, - .u129_size = 20, + .u129_align = 8, + .u129_size = 24, }, }, - .mips64, - .mips64el, - .powerpc64, - .powerpc64le, - .sparc64, - .x86_64, - => switch (builtin.object_format) { - .c => .{ - .a_align = 16, + .x86_64 => switch (builtin.zig_backend) { + .stage2_x86_64 => .{ + .a_align = 8, .a_size = 16, .b_align = 16, .b_size = 32, - .u128_align = 16, + .u128_align = 8, .u128_size = 16, - .u129_align = 16, - .u129_size = 32, + .u129_align = 8, + .u129_size = 24, }, else => .{ - .a_align = 8, + .a_align = 16, .a_size = 16, .b_align = 16, .b_size = 32, - .u128_align = 8, + .u128_align = 16, .u128_size = 16, - .u129_align = 8, - .u129_size = 24, + .u129_align = 16, + .u129_size = 32, }, }, + .x86, .aarch64, .aarch64_be, .aarch64_32, diff --git a/test/behavior/cast.zig b/test/behavior/cast.zig index 72e48de104..2f47155cc4 100644 --- a/test/behavior/cast.zig +++ b/test/behavior/cast.zig @@ -2481,6 +2481,13 @@ test "@intFromBool on vector" { if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_llvm and + builtin.cpu.arch == .aarch64 and builtin.os.tag == .windows) + { + // https://github.com/ziglang/zig/issues/19825 + return error.SkipZigTest; + } + const S = struct { fn doTheTest() !void { var a: @Vector(3, bool) = .{ false, true, false }; diff --git a/test/behavior/error.zig b/test/behavior/error.zig index 408dc96005..7703a02f68 100644 --- a/test/behavior/error.zig +++ b/test/behavior/error.zig @@ -1077,3 +1077,13 @@ test "result location initialization of error union with OPV payload" { _ = &c; try expectEqual(0, (c catch return error.TestFailed).x); } + +test "return error union with i65" { + if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; + + try expect(try add(1000, 234) == 1234); +} + +fn add(x: i65, y: i65) anyerror!i65 { + return x + y; +} diff --git a/test/behavior/shuffle.zig b/test/behavior/shuffle.zig index c3d760103d..58c925b8fd 100644 --- a/test/behavior/shuffle.zig +++ b/test/behavior/shuffle.zig @@ -55,6 +55,13 @@ test "@shuffle bool 1" { if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_llvm and + builtin.cpu.arch == .aarch64 and builtin.os.tag == .windows) + { + // https://github.com/ziglang/zig/issues/19824 + return error.SkipZigTest; + } + const S = struct { fn doTheTest() !void { var x: @Vector(4, bool) = [4]bool{ false, true, false, true }; diff --git a/test/c_abi/cfuncs.c b/test/c_abi/cfuncs.c index e948c067ac..028f6e06d2 100644 --- a/test/c_abi/cfuncs.c +++ b/test/c_abi/cfuncs.c @@ -5478,17 +5478,35 @@ f80_extra_struct c_f80_extra_struct(f80_extra_struct a) { #endif #ifndef ZIG_NO_F128 +__float128 zig_f128(__float128 a); __float128 c_f128(__float128 a) { assert_or_panic((double)a == 12.34); + assert_or_panic(zig_f128(12) == 34); return 56.78; } typedef struct { __float128 a; } f128_struct; +f128_struct zig_f128_struct(f128_struct a); f128_struct c_f128_struct(f128_struct a) { assert_or_panic((double)a.a == 12.34); + f128_struct b = zig_f128_struct((f128_struct){12345}); + assert_or_panic(b.a == 98765); return (f128_struct){56.78}; } + +typedef struct { + __float128 a, b; +} f128_f128_struct; +f128_f128_struct zig_f128_f128_struct(f128_f128_struct a); +f128_f128_struct c_f128_f128_struct(f128_f128_struct a) { + assert_or_panic((double)a.a == 12.34); + assert_or_panic((double)a.b == 87.65); + f128_f128_struct b = zig_f128_f128_struct((f128_f128_struct){13, 57}); + assert_or_panic((double)b.a == 24); + assert_or_panic((double)b.b == 68); + return (f128_f128_struct){56.78, 43.21}; +} #endif void __attribute__((stdcall)) stdcall_scalars(char a, short b, int c, float d, double e) { diff --git a/test/c_abi/main.zig b/test/c_abi/main.zig index 028156f35d..2bc93cc89e 100644 --- a/test/c_abi/main.zig +++ b/test/c_abi/main.zig @@ -136,7 +136,7 @@ export fn zig_f64(x: f64) void { expect(x == 56.78) catch @panic("test failure: zig_f64"); } export fn zig_longdouble(x: c_longdouble) void { - if (!builtin.cpu.arch.isWasm()) return; // waiting for #1481 + if (!builtin.target.isWasm()) return; // waiting for #1481 expect(x == 12.34) catch @panic("test failure: zig_longdouble"); } @@ -1671,7 +1671,7 @@ test "bool simd vector" { } { - if (builtin.target.cpu.arch != .wasm32) c_vector_256_bool(.{ + if (!builtin.target.isWasm()) c_vector_256_bool(.{ false, true, true, @@ -2189,7 +2189,7 @@ test "bool simd vector" { try expect(vec[255] == false); } { - if (builtin.target.cpu.arch != .wasm32) c_vector_512_bool(.{ + if (!builtin.target.isWasm()) c_vector_512_bool(.{ true, true, true, @@ -5614,23 +5614,64 @@ test "f80 extra struct" { try expect(a.b == 24); } -extern fn c_f128(f128) f128; -test "f128 bare" { - if (!have_f128) return error.SkipZigTest; +comptime { + skip: { + if (builtin.target.isWasm()) break :skip; - const a = c_f128(12.34); - try expect(@as(f64, @floatCast(a)) == 56.78); -} + _ = struct { + export fn zig_f128(x: f128) f128 { + expect(x == 12) catch @panic("test failure"); + return 34; + } + extern fn c_f128(f128) f128; + test "f128 bare" { + if (!have_f128) return error.SkipZigTest; -const f128_struct = extern struct { - a: f128, -}; -extern fn c_f128_struct(f128_struct) f128_struct; -test "f128 struct" { - if (!have_f128) return error.SkipZigTest; + const a = c_f128(12.34); + try expect(@as(f64, @floatCast(a)) == 56.78); + } - const a = c_f128_struct(.{ .a = 12.34 }); - try expect(@as(f64, @floatCast(a.a)) == 56.78); + const f128_struct = extern struct { + a: f128, + }; + export fn zig_f128_struct(a: f128_struct) f128_struct { + expect(a.a == 12345) catch @panic("test failure"); + return .{ .a = 98765 }; + } + extern fn c_f128_struct(f128_struct) f128_struct; + test "f128 struct" { + if (!have_f128) return error.SkipZigTest; + + const a = c_f128_struct(.{ .a = 12.34 }); + try expect(@as(f64, @floatCast(a.a)) == 56.78); + + const b = c_f128_f128_struct(.{ .a = 12.34, .b = 87.65 }); + try expect(@as(f64, @floatCast(b.a)) == 56.78); + try expect(@as(f64, @floatCast(b.b)) == 43.21); + } + + const f128_f128_struct = extern struct { + a: f128, + b: f128, + }; + export fn zig_f128_f128_struct(a: f128_f128_struct) f128_f128_struct { + expect(a.a == 13) catch @panic("test failure"); + expect(a.b == 57) catch @panic("test failure"); + return .{ .a = 24, .b = 68 }; + } + extern fn c_f128_f128_struct(f128_f128_struct) f128_f128_struct; + test "f128 f128 struct" { + if (!have_f128) return error.SkipZigTest; + + const a = c_f128_struct(.{ .a = 12.34 }); + try expect(@as(f64, @floatCast(a.a)) == 56.78); + + const b = c_f128_f128_struct(.{ .a = 12.34, .b = 87.65 }); + try expect(@as(f64, @floatCast(b.a)) == 56.78); + try expect(@as(f64, @floatCast(b.b)) == 43.21); + } + }; + } } // The stdcall attribute on C functions is ignored when compiled on non-x86 |
