mirror of
https://github.com/ziglang/zig.git
synced 2026-02-15 13:58:27 +00:00
commit
4071b22454
@ -453,7 +453,7 @@ fn __atomic_fetch_nand_8(ptr: *u64, val: u64, model: i32) callconv(.C) u64 {
|
||||
}
|
||||
|
||||
comptime {
|
||||
if (supports_atomic_ops) {
|
||||
if (supports_atomic_ops and builtin.object_format != .c) {
|
||||
@export(__atomic_load, .{ .name = "__atomic_load", .linkage = linkage });
|
||||
@export(__atomic_store, .{ .name = "__atomic_store", .linkage = linkage });
|
||||
@export(__atomic_exchange, .{ .name = "__atomic_exchange", .linkage = linkage });
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
const std = @import("std");
|
||||
const common = @import("./common.zig");
|
||||
const builtin = @import("builtin");
|
||||
|
||||
comptime {
|
||||
@export(memcpy, .{ .name = "memcpy", .linkage = common.linkage });
|
||||
if (builtin.object_format != .c) {
|
||||
@export(memcpy, .{ .name = "memcpy", .linkage = common.linkage });
|
||||
}
|
||||
}
|
||||
|
||||
pub fn memcpy(noalias dest: ?[*]u8, noalias src: ?[*]const u8, len: usize) callconv(.C) ?[*]u8 {
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
const std = @import("std");
|
||||
const common = @import("./common.zig");
|
||||
const builtin = @import("builtin");
|
||||
|
||||
comptime {
|
||||
@export(memset, .{ .name = "memset", .linkage = common.linkage });
|
||||
@export(__memset, .{ .name = "__memset", .linkage = common.linkage });
|
||||
if (builtin.object_format != .c) {
|
||||
@export(memset, .{ .name = "memset", .linkage = common.linkage });
|
||||
@export(__memset, .{ .name = "__memset", .linkage = common.linkage });
|
||||
}
|
||||
}
|
||||
|
||||
pub fn memset(dest: ?[*]u8, c: u8, len: usize) callconv(.C) ?[*]u8 {
|
||||
|
||||
@ -8551,11 +8551,18 @@ fn shiftOp(
|
||||
rhs_node: Ast.Node.Index,
|
||||
tag: Zir.Inst.Tag,
|
||||
) InnerError!Zir.Inst.Ref {
|
||||
var line = gz.astgen.source_line - gz.decl_line;
|
||||
var column = gz.astgen.source_column;
|
||||
const lhs = try expr(gz, scope, .{ .rl = .none }, lhs_node);
|
||||
|
||||
maybeAdvanceSourceCursorToMainToken(gz, node);
|
||||
const line = gz.astgen.source_line - gz.decl_line;
|
||||
const column = gz.astgen.source_column;
|
||||
switch (gz.astgen.tree.nodes.items(.tag)[node]) {
|
||||
.shl, .shr => {
|
||||
maybeAdvanceSourceCursorToMainToken(gz, node);
|
||||
line = gz.astgen.source_line - gz.decl_line;
|
||||
column = gz.astgen.source_column;
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
|
||||
const log2_int_type = try gz.addUnNode(.typeof_log2_int_type, lhs, lhs_node);
|
||||
const rhs = try expr(gz, scope, .{ .rl = .{ .ty = log2_int_type }, .ctx = .shift_op }, rhs_node);
|
||||
|
||||
@ -3645,7 +3645,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com
|
||||
const final_elem_ty = try decl.ty.copy(sema.arena);
|
||||
const final_ptr_ty = try Type.ptr(sema.arena, sema.mod, .{
|
||||
.pointee_type = final_elem_ty,
|
||||
.mutable = var_is_mut,
|
||||
.mutable = true,
|
||||
.@"align" = iac.data.alignment,
|
||||
.@"addrspace" = target_util.defaultAddressSpace(target, .local),
|
||||
});
|
||||
@ -3669,7 +3669,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com
|
||||
|
||||
const final_ptr_ty = try Type.ptr(sema.arena, sema.mod, .{
|
||||
.pointee_type = final_elem_ty,
|
||||
.mutable = var_is_mut,
|
||||
.mutable = true,
|
||||
.@"align" = inferred_alloc.data.alignment,
|
||||
.@"addrspace" = target_util.defaultAddressSpace(target, .local),
|
||||
});
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -2895,6 +2895,12 @@ pub const Value = extern union {
|
||||
return val;
|
||||
},
|
||||
|
||||
.opt_payload_ptr => return val.castTag(.opt_payload_ptr).?.data.container_ptr.elemValueAdvanced(mod, index, arena, buffer),
|
||||
.eu_payload_ptr => return val.castTag(.eu_payload_ptr).?.data.container_ptr.elemValueAdvanced(mod, index, arena, buffer),
|
||||
|
||||
.opt_payload => return val.castTag(.opt_payload).?.data.elemValueAdvanced(mod, index, arena, buffer),
|
||||
.eu_payload => return val.castTag(.eu_payload).?.data.elemValueAdvanced(mod, index, arena, buffer),
|
||||
|
||||
else => unreachable,
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,6 +117,7 @@ test {
|
||||
_ = @import("behavior/bugs/13285.zig");
|
||||
_ = @import("behavior/bugs/13435.zig");
|
||||
_ = @import("behavior/bugs/13664.zig");
|
||||
_ = @import("behavior/bugs/13714.zig");
|
||||
_ = @import("behavior/byteswap.zig");
|
||||
_ = @import("behavior/byval_arg_var.zig");
|
||||
_ = @import("behavior/call.zig");
|
||||
|
||||
@ -739,7 +739,6 @@ test "thread local variable" {
|
||||
}
|
||||
|
||||
test "result location is optional inside error union" {
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
||||
|
||||
@ -771,6 +770,7 @@ threadlocal var buffer: [11]u8 = undefined;
|
||||
|
||||
test "auto created variables have correct alignment" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
|
||||
|
||||
const S = struct {
|
||||
fn foo(str: [*]const u8) u32 {
|
||||
|
||||
@ -5,7 +5,6 @@ const expect = std.testing.expect;
|
||||
test {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
|
||||
|
||||
var x: [10][10]u32 = undefined;
|
||||
|
||||
|
||||
@ -10,7 +10,6 @@ const U = union(enum) {
|
||||
test {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
|
||||
|
||||
var x = U{ .array = undefined };
|
||||
|
||||
|
||||
@ -6,7 +6,6 @@ test {
|
||||
if (builtin.zig_backend == .stage2_arm) 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_c) return error.SkipZigTest; // TODO
|
||||
|
||||
var opt_x: ?[3]f32 = [_]f32{0.0} ** 3;
|
||||
|
||||
|
||||
4
test/behavior/bugs/13714.zig
Normal file
4
test/behavior/bugs/13714.zig
Normal file
@ -0,0 +1,4 @@
|
||||
comptime {
|
||||
var image: [1]u8 = undefined;
|
||||
_ = @shlExact(@as(u16, image[0]), 8);
|
||||
}
|
||||
@ -1101,7 +1101,6 @@ test "enum literal in array literal" {
|
||||
}
|
||||
|
||||
test "tag name functions are unique" {
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
|
||||
@ -798,7 +798,6 @@ test "comptime fixed-width float non-zero divided by zero produces signed Inf" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
|
||||
|
||||
inline for (.{ f16, f32, f64, f80, f128 }) |F| {
|
||||
const pos = @as(F, 1) / @as(F, 0);
|
||||
@ -897,7 +896,6 @@ test "nan negation f80" {
|
||||
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
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
|
||||
|
||||
const nan_comptime = comptime math.nan(f80);
|
||||
const neg_nan_comptime = -nan_comptime;
|
||||
|
||||
@ -133,7 +133,6 @@ test "if-else expression with runtime condition result location is inferred opti
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
|
||||
|
||||
const A = struct { b: u64, c: u64 };
|
||||
var d: bool = true;
|
||||
|
||||
@ -315,8 +315,6 @@ test "comptime_int multi-limb partial shift right" {
|
||||
}
|
||||
|
||||
test "xor" {
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
|
||||
|
||||
try test_xor();
|
||||
comptime try test_xor();
|
||||
}
|
||||
@ -572,7 +570,6 @@ fn testShrTrunc(x: u16) !void {
|
||||
}
|
||||
|
||||
test "f128" {
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_wasm) 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
|
||||
|
||||
@ -342,7 +342,6 @@ test "optional pointer to zero bit optional payload" {
|
||||
}
|
||||
|
||||
test "optional pointer to zero bit error union payload" {
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
|
||||
@ -548,7 +548,6 @@ test "switch prongs with cases with identical payload types" {
|
||||
}
|
||||
|
||||
test "switch on pointer type" {
|
||||
if (builtin.zig_backend == .stage2_c) 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
|
||||
|
||||
|
||||
@ -535,3 +535,25 @@ test "Type.Fn" {
|
||||
try std.testing.expectEqual(T, fn_type);
|
||||
}
|
||||
}
|
||||
|
||||
test "reified struct field name from optional payload" {
|
||||
comptime {
|
||||
const m_name: ?[1]u8 = "a".*;
|
||||
if (m_name) |*name| {
|
||||
const T = @Type(.{ .Struct = .{
|
||||
.layout = .Auto,
|
||||
.fields = &.{.{
|
||||
.name = name,
|
||||
.field_type = u8,
|
||||
.default_value = null,
|
||||
.is_comptime = false,
|
||||
.alignment = 1,
|
||||
}},
|
||||
.decls = &.{},
|
||||
.is_tuple = false,
|
||||
} });
|
||||
var t: T = .{ .a = 123 };
|
||||
try std.testing.expect(t.a == 123);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1376,7 +1376,6 @@ test "union field ptr - zero sized field" {
|
||||
|
||||
test "packed union in packed struct" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user