Merge pull request #24199 from Justus2308/24106-fmt-casts
zig fmt: canonicalize nested cast builtin order
This commit is contained in:
@@ -1091,7 +1091,7 @@ test "initialize pointer to anyopaque with reference to empty array initializer"
|
||||
const ptr: *const anyopaque = &.{};
|
||||
// The above acts like an untyped initializer, since the `.{}` has no result type.
|
||||
// So, `ptr` points in memory to an empty tuple (`@TypeOf(.{})`).
|
||||
const casted: *const @TypeOf(.{}) = @alignCast(@ptrCast(ptr));
|
||||
const casted: *const @TypeOf(.{}) = @ptrCast(@alignCast(ptr));
|
||||
const loaded = casted.*;
|
||||
// `val` should be a `@TypeOf(.{})`, as expected.
|
||||
// We can't check the value, but it's zero-bit, so the type matching is good enough.
|
||||
|
||||
@@ -477,7 +477,7 @@ fn GenericIntApplier(
|
||||
}
|
||||
|
||||
fn typeErasedApplyFn(context: *const anyopaque, arg: u32) void {
|
||||
const ptr: *const Context = @alignCast(@ptrCast(context));
|
||||
const ptr: *const Context = @ptrCast(@alignCast(context));
|
||||
applyFn(ptr.*, arg);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -8,7 +8,7 @@ test "anyopaque extern symbol" {
|
||||
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
|
||||
|
||||
const a = @extern(*anyopaque, .{ .name = "a_mystery_symbol" });
|
||||
const b: *i32 = @alignCast(@ptrCast(a));
|
||||
const b: *i32 = @ptrCast(@alignCast(a));
|
||||
try expect(b.* == 1234);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ export fn b() void {
|
||||
_ = @constCast(@volatileCast(123));
|
||||
}
|
||||
export fn c() void {
|
||||
const x: ?*f32 = @constCast(@ptrCast(@addrSpaceCast(@volatileCast(p))));
|
||||
const x: ?*f32 = @ptrCast(@addrSpaceCast(@constCast(@volatileCast(p))));
|
||||
_ = x;
|
||||
}
|
||||
|
||||
|
||||
@@ -3234,12 +3234,12 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
|
||||
\\pub export fn bar(arg_a: [*c]const c_int) void {
|
||||
\\ var a = arg_a;
|
||||
\\ _ = &a;
|
||||
\\ foo(@as([*c]c_int, @ptrCast(@volatileCast(@constCast(a)))));
|
||||
\\ foo(@as([*c]c_int, @ptrCast(@constCast(@volatileCast(a)))));
|
||||
\\}
|
||||
\\pub export fn baz(arg_a: [*c]volatile c_int) void {
|
||||
\\ var a = arg_a;
|
||||
\\ _ = &a;
|
||||
\\ foo(@as([*c]c_int, @ptrCast(@volatileCast(@constCast(a)))));
|
||||
\\ foo(@as([*c]c_int, @ptrCast(@constCast(@volatileCast(a)))));
|
||||
\\}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user