| author | |
| committer | |
| log | e3c524c1d482a845bb2d6555bda386739c862226 |
| tree | f787e6def3e09691db95852e1a264eb660585af1 |
| parent | ecb71d1dd34e98fc9813cffa473f83127e6e3d01 |
17 files changed, 37 insertions(+), 37 deletions(-)
doc/langref.md+1-1| ... | @@ -623,7 +623,7 @@ calls the public `panic` function exposed in the root source file, or | ... | @@ -623,7 +623,7 @@ calls the public `panic` function exposed in the root source file, or |
| 623 | if there is not one specified, invokes the one provided in | 623 | if there is not one specified, invokes the one provided in |
| 624 | `std/special/panic.zig`. | 624 | `std/special/panic.zig`. |
| 625 | 625 | ||
| 626 | ### @ptrcast(comptime DestType: type, value: var) -> DestType | 626 | ### @ptrCast(comptime DestType: type, value: var) -> DestType |
| 627 | 627 | ||
| 628 | Converts a pointer of one type to a pointer of another type. | 628 | Converts a pointer of one type to a pointer of another type. |
| 629 | 629 |
src/codegen.cpp+1-1| ... | @@ -4551,7 +4551,7 @@ static void define_builtin_fns(CodeGen *g) { | ... | @@ -4551,7 +4551,7 @@ static void define_builtin_fns(CodeGen *g) { |
| 4551 | create_builtin_fn(g, BuiltinFnIdSetGlobalSection, "setGlobalSection", 2); | 4551 | create_builtin_fn(g, BuiltinFnIdSetGlobalSection, "setGlobalSection", 2); |
| 4552 | create_builtin_fn(g, BuiltinFnIdSetGlobalLinkage, "setGlobalLinkage", 2); | 4552 | create_builtin_fn(g, BuiltinFnIdSetGlobalLinkage, "setGlobalLinkage", 2); |
| 4553 | create_builtin_fn(g, BuiltinFnIdPanic, "panic", 1); | 4553 | create_builtin_fn(g, BuiltinFnIdPanic, "panic", 1); |
| 4554 | create_builtin_fn(g, BuiltinFnIdPtrCast, "ptrcast", 2); | 4554 | create_builtin_fn(g, BuiltinFnIdPtrCast, "ptrCast", 2); |
| 4555 | create_builtin_fn(g, BuiltinFnIdIntToPtr, "intToPtr", 2); | 4555 | create_builtin_fn(g, BuiltinFnIdIntToPtr, "intToPtr", 2); |
| 4556 | create_builtin_fn(g, BuiltinFnIdEnumTagName, "enumTagName", 1); | 4556 | create_builtin_fn(g, BuiltinFnIdEnumTagName, "enumTagName", 1); |
| 4557 | create_builtin_fn(g, BuiltinFnIdFieldParentPtr, "fieldParentPtr", 3); | 4557 | create_builtin_fn(g, BuiltinFnIdFieldParentPtr, "fieldParentPtr", 3); |
std/buf_map.zig+1-1| ... | @@ -58,7 +58,7 @@ pub const BufMap = struct { | ... | @@ -58,7 +58,7 @@ pub const BufMap = struct { |
| 58 | 58 | ||
| 59 | fn free(self: &BufMap, value: []const u8) { | 59 | fn free(self: &BufMap, value: []const u8) { |
| 60 | // remove the const | 60 | // remove the const |
| 61 | const mut_value = @ptrcast(&u8, value.ptr)[0...value.len]; | 61 | const mut_value = @ptrCast(&u8, value.ptr)[0...value.len]; |
| 62 | self.hash_map.allocator.free(mut_value); | 62 | self.hash_map.allocator.free(mut_value); |
| 63 | } | 63 | } |
| 64 | 64 |
std/buf_set.zig+1-1| ... | @@ -47,7 +47,7 @@ pub const BufSet = struct { | ... | @@ -47,7 +47,7 @@ pub const BufSet = struct { |
| 47 | 47 | ||
| 48 | fn free(self: &BufSet, value: []const u8) { | 48 | fn free(self: &BufSet, value: []const u8) { |
| 49 | // remove the const | 49 | // remove the const |
| 50 | const mut_value = @ptrcast(&u8, value.ptr)[0...value.len]; | 50 | const mut_value = @ptrCast(&u8, value.ptr)[0...value.len]; |
| 51 | self.hash_map.allocator.free(mut_value); | 51 | self.hash_map.allocator.free(mut_value); |
| 52 | } | 52 | } |
| 53 | 53 |
std/debug.zig+1-1| ... | @@ -74,7 +74,7 @@ pub fn writeStackTrace(out_stream: &io.OutStream) -> %void { | ... | @@ -74,7 +74,7 @@ pub fn writeStackTrace(out_stream: &io.OutStream) -> %void { |
| 74 | const name = %return compile_unit.die.getAttrString(st, DW.AT_name); | 74 | const name = %return compile_unit.die.getAttrString(st, DW.AT_name); |
| 75 | 75 | ||
| 76 | %return out_stream.printf("{} -> {}\n", return_address, name); | 76 | %return out_stream.printf("{} -> {}\n", return_address, name); |
| 77 | maybe_fp = *@ptrcast(&const ?&const u8, fp); | 77 | maybe_fp = *@ptrCast(&const ?&const u8, fp); |
| 78 | } | 78 | } |
| 79 | }, | 79 | }, |
| 80 | ObjectFormat.coff => { | 80 | ObjectFormat.coff => { |
std/hash_map.zig+1-1| ... | @@ -250,7 +250,7 @@ test "basicHashMapTest" { | ... | @@ -250,7 +250,7 @@ test "basicHashMapTest" { |
| 250 | } | 250 | } |
| 251 | 251 | ||
| 252 | fn hash_i32(x: i32) -> u32 { | 252 | fn hash_i32(x: i32) -> u32 { |
| 253 | *@ptrcast(&u32, &x) | 253 | *@ptrCast(&u32, &x) |
| 254 | } | 254 | } |
| 255 | 255 | ||
| 256 | fn eql_i32(a: i32, b: i32) -> bool { | 256 | fn eql_i32(a: i32, b: i32) -> bool { |
std/os/darwin.zig+1-1| ... | @@ -59,7 +59,7 @@ pub fn exit(status: usize) -> noreturn { | ... | @@ -59,7 +59,7 @@ pub fn exit(status: usize) -> noreturn { |
| 59 | 59 | ||
| 60 | /// Get the errno from a syscall return value, or 0 for no error. | 60 | /// Get the errno from a syscall return value, or 0 for no error. |
| 61 | pub fn getErrno(r: usize) -> usize { | 61 | pub fn getErrno(r: usize) -> usize { |
| 62 | const signed_r = *@ptrcast(&const isize, &r); | 62 | const signed_r = *@ptrCast(&const isize, &r); |
| 63 | if (signed_r > -4096 and signed_r < 0) usize(-signed_r) else 0 | 63 | if (signed_r > -4096 and signed_r < 0) usize(-signed_r) else 0 |
| 64 | } | 64 | } |
| 65 | 65 |
std/os/index.zig+1-1| ... | @@ -752,7 +752,7 @@ pub const Dir = struct { | ... | @@ -752,7 +752,7 @@ pub const Dir = struct { |
| 752 | break; | 752 | break; |
| 753 | } | 753 | } |
| 754 | } | 754 | } |
| 755 | const linux_entry = @ptrcast(&LinuxEntry, &self.buf[self.index]); | 755 | const linux_entry = @ptrCast(&LinuxEntry, &self.buf[self.index]); |
| 756 | const next_index = self.index + linux_entry.d_reclen; | 756 | const next_index = self.index + linux_entry.d_reclen; |
| 757 | self.index = next_index; | 757 | self.index = next_index; |
| 758 | 758 |
std/os/linux.zig+3-3| ... | @@ -251,8 +251,8 @@ pub const DT_LNK = 10; | ... | @@ -251,8 +251,8 @@ pub const DT_LNK = 10; |
| 251 | pub const DT_SOCK = 12; | 251 | pub const DT_SOCK = 12; |
| 252 | pub const DT_WHT = 14; | 252 | pub const DT_WHT = 14; |
| 253 | 253 | ||
| 254 | fn unsigned(s: i32) -> u32 { *@ptrcast(&u32, &s) } | 254 | fn unsigned(s: i32) -> u32 { *@ptrCast(&u32, &s) } |
| 255 | fn signed(s: u32) -> i32 { *@ptrcast(&i32, &s) } | 255 | fn signed(s: u32) -> i32 { *@ptrCast(&i32, &s) } |
| 256 | pub fn WEXITSTATUS(s: i32) -> i32 { signed((unsigned(s) & 0xff00) >> 8) } | 256 | pub fn WEXITSTATUS(s: i32) -> i32 { signed((unsigned(s) & 0xff00) >> 8) } |
| 257 | pub fn WTERMSIG(s: i32) -> i32 { signed(unsigned(s) & 0x7f) } | 257 | pub fn WTERMSIG(s: i32) -> i32 { signed(unsigned(s) & 0x7f) } |
| 258 | pub fn WSTOPSIG(s: i32) -> i32 { WEXITSTATUS(s) } | 258 | pub fn WSTOPSIG(s: i32) -> i32 { WEXITSTATUS(s) } |
| ... | @@ -262,7 +262,7 @@ pub fn WIFSIGNALED(s: i32) -> bool { (unsigned(s)&0xffff)-%1 < 0xff } | ... | @@ -262,7 +262,7 @@ pub fn WIFSIGNALED(s: i32) -> bool { (unsigned(s)&0xffff)-%1 < 0xff } |
| 262 | 262 | ||
| 263 | /// Get the errno from a syscall return value, or 0 for no error. | 263 | /// Get the errno from a syscall return value, or 0 for no error. |
| 264 | pub fn getErrno(r: usize) -> usize { | 264 | pub fn getErrno(r: usize) -> usize { |
| 265 | const signed_r = *@ptrcast(&const isize, &r); | 265 | const signed_r = *@ptrCast(&const isize, &r); |
| 266 | if (signed_r > -4096 and signed_r < 0) usize(-signed_r) else 0 | 266 | if (signed_r > -4096 and signed_r < 0) usize(-signed_r) else 0 |
| 267 | } | 267 | } |
| 268 | 268 |
std/special/bootstrap.zig+3-3| ... | @@ -31,8 +31,8 @@ export nakedcc fn _start() -> noreturn { | ... | @@ -31,8 +31,8 @@ export nakedcc fn _start() -> noreturn { |
| 31 | 31 | ||
| 32 | fn callMainAndExit() -> noreturn { | 32 | fn callMainAndExit() -> noreturn { |
| 33 | const argc = *argc_ptr; | 33 | const argc = *argc_ptr; |
| 34 | const argv = @ptrcast(&&u8, &argc_ptr[1]); | 34 | const argv = @ptrCast(&&u8, &argc_ptr[1]); |
| 35 | const envp = @ptrcast(&?&u8, &argv[argc + 1]); | 35 | const envp = @ptrCast(&?&u8, &argv[argc + 1]); |
| 36 | callMain(argc, argv, envp) %% exit(1); | 36 | callMain(argc, argv, envp) %% exit(1); |
| 37 | exit(0); | 37 | exit(0); |
| 38 | } | 38 | } |
| ... | @@ -42,7 +42,7 @@ fn callMain(argc: usize, argv: &&u8, envp: &?&u8) -> %void { | ... | @@ -42,7 +42,7 @@ fn callMain(argc: usize, argv: &&u8, envp: &?&u8) -> %void { |
| 42 | 42 | ||
| 43 | var env_count: usize = 0; | 43 | var env_count: usize = 0; |
| 44 | while (envp[env_count] != null; env_count += 1) {} | 44 | while (envp[env_count] != null; env_count += 1) {} |
| 45 | std.os.environ_raw = @ptrcast(&&u8, envp)[0...env_count]; | 45 | std.os.environ_raw = @ptrCast(&&u8, envp)[0...env_count]; |
| 46 | 46 | ||
| 47 | return root.main(); | 47 | return root.main(); |
| 48 | } | 48 | } |
std/special/compiler_rt.zig+12-12| ... | @@ -15,7 +15,7 @@ export fn __udivdi3(a: du_int, b: du_int) -> du_int { | ... | @@ -15,7 +15,7 @@ export fn __udivdi3(a: du_int, b: du_int) -> du_int { |
| 15 | 15 | ||
| 16 | fn du_int_to_udwords(x: du_int) -> udwords { | 16 | fn du_int_to_udwords(x: du_int) -> udwords { |
| 17 | @setDebugSafety(this, false); | 17 | @setDebugSafety(this, false); |
| 18 | return *@ptrcast(&udwords, &x); | 18 | return *@ptrCast(&udwords, &x); |
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | export fn __udivmoddi4(a: du_int, b: du_int, maybe_rem: ?&du_int) -> du_int { | 21 | export fn __udivmoddi4(a: du_int, b: du_int, maybe_rem: ?&du_int) -> du_int { |
| ... | @@ -66,7 +66,7 @@ export fn __udivmoddi4(a: du_int, b: du_int, maybe_rem: ?&du_int) -> du_int { | ... | @@ -66,7 +66,7 @@ export fn __udivmoddi4(a: du_int, b: du_int, maybe_rem: ?&du_int) -> du_int { |
| 66 | if (var rem ?= maybe_rem) { | 66 | if (var rem ?= maybe_rem) { |
| 67 | r[high] = n[high] % d[high]; | 67 | r[high] = n[high] % d[high]; |
| 68 | r[low] = 0; | 68 | r[low] = 0; |
| 69 | *rem = *@ptrcast(&du_int, &r[0]); | 69 | *rem = *@ptrCast(&du_int, &r[0]); |
| 70 | } | 70 | } |
| 71 | return n[high] / d[high]; | 71 | return n[high] / d[high]; |
| 72 | } | 72 | } |
| ... | @@ -78,7 +78,7 @@ export fn __udivmoddi4(a: du_int, b: du_int, maybe_rem: ?&du_int) -> du_int { | ... | @@ -78,7 +78,7 @@ export fn __udivmoddi4(a: du_int, b: du_int, maybe_rem: ?&du_int) -> du_int { |
| 78 | if (var rem ?= maybe_rem) { | 78 | if (var rem ?= maybe_rem) { |
| 79 | r[low] = n[low]; | 79 | r[low] = n[low]; |
| 80 | r[high] = n[high] & (d[high] - 1); | 80 | r[high] = n[high] & (d[high] - 1); |
| 81 | *rem = *@ptrcast(&du_int, &r[0]); | 81 | *rem = *@ptrCast(&du_int, &r[0]); |
| 82 | } | 82 | } |
| 83 | return n[high] >> @ctz(d[high]); | 83 | return n[high] >> @ctz(d[high]); |
| 84 | } | 84 | } |
| ... | @@ -89,7 +89,7 @@ export fn __udivmoddi4(a: du_int, b: du_int, maybe_rem: ?&du_int) -> du_int { | ... | @@ -89,7 +89,7 @@ export fn __udivmoddi4(a: du_int, b: du_int, maybe_rem: ?&du_int) -> du_int { |
| 89 | // 0 <= sr <= n_uword_bits - 2 or sr large | 89 | // 0 <= sr <= n_uword_bits - 2 or sr large |
| 90 | if (sr > n_uword_bits - 2) { | 90 | if (sr > n_uword_bits - 2) { |
| 91 | if (var rem ?= maybe_rem) { | 91 | if (var rem ?= maybe_rem) { |
| 92 | *rem = *@ptrcast(&du_int, &n[0]); | 92 | *rem = *@ptrCast(&du_int, &n[0]); |
| 93 | } | 93 | } |
| 94 | return 0; | 94 | return 0; |
| 95 | } | 95 | } |
| ... | @@ -113,12 +113,12 @@ export fn __udivmoddi4(a: du_int, b: du_int, maybe_rem: ?&du_int) -> du_int { | ... | @@ -113,12 +113,12 @@ export fn __udivmoddi4(a: du_int, b: du_int, maybe_rem: ?&du_int) -> du_int { |
| 113 | *rem = n[low] & (d[low] - 1); | 113 | *rem = n[low] & (d[low] - 1); |
| 114 | } | 114 | } |
| 115 | if (d[low] == 1) { | 115 | if (d[low] == 1) { |
| 116 | return *@ptrcast(&du_int, &n[0]); | 116 | return *@ptrCast(&du_int, &n[0]); |
| 117 | } | 117 | } |
| 118 | sr = @ctz(d[low]); | 118 | sr = @ctz(d[low]); |
| 119 | q[high] = n[high] >> sr; | 119 | q[high] = n[high] >> sr; |
| 120 | q[low] = (n[high] << (n_uword_bits - sr)) | (n[low] >> sr); | 120 | q[low] = (n[high] << (n_uword_bits - sr)) | (n[low] >> sr); |
| 121 | return *@ptrcast(&du_int, &q[0]); | 121 | return *@ptrCast(&du_int, &q[0]); |
| 122 | } | 122 | } |
| 123 | // K X | 123 | // K X |
| 124 | // --- | 124 | // --- |
| ... | @@ -154,7 +154,7 @@ export fn __udivmoddi4(a: du_int, b: du_int, maybe_rem: ?&du_int) -> du_int { | ... | @@ -154,7 +154,7 @@ export fn __udivmoddi4(a: du_int, b: du_int, maybe_rem: ?&du_int) -> du_int { |
| 154 | // 0 <= sr <= n_uword_bits - 1 or sr large | 154 | // 0 <= sr <= n_uword_bits - 1 or sr large |
| 155 | if (sr > n_uword_bits - 1) { | 155 | if (sr > n_uword_bits - 1) { |
| 156 | if (var rem ?= maybe_rem) { | 156 | if (var rem ?= maybe_rem) { |
| 157 | *rem = *@ptrcast(&du_int, &n[0]); | 157 | *rem = *@ptrCast(&du_int, &n[0]); |
| 158 | } | 158 | } |
| 159 | return 0; | 159 | return 0; |
| 160 | } | 160 | } |
| ... | @@ -191,17 +191,17 @@ export fn __udivmoddi4(a: du_int, b: du_int, maybe_rem: ?&du_int) -> du_int { | ... | @@ -191,17 +191,17 @@ export fn __udivmoddi4(a: du_int, b: du_int, maybe_rem: ?&du_int) -> du_int { |
| 191 | // r.all -= d.all; | 191 | // r.all -= d.all; |
| 192 | // carry = 1; | 192 | // carry = 1; |
| 193 | // } | 193 | // } |
| 194 | const s: di_int = (di_int)(*@ptrcast(&du_int, &d[0]) - *@ptrcast(&du_int, &r[0]) - 1) >> (n_udword_bits - 1); | 194 | const s: di_int = (di_int)(*@ptrCast(&du_int, &d[0]) - *@ptrCast(&du_int, &r[0]) - 1) >> (n_udword_bits - 1); |
| 195 | carry = su_int(s & 1); | 195 | carry = su_int(s & 1); |
| 196 | *@ptrcast(&du_int, &r[0]) -= *@ptrcast(&du_int, &d[0]) & u64(s); | 196 | *@ptrCast(&du_int, &r[0]) -= *@ptrCast(&du_int, &d[0]) & u64(s); |
| 197 | 197 | ||
| 198 | sr -= 1; | 198 | sr -= 1; |
| 199 | } | 199 | } |
| 200 | *@ptrcast(&du_int, &q[0]) = (*@ptrcast(&du_int, &q[0]) << 1) | u64(carry); | 200 | *@ptrCast(&du_int, &q[0]) = (*@ptrCast(&du_int, &q[0]) << 1) | u64(carry); |
| 201 | if (var rem ?= maybe_rem) { | 201 | if (var rem ?= maybe_rem) { |
| 202 | *rem = *@ptrcast(&du_int, &r[0]); | 202 | *rem = *@ptrCast(&du_int, &r[0]); |
| 203 | } | 203 | } |
| 204 | return *@ptrcast(&du_int, &q[0]); | 204 | return *@ptrCast(&du_int, &q[0]); |
| 205 | } | 205 | } |
| 206 | 206 | ||
| 207 | export fn __umoddi3(a: du_int, b: du_int) -> du_int { | 207 | export fn __umoddi3(a: du_int, b: du_int) -> du_int { |
test/cases/cast.zig+1-1| ... | @@ -16,7 +16,7 @@ test "numLitIntToPtrCast" { | ... | @@ -16,7 +16,7 @@ test "numLitIntToPtrCast" { |
| 16 | test "pointerReinterpretConstFloatToInt" { | 16 | test "pointerReinterpretConstFloatToInt" { |
| 17 | const float: f64 = 5.99999999999994648725e-01; | 17 | const float: f64 = 5.99999999999994648725e-01; |
| 18 | const float_ptr = &float; | 18 | const float_ptr = &float; |
| 19 | const int_ptr = @ptrcast(&i32, float_ptr); | 19 | const int_ptr = @ptrCast(&i32, float_ptr); |
| 20 | const int_val = *int_ptr; | 20 | const int_val = *int_ptr; |
| 21 | assert(int_val == 858993411); | 21 | assert(int_val == 858993411); |
| 22 | } | 22 | } |
test/cases/generics.zig+1-1| ... | @@ -121,5 +121,5 @@ test "genericFnWithImplicitCast" { | ... | @@ -121,5 +121,5 @@ test "genericFnWithImplicitCast" { |
| 121 | } | 121 | } |
| 122 | fn getByte(ptr: ?&const u8) -> u8 {*??ptr} | 122 | fn getByte(ptr: ?&const u8) -> u8 {*??ptr} |
| 123 | fn getFirstByte(comptime T: type, mem: []const T) -> u8 { | 123 | fn getFirstByte(comptime T: type, mem: []const T) -> u8 { |
| 124 | getByte(@ptrcast(&const u8, &mem[0])) | 124 | getByte(@ptrCast(&const u8, &mem[0])) |
| 125 | } | 125 | } |
test/cases/misc.zig+4-4| ... | @@ -246,15 +246,15 @@ test "typeEquality" { | ... | @@ -246,15 +246,15 @@ test "typeEquality" { |
| 246 | 246 | ||
| 247 | const global_a: i32 = 1234; | 247 | const global_a: i32 = 1234; |
| 248 | const global_b: &const i32 = &global_a; | 248 | const global_b: &const i32 = &global_a; |
| 249 | const global_c: &const f32 = @ptrcast(&const f32, global_b); | 249 | const global_c: &const f32 = @ptrCast(&const f32, global_b); |
| 250 | test "compileTimeGlobalReinterpret" { | 250 | test "compileTimeGlobalReinterpret" { |
| 251 | const d = @ptrcast(&const i32, global_c); | 251 | const d = @ptrCast(&const i32, global_c); |
| 252 | assert(*d == 1234); | 252 | assert(*d == 1234); |
| 253 | } | 253 | } |
| 254 | 254 | ||
| 255 | test "explicitCastMaybePointers" { | 255 | test "explicitCastMaybePointers" { |
| 256 | const a: ?&i32 = undefined; | 256 | const a: ?&i32 = undefined; |
| 257 | const b: ?&f32 = @ptrcast(?&f32, a); | 257 | const b: ?&f32 = @ptrCast(?&f32, a); |
| 258 | } | 258 | } |
| 259 | 259 | ||
| 260 | test "genericMallocFree" { | 260 | test "genericMallocFree" { |
| ... | @@ -263,7 +263,7 @@ test "genericMallocFree" { | ... | @@ -263,7 +263,7 @@ test "genericMallocFree" { |
| 263 | } | 263 | } |
| 264 | const some_mem : [100]u8 = undefined; | 264 | const some_mem : [100]u8 = undefined; |
| 265 | fn memAlloc(comptime T: type, n: usize) -> %[]T { | 265 | fn memAlloc(comptime T: type, n: usize) -> %[]T { |
| 266 | return @ptrcast(&T, &some_mem[0])[0...n]; | 266 | return @ptrCast(&T, &some_mem[0])[0...n]; |
| 267 | } | 267 | } |
| 268 | fn memFree(comptime T: type, memory: []T) { } | 268 | fn memFree(comptime T: type, memory: []T) { } |
| 269 | 269 |
test/cases/struct.zig+1-1| ... | @@ -41,7 +41,7 @@ const VoidStructFieldsFoo = struct { | ... | @@ -41,7 +41,7 @@ const VoidStructFieldsFoo = struct { |
| 41 | 41 | ||
| 42 | test "fn" { | 42 | test "fn" { |
| 43 | var foo: StructFoo = undefined; | 43 | var foo: StructFoo = undefined; |
| 44 | @memset(@ptrcast(&u8, &foo), 0, @sizeOf(StructFoo)); | 44 | @memset(@ptrCast(&u8, &foo), 0, @sizeOf(StructFoo)); |
| 45 | foo.a += 1; | 45 | foo.a += 1; |
| 46 | foo.b = foo.a == 1; | 46 | foo.b = foo.a == 1; |
| 47 | testFoo(foo); | 47 | testFoo(foo); |
test/compare_output.zig+3-3| ... | @@ -262,8 +262,8 @@ pub fn addCases(cases: &tests.CompareOutputContext) { | ... | @@ -262,8 +262,8 @@ pub fn addCases(cases: &tests.CompareOutputContext) { |
| 262 | \\const c = @cImport(@cInclude("stdlib.h")); | 262 | \\const c = @cImport(@cInclude("stdlib.h")); |
| 263 | \\ | 263 | \\ |
| 264 | \\export fn compare_fn(a: ?&const c_void, b: ?&const c_void) -> c_int { | 264 | \\export fn compare_fn(a: ?&const c_void, b: ?&const c_void) -> c_int { |
| 265 | \\ const a_int = @ptrcast(&i32, a ?? unreachable); | 265 | \\ const a_int = @ptrCast(&i32, a ?? unreachable); |
| 266 | \\ const b_int = @ptrcast(&i32, b ?? unreachable); | 266 | \\ const b_int = @ptrCast(&i32, b ?? unreachable); |
| 267 | \\ if (*a_int < *b_int) { | 267 | \\ if (*a_int < *b_int) { |
| 268 | \\ -1 | 268 | \\ -1 |
| 269 | \\ } else if (*a_int > *b_int) { | 269 | \\ } else if (*a_int > *b_int) { |
| ... | @@ -276,7 +276,7 @@ pub fn addCases(cases: &tests.CompareOutputContext) { | ... | @@ -276,7 +276,7 @@ pub fn addCases(cases: &tests.CompareOutputContext) { |
| 276 | \\export fn main() -> c_int { | 276 | \\export fn main() -> c_int { |
| 277 | \\ var array = []u32 { 1, 7, 3, 2, 0, 9, 4, 8, 6, 5 }; | 277 | \\ var array = []u32 { 1, 7, 3, 2, 0, 9, 4, 8, 6, 5 }; |
| 278 | \\ | 278 | \\ |
| 279 | \\ c.qsort(@ptrcast(&c_void, &array[0]), c_ulong(array.len), @sizeOf(i32), compare_fn); | 279 | \\ c.qsort(@ptrCast(&c_void, &array[0]), c_ulong(array.len), @sizeOf(i32), compare_fn); |
| 280 | \\ | 280 | \\ |
| 281 | \\ for (array) |item, i| { | 281 | \\ for (array) |item, i| { |
| 282 | \\ if (item != i) { | 282 | \\ if (item != i) { |
test/compile_errors.zig+1-1| ... | @@ -1475,7 +1475,7 @@ pub fn addCases(cases: &tests.CompileErrorContext) { | ... | @@ -1475,7 +1475,7 @@ pub fn addCases(cases: &tests.CompileErrorContext) { |
| 1475 | 1475 | ||
| 1476 | cases.add("ptrcast to non-pointer", | 1476 | cases.add("ptrcast to non-pointer", |
| 1477 | \\export fn entry(a: &i32) -> usize { | 1477 | \\export fn entry(a: &i32) -> usize { |
| 1478 | \\ return @ptrcast(usize, a); | 1478 | \\ return @ptrCast(usize, a); |
| 1479 | \\} | 1479 | \\} |
| 1480 | , ".tmp_source.zig:2:21: error: expected pointer, found 'usize'"); | 1480 | , ".tmp_source.zig:2:21: error: expected pointer, found 'usize'"); |
| 1481 | 1481 |