authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-01-15 17:53:05+00:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-01-16 12:46:29+00:00
logd00e05f18609921c1a051a637c24e47cfa304243
treeddeaafcc089671286dff4a7722667fb1e13dba53
parentaf6bad46cd132113e7b8497829a660a79e101742
signaturelock-open Commit is signed but in an unrecognized format.

all: update to `std.builtin.Type.Pointer.Size` field renames

This was done by regex substitution with `sed`. I then manually went over the entire diff and fixed any incorrect changes. This diff also changes a lot of `callconv(.C)` to `callconv(.c)`, since my regex happened to also trigger here. I opted to leave these changes in, since they *are* a correct migration, even if they're not the one I was trying to do!

74 files changed, 576 insertions(+), 581 deletions(-)

lib/std/Build/Step/ConfigHeader.zig+2-2
...@@ -144,13 +144,13 @@ fn putValue(config_header: *ConfigHeader, field_name: []const u8, comptime T: ty...@@ -144,13 +144,13 @@ fn putValue(config_header: *ConfigHeader, field_name: []const u8, comptime T: ty
144 .pointer => |ptr| {144 .pointer => |ptr| {
145 switch (@typeInfo(ptr.child)) {145 switch (@typeInfo(ptr.child)) {
146 .array => |array| {146 .array => |array| {
147 if (ptr.size == .One and array.child == u8) {147 if (ptr.size == .one and array.child == u8) {
148 try config_header.values.put(field_name, .{ .string = v });148 try config_header.values.put(field_name, .{ .string = v });
149 return;149 return;
150 }150 }
151 },151 },
152 .int => {152 .int => {
153 if (ptr.size == .Slice and ptr.child == u8) {153 if (ptr.size == .slice and ptr.child == u8) {
154 try config_header.values.put(field_name, .{ .string = v });154 try config_header.values.put(field_name, .{ .string = v });
155 return;155 return;
156 }156 }
lib/std/Build/Step/Options.zig+1-1
...@@ -172,7 +172,7 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent...@@ -172,7 +172,7 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent
172 return;172 return;
173 },173 },
174 .pointer => |p| {174 .pointer => |p| {
175 if (p.size != .Slice) {175 if (p.size != .slice) {
176 @compileError("Non-slice pointers are not yet supported in build options");176 @compileError("Non-slice pointers are not yet supported in build options");
177 }177 }
178178
lib/std/Progress.zig+1-1
...@@ -1366,7 +1366,7 @@ fn maybeUpdateSize(resize_flag: bool) void {...@@ -1366,7 +1366,7 @@ fn maybeUpdateSize(resize_flag: bool) void {
1366 }1366 }
1367}1367}
13681368
1369fn handleSigWinch(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.C) void {1369fn handleSigWinch(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.c) void {
1370 _ = info;1370 _ = info;
1371 _ = ctx_ptr;1371 _ = ctx_ptr;
1372 assert(sig == posix.SIG.WINCH);1372 assert(sig == posix.SIG.WINCH);
lib/std/Random.zig+1-1
...@@ -35,7 +35,7 @@ fillFn: *const fn (ptr: *anyopaque, buf: []u8) void,...@@ -35,7 +35,7 @@ fillFn: *const fn (ptr: *anyopaque, buf: []u8) void,
35pub fn init(pointer: anytype, comptime fillFn: fn (ptr: @TypeOf(pointer), buf: []u8) void) Random {35pub fn init(pointer: anytype, comptime fillFn: fn (ptr: @TypeOf(pointer), buf: []u8) void) Random {
36 const Ptr = @TypeOf(pointer);36 const Ptr = @TypeOf(pointer);
37 assert(@typeInfo(Ptr) == .pointer); // Must be a pointer37 assert(@typeInfo(Ptr) == .pointer); // Must be a pointer
38 assert(@typeInfo(Ptr).pointer.size == .One); // Must be a single-item pointer38 assert(@typeInfo(Ptr).pointer.size == .one); // Must be a single-item pointer
39 assert(@typeInfo(@typeInfo(Ptr).pointer.child) == .@"struct"); // Must point to a struct39 assert(@typeInfo(@typeInfo(Ptr).pointer.child) == .@"struct"); // Must point to a struct
40 const gen = struct {40 const gen = struct {
41 fn fill(ptr: *anyopaque, buf: []u8) void {41 fn fill(ptr: *anyopaque, buf: []u8) void {
lib/std/c.zig+31-31
...@@ -2733,8 +2733,8 @@ pub const Sigaction = switch (native_os) {...@@ -2733,8 +2733,8 @@ pub const Sigaction = switch (native_os) {
2733 => if (builtin.target.isMusl())2733 => if (builtin.target.isMusl())
2734 linux.Sigaction2734 linux.Sigaction
2735 else if (builtin.target.ptrBitWidth() == 64) extern struct {2735 else if (builtin.target.ptrBitWidth() == 64) extern struct {
2736 pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;2736 pub const handler_fn = *align(1) const fn (i32) callconv(.c) void;
2737 pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;2737 pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
27382738
2739 flags: c_uint,2739 flags: c_uint,
2740 handler: extern union {2740 handler: extern union {
...@@ -2742,10 +2742,10 @@ pub const Sigaction = switch (native_os) {...@@ -2742,10 +2742,10 @@ pub const Sigaction = switch (native_os) {
2742 sigaction: ?sigaction_fn,2742 sigaction: ?sigaction_fn,
2743 },2743 },
2744 mask: sigset_t,2744 mask: sigset_t,
2745 restorer: ?*const fn () callconv(.C) void = null,2745 restorer: ?*const fn () callconv(.c) void = null,
2746 } else extern struct {2746 } else extern struct {
2747 pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;2747 pub const handler_fn = *align(1) const fn (i32) callconv(.c) void;
2748 pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;2748 pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
27492749
2750 flags: c_uint,2750 flags: c_uint,
2751 handler: extern union {2751 handler: extern union {
...@@ -2753,12 +2753,12 @@ pub const Sigaction = switch (native_os) {...@@ -2753,12 +2753,12 @@ pub const Sigaction = switch (native_os) {
2753 sigaction: ?sigaction_fn,2753 sigaction: ?sigaction_fn,
2754 },2754 },
2755 mask: sigset_t,2755 mask: sigset_t,
2756 restorer: ?*const fn () callconv(.C) void = null,2756 restorer: ?*const fn () callconv(.c) void = null,
2757 __resv: [1]c_int = .{0},2757 __resv: [1]c_int = .{0},
2758 },2758 },
2759 .s390x => if (builtin.abi == .gnu) extern struct {2759 .s390x => if (builtin.abi == .gnu) extern struct {
2760 pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;2760 pub const handler_fn = *align(1) const fn (i32) callconv(.c) void;
2761 pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;2761 pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
27622762
2763 handler: extern union {2763 handler: extern union {
2764 handler: ?handler_fn,2764 handler: ?handler_fn,
...@@ -2766,15 +2766,15 @@ pub const Sigaction = switch (native_os) {...@@ -2766,15 +2766,15 @@ pub const Sigaction = switch (native_os) {
2766 },2766 },
2767 __glibc_reserved0: c_int = 0,2767 __glibc_reserved0: c_int = 0,
2768 flags: c_uint,2768 flags: c_uint,
2769 restorer: ?*const fn () callconv(.C) void = null,2769 restorer: ?*const fn () callconv(.c) void = null,
2770 mask: sigset_t,2770 mask: sigset_t,
2771 } else linux.Sigaction,2771 } else linux.Sigaction,
2772 else => linux.Sigaction,2772 else => linux.Sigaction,
2773 },2773 },
2774 .emscripten => emscripten.Sigaction,2774 .emscripten => emscripten.Sigaction,
2775 .netbsd, .macos, .ios, .tvos, .watchos, .visionos => extern struct {2775 .netbsd, .macos, .ios, .tvos, .watchos, .visionos => extern struct {
2776 pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;2776 pub const handler_fn = *align(1) const fn (i32) callconv(.c) void;
2777 pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;2777 pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
27782778
2779 handler: extern union {2779 handler: extern union {
2780 handler: ?handler_fn,2780 handler: ?handler_fn,
...@@ -2784,8 +2784,8 @@ pub const Sigaction = switch (native_os) {...@@ -2784,8 +2784,8 @@ pub const Sigaction = switch (native_os) {
2784 flags: c_uint,2784 flags: c_uint,
2785 },2785 },
2786 .dragonfly, .freebsd => extern struct {2786 .dragonfly, .freebsd => extern struct {
2787 pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;2787 pub const handler_fn = *align(1) const fn (i32) callconv(.c) void;
2788 pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;2788 pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
27892789
2790 /// signal handler2790 /// signal handler
2791 handler: extern union {2791 handler: extern union {
...@@ -2798,8 +2798,8 @@ pub const Sigaction = switch (native_os) {...@@ -2798,8 +2798,8 @@ pub const Sigaction = switch (native_os) {
2798 mask: sigset_t,2798 mask: sigset_t,
2799 },2799 },
2800 .solaris, .illumos => extern struct {2800 .solaris, .illumos => extern struct {
2801 pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;2801 pub const handler_fn = *align(1) const fn (i32) callconv(.c) void;
2802 pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;2802 pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
28032803
2804 /// signal options2804 /// signal options
2805 flags: c_uint,2805 flags: c_uint,
...@@ -2812,8 +2812,8 @@ pub const Sigaction = switch (native_os) {...@@ -2812,8 +2812,8 @@ pub const Sigaction = switch (native_os) {
2812 mask: sigset_t,2812 mask: sigset_t,
2813 },2813 },
2814 .haiku => extern struct {2814 .haiku => extern struct {
2815 pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;2815 pub const handler_fn = *align(1) const fn (i32) callconv(.c) void;
2816 pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;2816 pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
28172817
2818 /// signal handler2818 /// signal handler
2819 handler: extern union {2819 handler: extern union {
...@@ -2831,8 +2831,8 @@ pub const Sigaction = switch (native_os) {...@@ -2831,8 +2831,8 @@ pub const Sigaction = switch (native_os) {
2831 userdata: *allowzero anyopaque = undefined,2831 userdata: *allowzero anyopaque = undefined,
2832 },2832 },
2833 .openbsd => extern struct {2833 .openbsd => extern struct {
2834 pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;2834 pub const handler_fn = *align(1) const fn (i32) callconv(.c) void;
2835 pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;2835 pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
28362836
2837 /// signal handler2837 /// signal handler
2838 handler: extern union {2838 handler: extern union {
...@@ -6410,7 +6410,7 @@ pub const EAI = switch (native_os) {...@@ -6410,7 +6410,7 @@ pub const EAI = switch (native_os) {
6410 else => void,6410 else => void,
6411};6411};
64126412
6413pub const dl_iterate_phdr_callback = *const fn (info: *dl_phdr_info, size: usize, data: ?*anyopaque) callconv(.C) c_int;6413pub const dl_iterate_phdr_callback = *const fn (info: *dl_phdr_info, size: usize, data: ?*anyopaque) callconv(.c) c_int;
64146414
6415pub const Stat = switch (native_os) {6415pub const Stat = switch (native_os) {
6416 .linux => switch (native_arch) {6416 .linux => switch (native_arch) {
...@@ -9396,7 +9396,7 @@ pub extern "c" fn futimens(fd: fd_t, times: *const [2]timespec) c_int;...@@ -9396,7 +9396,7 @@ pub extern "c" fn futimens(fd: fd_t, times: *const [2]timespec) c_int;
9396pub extern "c" fn pthread_create(9396pub extern "c" fn pthread_create(
9397 noalias newthread: *pthread_t,9397 noalias newthread: *pthread_t,
9398 noalias attr: ?*const pthread_attr_t,9398 noalias attr: ?*const pthread_attr_t,
9399 start_routine: *const fn (?*anyopaque) callconv(.C) ?*anyopaque,9399 start_routine: *const fn (?*anyopaque) callconv(.c) ?*anyopaque,
9400 noalias arg: ?*anyopaque,9400 noalias arg: ?*anyopaque,
9401) E;9401) E;
9402pub extern "c" fn pthread_attr_init(attr: *pthread_attr_t) E;9402pub extern "c" fn pthread_attr_init(attr: *pthread_attr_t) E;
...@@ -9408,13 +9408,13 @@ pub extern "c" fn pthread_self() pthread_t;...@@ -9408,13 +9408,13 @@ pub extern "c" fn pthread_self() pthread_t;
9408pub extern "c" fn pthread_join(thread: pthread_t, arg_return: ?*?*anyopaque) E;9408pub extern "c" fn pthread_join(thread: pthread_t, arg_return: ?*?*anyopaque) E;
9409pub extern "c" fn pthread_detach(thread: pthread_t) E;9409pub extern "c" fn pthread_detach(thread: pthread_t) E;
9410pub extern "c" fn pthread_atfork(9410pub extern "c" fn pthread_atfork(
9411 prepare: ?*const fn () callconv(.C) void,9411 prepare: ?*const fn () callconv(.c) void,
9412 parent: ?*const fn () callconv(.C) void,9412 parent: ?*const fn () callconv(.c) void,
9413 child: ?*const fn () callconv(.C) void,9413 child: ?*const fn () callconv(.c) void,
9414) c_int;9414) c_int;
9415pub extern "c" fn pthread_key_create(9415pub extern "c" fn pthread_key_create(
9416 key: *pthread_key_t,9416 key: *pthread_key_t,
9417 destructor: ?*const fn (value: *anyopaque) callconv(.C) void,9417 destructor: ?*const fn (value: *anyopaque) callconv(.c) void,
9418) E;9418) E;
9419pub extern "c" fn pthread_key_delete(key: pthread_key_t) E;9419pub extern "c" fn pthread_key_delete(key: pthread_key_t) E;
9420pub extern "c" fn pthread_getspecific(key: pthread_key_t) ?*anyopaque;9420pub extern "c" fn pthread_getspecific(key: pthread_key_t) ?*anyopaque;
...@@ -9530,12 +9530,12 @@ pub extern "c" fn pthread_cond_signal(cond: *pthread_cond_t) E;...@@ -9530,12 +9530,12 @@ pub extern "c" fn pthread_cond_signal(cond: *pthread_cond_t) E;
9530pub extern "c" fn pthread_cond_broadcast(cond: *pthread_cond_t) E;9530pub extern "c" fn pthread_cond_broadcast(cond: *pthread_cond_t) E;
9531pub extern "c" fn pthread_cond_destroy(cond: *pthread_cond_t) E;9531pub extern "c" fn pthread_cond_destroy(cond: *pthread_cond_t) E;
95329532
9533pub extern "c" fn pthread_rwlock_destroy(rwl: *pthread_rwlock_t) callconv(.C) E;9533pub extern "c" fn pthread_rwlock_destroy(rwl: *pthread_rwlock_t) callconv(.c) E;
9534pub extern "c" fn pthread_rwlock_rdlock(rwl: *pthread_rwlock_t) callconv(.C) E;9534pub extern "c" fn pthread_rwlock_rdlock(rwl: *pthread_rwlock_t) callconv(.c) E;
9535pub extern "c" fn pthread_rwlock_wrlock(rwl: *pthread_rwlock_t) callconv(.C) E;9535pub extern "c" fn pthread_rwlock_wrlock(rwl: *pthread_rwlock_t) callconv(.c) E;
9536pub extern "c" fn pthread_rwlock_tryrdlock(rwl: *pthread_rwlock_t) callconv(.C) E;9536pub extern "c" fn pthread_rwlock_tryrdlock(rwl: *pthread_rwlock_t) callconv(.c) E;
9537pub extern "c" fn pthread_rwlock_trywrlock(rwl: *pthread_rwlock_t) callconv(.C) E;9537pub extern "c" fn pthread_rwlock_trywrlock(rwl: *pthread_rwlock_t) callconv(.c) E;
9538pub extern "c" fn pthread_rwlock_unlock(rwl: *pthread_rwlock_t) callconv(.C) E;9538pub extern "c" fn pthread_rwlock_unlock(rwl: *pthread_rwlock_t) callconv(.c) E;
95399539
9540pub const pthread_t = *opaque {};9540pub const pthread_t = *opaque {};
9541pub const FILE = opaque {};9541pub const FILE = opaque {};
lib/std/c/darwin.zig+2-2
...@@ -379,7 +379,7 @@ pub const MACH_MSG_TYPE = enum(mach_msg_type_name_t) {...@@ -379,7 +379,7 @@ pub const MACH_MSG_TYPE = enum(mach_msg_type_name_t) {
379};379};
380380
381extern "c" var mach_task_self_: mach_port_t;381extern "c" var mach_task_self_: mach_port_t;
382pub fn mach_task_self() callconv(.C) mach_port_t {382pub fn mach_task_self() callconv(.c) mach_port_t {
383 return mach_task_self_;383 return mach_task_self_;
384}384}
385385
...@@ -873,7 +873,7 @@ pub const DISPATCH_TIME_FOREVER = ~@as(dispatch_time_t, 0);...@@ -873,7 +873,7 @@ pub const DISPATCH_TIME_FOREVER = ~@as(dispatch_time_t, 0);
873pub extern "c" fn dispatch_time(when: dispatch_time_t, delta: i64) dispatch_time_t;873pub extern "c" fn dispatch_time(when: dispatch_time_t, delta: i64) dispatch_time_t;
874874
875const dispatch_once_t = usize;875const dispatch_once_t = usize;
876const dispatch_function_t = fn (?*anyopaque) callconv(.C) void;876const dispatch_function_t = fn (?*anyopaque) callconv(.c) void;
877pub extern fn dispatch_once_f(877pub extern fn dispatch_once_f(
878 predicate: *dispatch_once_t,878 predicate: *dispatch_once_t,
879 context: ?*anyopaque,879 context: ?*anyopaque,
lib/std/c/dragonfly.zig+1-1
...@@ -156,7 +156,7 @@ pub const E = enum(u16) {...@@ -156,7 +156,7 @@ pub const E = enum(u16) {
156156
157pub const BADSIG = SIG.ERR;157pub const BADSIG = SIG.ERR;
158158
159pub const sig_t = *const fn (i32) callconv(.C) void;159pub const sig_t = *const fn (i32) callconv(.c) void;
160160
161pub const cmsghdr = extern struct {161pub const cmsghdr = extern struct {
162 len: socklen_t,162 len: socklen_t,
lib/std/crypto/tlcsprng.zig+1-1
...@@ -133,7 +133,7 @@ fn setupPthreadAtforkAndFill(buffer: []u8) void {...@@ -133,7 +133,7 @@ fn setupPthreadAtforkAndFill(buffer: []u8) void {
133 return initAndFill(buffer);133 return initAndFill(buffer);
134}134}
135135
136fn childAtForkHandler() callconv(.C) void {136fn childAtForkHandler() callconv(.c) void {
137 // The atfork handler is global, this function may be called after137 // The atfork handler is global, this function may be called after
138 // fork()-ing threads that never initialized the CSPRNG context.138 // fork()-ing threads that never initialized the CSPRNG context.
139 if (wipe_mem.len == 0) return;139 if (wipe_mem.len == 0) return;
lib/std/debug.zig+1-1
...@@ -1269,7 +1269,7 @@ fn resetSegfaultHandler() void {...@@ -1269,7 +1269,7 @@ fn resetSegfaultHandler() void {
1269 updateSegfaultHandler(&act);1269 updateSegfaultHandler(&act);
1270}1270}
12711271
1272fn handleSegfaultPosix(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.C) noreturn {1272fn handleSegfaultPosix(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.c) noreturn {
1273 // Reset to the default handler so that if a segfault happens in this handler it will crash1273 // Reset to the default handler so that if a segfault happens in this handler it will crash
1274 // the process. Also when this handler returns, the original instruction will be repeated1274 // the process. Also when this handler returns, the original instruction will be repeated
1275 // and the resulting segfault will crash the process rather than continually dump stack traces.1275 // and the resulting segfault will crash the process rather than continually dump stack traces.
lib/std/fmt.zig+7-7
...@@ -434,7 +434,7 @@ pub fn formatAddress(value: anytype, options: FormatOptions, writer: anytype) @T...@@ -434,7 +434,7 @@ pub fn formatAddress(value: anytype, options: FormatOptions, writer: anytype) @T
434 switch (@typeInfo(T)) {434 switch (@typeInfo(T)) {
435 .pointer => |info| {435 .pointer => |info| {
436 try writer.writeAll(@typeName(info.child) ++ "@");436 try writer.writeAll(@typeName(info.child) ++ "@");
437 if (info.size == .Slice)437 if (info.size == .slice)
438 try formatInt(@intFromPtr(value.ptr), 16, .lower, FormatOptions{}, writer)438 try formatInt(@intFromPtr(value.ptr), 16, .lower, FormatOptions{}, writer)
439 else439 else
440 try formatInt(@intFromPtr(value), 16, .lower, FormatOptions{}, writer);440 try formatInt(@intFromPtr(value), 16, .lower, FormatOptions{}, writer);
...@@ -460,12 +460,12 @@ pub fn defaultSpec(comptime T: type) [:0]const u8 {...@@ -460,12 +460,12 @@ pub fn defaultSpec(comptime T: type) [:0]const u8 {
460 switch (@typeInfo(T)) {460 switch (@typeInfo(T)) {
461 .array, .vector => return ANY,461 .array, .vector => return ANY,
462 .pointer => |ptr_info| switch (ptr_info.size) {462 .pointer => |ptr_info| switch (ptr_info.size) {
463 .One => switch (@typeInfo(ptr_info.child)) {463 .one => switch (@typeInfo(ptr_info.child)) {
464 .array => return ANY,464 .array => return ANY,
465 else => {},465 else => {},
466 },466 },
467 .Many, .C => return "*",467 .many, .c => return "*",
468 .Slice => return ANY,468 .slice => return ANY,
469 },469 },
470 .optional => |info| return "?" ++ defaultSpec(info.child),470 .optional => |info| return "?" ++ defaultSpec(info.child),
471 .error_union => |info| return "!" ++ defaultSpec(info.payload),471 .error_union => |info| return "!" ++ defaultSpec(info.payload),
...@@ -624,13 +624,13 @@ pub fn formatType(...@@ -624,13 +624,13 @@ pub fn formatType(
624 try writer.writeAll(" }");624 try writer.writeAll(" }");
625 },625 },
626 .pointer => |ptr_info| switch (ptr_info.size) {626 .pointer => |ptr_info| switch (ptr_info.size) {
627 .One => switch (@typeInfo(ptr_info.child)) {627 .one => switch (@typeInfo(ptr_info.child)) {
628 .array, .@"enum", .@"union", .@"struct" => {628 .array, .@"enum", .@"union", .@"struct" => {
629 return formatType(value.*, actual_fmt, options, writer, max_depth);629 return formatType(value.*, actual_fmt, options, writer, max_depth);
630 },630 },
631 else => return format(writer, "{s}@{x}", .{ @typeName(ptr_info.child), @intFromPtr(value) }),631 else => return format(writer, "{s}@{x}", .{ @typeName(ptr_info.child), @intFromPtr(value) }),
632 },632 },
633 .Many, .C => {633 .many, .c => {
634 if (actual_fmt.len == 0)634 if (actual_fmt.len == 0)
635 @compileError("cannot format pointer without a specifier (i.e. {s} or {*})");635 @compileError("cannot format pointer without a specifier (i.e. {s} or {*})");
636 if (ptr_info.sentinel) |_| {636 if (ptr_info.sentinel) |_| {
...@@ -641,7 +641,7 @@ pub fn formatType(...@@ -641,7 +641,7 @@ pub fn formatType(
641 }641 }
642 invalidFmtError(fmt, value);642 invalidFmtError(fmt, value);
643 },643 },
644 .Slice => {644 .slice => {
645 if (actual_fmt.len == 0)645 if (actual_fmt.len == 0)
646 @compileError("cannot format slice without a specifier (i.e. {s} or {any})");646 @compileError("cannot format slice without a specifier (i.e. {s} or {any})");
647 if (max_depth == 0) {647 if (max_depth == 0) {
lib/std/hash/auto_hash.zig+5-5
...@@ -23,13 +23,13 @@ pub fn hashPointer(hasher: anytype, key: anytype, comptime strat: HashStrategy)...@@ -23,13 +23,13 @@ pub fn hashPointer(hasher: anytype, key: anytype, comptime strat: HashStrategy)
23 const info = @typeInfo(@TypeOf(key));23 const info = @typeInfo(@TypeOf(key));
2424
25 switch (info.pointer.size) {25 switch (info.pointer.size) {
26 .One => switch (strat) {26 .one => switch (strat) {
27 .Shallow => hash(hasher, @intFromPtr(key), .Shallow),27 .Shallow => hash(hasher, @intFromPtr(key), .Shallow),
28 .Deep => hash(hasher, key.*, .Shallow),28 .Deep => hash(hasher, key.*, .Shallow),
29 .DeepRecursive => hash(hasher, key.*, .DeepRecursive),29 .DeepRecursive => hash(hasher, key.*, .DeepRecursive),
30 },30 },
3131
32 .Slice => {32 .slice => {
33 switch (strat) {33 switch (strat) {
34 .Shallow => {34 .Shallow => {
35 hashPointer(hasher, key.ptr, .Shallow);35 hashPointer(hasher, key.ptr, .Shallow);
...@@ -40,8 +40,8 @@ pub fn hashPointer(hasher: anytype, key: anytype, comptime strat: HashStrategy)...@@ -40,8 +40,8 @@ pub fn hashPointer(hasher: anytype, key: anytype, comptime strat: HashStrategy)
40 hash(hasher, key.len, .Shallow);40 hash(hasher, key.len, .Shallow);
41 },41 },
4242
43 .Many,43 .many,
44 .C,44 .c,
45 => switch (strat) {45 => switch (strat) {
46 .Shallow => hash(hasher, @intFromPtr(key), .Shallow),46 .Shallow => hash(hasher, @intFromPtr(key), .Shallow),
47 else => @compileError(47 else => @compileError(
...@@ -167,7 +167,7 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {...@@ -167,7 +167,7 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {
167167
168inline fn typeContainsSlice(comptime K: type) bool {168inline fn typeContainsSlice(comptime K: type) bool {
169 return switch (@typeInfo(K)) {169 return switch (@typeInfo(K)) {
170 .pointer => |info| info.size == .Slice,170 .pointer => |info| info.size == .slice,
171171
172 inline .@"struct", .@"union" => |info| {172 inline .@"struct", .@"union" => |info| {
173 inline for (info.fields) |field| {173 inline for (info.fields) |field| {
lib/std/io/fixed_buffer_stream.zig+3-3
...@@ -118,14 +118,14 @@ fn Slice(comptime T: type) type {...@@ -118,14 +118,14 @@ fn Slice(comptime T: type) type {
118 .pointer => |ptr_info| {118 .pointer => |ptr_info| {
119 var new_ptr_info = ptr_info;119 var new_ptr_info = ptr_info;
120 switch (ptr_info.size) {120 switch (ptr_info.size) {
121 .Slice => {},121 .slice => {},
122 .One => switch (@typeInfo(ptr_info.child)) {122 .one => switch (@typeInfo(ptr_info.child)) {
123 .array => |info| new_ptr_info.child = info.child,123 .array => |info| new_ptr_info.child = info.child,
124 else => @compileError("invalid type given to fixedBufferStream"),124 else => @compileError("invalid type given to fixedBufferStream"),
125 },125 },
126 else => @compileError("invalid type given to fixedBufferStream"),126 else => @compileError("invalid type given to fixedBufferStream"),
127 }127 }
128 new_ptr_info.size = .Slice;128 new_ptr_info.size = .slice;
129 return @Type(.{ .pointer = new_ptr_info });129 return @Type(.{ .pointer = new_ptr_info });
130 },130 },
131 else => @compileError("invalid type given to fixedBufferStream"),131 else => @compileError("invalid type given to fixedBufferStream"),
lib/std/json/static.zig+4-4
...@@ -451,12 +451,12 @@ pub fn innerParse(...@@ -451,12 +451,12 @@ pub fn innerParse(
451451
452 .pointer => |ptrInfo| {452 .pointer => |ptrInfo| {
453 switch (ptrInfo.size) {453 switch (ptrInfo.size) {
454 .One => {454 .one => {
455 const r: *ptrInfo.child = try allocator.create(ptrInfo.child);455 const r: *ptrInfo.child = try allocator.create(ptrInfo.child);
456 r.* = try innerParse(ptrInfo.child, allocator, source, options);456 r.* = try innerParse(ptrInfo.child, allocator, source, options);
457 return r;457 return r;
458 },458 },
459 .Slice => {459 .slice => {
460 switch (try source.peekNextTokenType()) {460 switch (try source.peekNextTokenType()) {
461 .array_begin => {461 .array_begin => {
462 _ = try source.next();462 _ = try source.next();
...@@ -706,12 +706,12 @@ pub fn innerParseFromValue(...@@ -706,12 +706,12 @@ pub fn innerParseFromValue(
706706
707 .pointer => |ptrInfo| {707 .pointer => |ptrInfo| {
708 switch (ptrInfo.size) {708 switch (ptrInfo.size) {
709 .One => {709 .one => {
710 const r: *ptrInfo.child = try allocator.create(ptrInfo.child);710 const r: *ptrInfo.child = try allocator.create(ptrInfo.child);
711 r.* = try innerParseFromValue(ptrInfo.child, allocator, source, options);711 r.* = try innerParseFromValue(ptrInfo.child, allocator, source, options);
712 return r;712 return r;
713 },713 },
714 .Slice => {714 .slice => {
715 switch (source) {715 switch (source) {
716 .array => |array| {716 .array => |array| {
717 const r = if (ptrInfo.sentinel) |sentinel_ptr|717 const r = if (ptrInfo.sentinel) |sentinel_ptr|
lib/std/json/stringify.zig+4-4
...@@ -631,7 +631,7 @@ pub fn WriteStream(...@@ -631,7 +631,7 @@ pub fn WriteStream(
631 },631 },
632 .error_set => return self.stringValue(@errorName(value)),632 .error_set => return self.stringValue(@errorName(value)),
633 .pointer => |ptr_info| switch (ptr_info.size) {633 .pointer => |ptr_info| switch (ptr_info.size) {
634 .One => switch (@typeInfo(ptr_info.child)) {634 .one => switch (@typeInfo(ptr_info.child)) {
635 .array => {635 .array => {
636 // Coerce `*[N]T` to `[]const T`.636 // Coerce `*[N]T` to `[]const T`.
637 const Slice = []const std.meta.Elem(ptr_info.child);637 const Slice = []const std.meta.Elem(ptr_info.child);
...@@ -641,10 +641,10 @@ pub fn WriteStream(...@@ -641,10 +641,10 @@ pub fn WriteStream(
641 return self.write(value.*);641 return self.write(value.*);
642 },642 },
643 },643 },
644 .Many, .Slice => {644 .many, .slice => {
645 if (ptr_info.size == .Many and ptr_info.sentinel == null)645 if (ptr_info.size == .many and ptr_info.sentinel == null)
646 @compileError("unable to stringify type '" ++ @typeName(T) ++ "' without sentinel");646 @compileError("unable to stringify type '" ++ @typeName(T) ++ "' without sentinel");
647 const slice = if (ptr_info.size == .Many) std.mem.span(value) else value;647 const slice = if (ptr_info.size == .many) std.mem.span(value) else value;
648648
649 if (ptr_info.child == u8) {649 if (ptr_info.child == u8) {
650 // This is a []const u8, or some similar Zig string.650 // This is a []const u8, or some similar Zig string.
lib/std/mem.zig+31-31
...@@ -262,7 +262,7 @@ pub fn zeroes(comptime T: type) T {...@@ -262,7 +262,7 @@ pub fn zeroes(comptime T: type) T {
262 },262 },
263 .pointer => |ptr_info| {263 .pointer => |ptr_info| {
264 switch (ptr_info.size) {264 switch (ptr_info.size) {
265 .Slice => {265 .slice => {
266 if (ptr_info.sentinel) |sentinel| {266 if (ptr_info.sentinel) |sentinel| {
267 if (ptr_info.child == u8 and @as(*const u8, @ptrCast(sentinel)).* == 0) {267 if (ptr_info.child == u8 and @as(*const u8, @ptrCast(sentinel)).* == 0) {
268 return ""; // A special case for the most common use-case: null-terminated strings.268 return ""; // A special case for the most common use-case: null-terminated strings.
...@@ -272,10 +272,10 @@ pub fn zeroes(comptime T: type) T {...@@ -272,10 +272,10 @@ pub fn zeroes(comptime T: type) T {
272 return &[_]ptr_info.child{};272 return &[_]ptr_info.child{};
273 }273 }
274 },274 },
275 .C => {275 .c => {
276 return null;276 return null;
277 },277 },
278 .One, .Many => {278 .one, .many => {
279 if (ptr_info.is_allowzero) return @ptrFromInt(0);279 if (ptr_info.is_allowzero) return @ptrFromInt(0);
280 @compileError("Only nullable and allowzero pointers can be set to zero.");280 @compileError("Only nullable and allowzero pointers can be set to zero.");
281 },281 },
...@@ -781,14 +781,14 @@ fn Span(comptime T: type) type {...@@ -781,14 +781,14 @@ fn Span(comptime T: type) type {
781 .pointer => |ptr_info| {781 .pointer => |ptr_info| {
782 var new_ptr_info = ptr_info;782 var new_ptr_info = ptr_info;
783 switch (ptr_info.size) {783 switch (ptr_info.size) {
784 .C => {784 .c => {
785 new_ptr_info.sentinel = &@as(ptr_info.child, 0);785 new_ptr_info.sentinel = &@as(ptr_info.child, 0);
786 new_ptr_info.is_allowzero = false;786 new_ptr_info.is_allowzero = false;
787 },787 },
788 .Many => if (ptr_info.sentinel == null) @compileError("invalid type given to std.mem.span: " ++ @typeName(T)),788 .many => if (ptr_info.sentinel == null) @compileError("invalid type given to std.mem.span: " ++ @typeName(T)),
789 .One, .Slice => @compileError("invalid type given to std.mem.span: " ++ @typeName(T)),789 .one, .slice => @compileError("invalid type given to std.mem.span: " ++ @typeName(T)),
790 }790 }
791 new_ptr_info.size = .Slice;791 new_ptr_info.size = .slice;
792 return @Type(.{ .pointer = new_ptr_info });792 return @Type(.{ .pointer = new_ptr_info });
793 },793 },
794 else => {},794 else => {},
...@@ -845,9 +845,9 @@ fn SliceTo(comptime T: type, comptime end: std.meta.Elem(T)) type {...@@ -845,9 +845,9 @@ fn SliceTo(comptime T: type, comptime end: std.meta.Elem(T)) type {
845 },845 },
846 .pointer => |ptr_info| {846 .pointer => |ptr_info| {
847 var new_ptr_info = ptr_info;847 var new_ptr_info = ptr_info;
848 new_ptr_info.size = .Slice;848 new_ptr_info.size = .slice;
849 switch (ptr_info.size) {849 switch (ptr_info.size) {
850 .One => switch (@typeInfo(ptr_info.child)) {850 .one => switch (@typeInfo(ptr_info.child)) {
851 .array => |array_info| {851 .array => |array_info| {
852 new_ptr_info.child = array_info.child;852 new_ptr_info.child = array_info.child;
853 // The return type must only be sentinel terminated if we are guaranteed853 // The return type must only be sentinel terminated if we are guaranteed
...@@ -864,7 +864,7 @@ fn SliceTo(comptime T: type, comptime end: std.meta.Elem(T)) type {...@@ -864,7 +864,7 @@ fn SliceTo(comptime T: type, comptime end: std.meta.Elem(T)) type {
864 },864 },
865 else => {},865 else => {},
866 },866 },
867 .Many, .Slice => {867 .many, .slice => {
868 // The return type must only be sentinel terminated if we are guaranteed868 // The return type must only be sentinel terminated if we are guaranteed
869 // to find the value searched for, which is only the case if it matches869 // to find the value searched for, which is only the case if it matches
870 // the sentinel of the type passed.870 // the sentinel of the type passed.
...@@ -877,7 +877,7 @@ fn SliceTo(comptime T: type, comptime end: std.meta.Elem(T)) type {...@@ -877,7 +877,7 @@ fn SliceTo(comptime T: type, comptime end: std.meta.Elem(T)) type {
877 }877 }
878 }878 }
879 },879 },
880 .C => {880 .c => {
881 new_ptr_info.sentinel = &end;881 new_ptr_info.sentinel = &end;
882 // C pointers are always allowzero, but we don't want the return type to be.882 // C pointers are always allowzero, but we don't want the return type to be.
883 assert(new_ptr_info.is_allowzero);883 assert(new_ptr_info.is_allowzero);
...@@ -957,7 +957,7 @@ test sliceTo {...@@ -957,7 +957,7 @@ test sliceTo {
957fn lenSliceTo(ptr: anytype, comptime end: std.meta.Elem(@TypeOf(ptr))) usize {957fn lenSliceTo(ptr: anytype, comptime end: std.meta.Elem(@TypeOf(ptr))) usize {
958 switch (@typeInfo(@TypeOf(ptr))) {958 switch (@typeInfo(@TypeOf(ptr))) {
959 .pointer => |ptr_info| switch (ptr_info.size) {959 .pointer => |ptr_info| switch (ptr_info.size) {
960 .One => switch (@typeInfo(ptr_info.child)) {960 .one => switch (@typeInfo(ptr_info.child)) {
961 .array => |array_info| {961 .array => |array_info| {
962 if (array_info.sentinel) |sentinel_ptr| {962 if (array_info.sentinel) |sentinel_ptr| {
963 const sentinel = @as(*align(1) const array_info.child, @ptrCast(sentinel_ptr)).*;963 const sentinel = @as(*align(1) const array_info.child, @ptrCast(sentinel_ptr)).*;
...@@ -969,7 +969,7 @@ fn lenSliceTo(ptr: anytype, comptime end: std.meta.Elem(@TypeOf(ptr))) usize {...@@ -969,7 +969,7 @@ fn lenSliceTo(ptr: anytype, comptime end: std.meta.Elem(@TypeOf(ptr))) usize {
969 },969 },
970 else => {},970 else => {},
971 },971 },
972 .Many => if (ptr_info.sentinel) |sentinel_ptr| {972 .many => if (ptr_info.sentinel) |sentinel_ptr| {
973 const sentinel = @as(*align(1) const ptr_info.child, @ptrCast(sentinel_ptr)).*;973 const sentinel = @as(*align(1) const ptr_info.child, @ptrCast(sentinel_ptr)).*;
974 if (sentinel == end) {974 if (sentinel == end) {
975 return indexOfSentinel(ptr_info.child, end, ptr);975 return indexOfSentinel(ptr_info.child, end, ptr);
...@@ -981,11 +981,11 @@ fn lenSliceTo(ptr: anytype, comptime end: std.meta.Elem(@TypeOf(ptr))) usize {...@@ -981,11 +981,11 @@ fn lenSliceTo(ptr: anytype, comptime end: std.meta.Elem(@TypeOf(ptr))) usize {
981 while (ptr[i] != end and ptr[i] != sentinel) i += 1;981 while (ptr[i] != end and ptr[i] != sentinel) i += 1;
982 return i;982 return i;
983 },983 },
984 .C => {984 .c => {
985 assert(ptr != null);985 assert(ptr != null);
986 return indexOfSentinel(ptr_info.child, end, ptr);986 return indexOfSentinel(ptr_info.child, end, ptr);
987 },987 },
988 .Slice => {988 .slice => {
989 if (ptr_info.sentinel) |sentinel_ptr| {989 if (ptr_info.sentinel) |sentinel_ptr| {
990 const sentinel = @as(*align(1) const ptr_info.child, @ptrCast(sentinel_ptr)).*;990 const sentinel = @as(*align(1) const ptr_info.child, @ptrCast(sentinel_ptr)).*;
991 if (sentinel == end) {991 if (sentinel == end) {
...@@ -1039,13 +1039,13 @@ test lenSliceTo {...@@ -1039,13 +1039,13 @@ test lenSliceTo {
1039pub fn len(value: anytype) usize {1039pub fn len(value: anytype) usize {
1040 switch (@typeInfo(@TypeOf(value))) {1040 switch (@typeInfo(@TypeOf(value))) {
1041 .pointer => |info| switch (info.size) {1041 .pointer => |info| switch (info.size) {
1042 .Many => {1042 .many => {
1043 const sentinel_ptr = info.sentinel orelse1043 const sentinel_ptr = info.sentinel orelse
1044 @compileError("invalid type given to std.mem.len: " ++ @typeName(@TypeOf(value)));1044 @compileError("invalid type given to std.mem.len: " ++ @typeName(@TypeOf(value)));
1045 const sentinel = @as(*align(1) const info.child, @ptrCast(sentinel_ptr)).*;1045 const sentinel = @as(*align(1) const info.child, @ptrCast(sentinel_ptr)).*;
1046 return indexOfSentinel(info.child, sentinel, value);1046 return indexOfSentinel(info.child, sentinel, value);
1047 },1047 },
1048 .C => {1048 .c => {
1049 assert(value != null);1049 assert(value != null);
1050 return indexOfSentinel(info.child, 0, value);1050 return indexOfSentinel(info.child, 0, value);
1051 },1051 },
...@@ -3582,19 +3582,19 @@ fn ReverseIterator(comptime T: type) type {...@@ -3582,19 +3582,19 @@ fn ReverseIterator(comptime T: type) type {
3582 const Pointer = blk: {3582 const Pointer = blk: {
3583 switch (@typeInfo(T)) {3583 switch (@typeInfo(T)) {
3584 .pointer => |ptr_info| switch (ptr_info.size) {3584 .pointer => |ptr_info| switch (ptr_info.size) {
3585 .One => switch (@typeInfo(ptr_info.child)) {3585 .one => switch (@typeInfo(ptr_info.child)) {
3586 .array => |array_info| {3586 .array => |array_info| {
3587 var new_ptr_info = ptr_info;3587 var new_ptr_info = ptr_info;
3588 new_ptr_info.size = .Many;3588 new_ptr_info.size = .many;
3589 new_ptr_info.child = array_info.child;3589 new_ptr_info.child = array_info.child;
3590 new_ptr_info.sentinel = array_info.sentinel;3590 new_ptr_info.sentinel = array_info.sentinel;
3591 break :blk @Type(.{ .pointer = new_ptr_info });3591 break :blk @Type(.{ .pointer = new_ptr_info });
3592 },3592 },
3593 else => {},3593 else => {},
3594 },3594 },
3595 .Slice => {3595 .slice => {
3596 var new_ptr_info = ptr_info;3596 var new_ptr_info = ptr_info;
3597 new_ptr_info.size = .Many;3597 new_ptr_info.size = .many;
3598 break :blk @Type(.{ .pointer = new_ptr_info });3598 break :blk @Type(.{ .pointer = new_ptr_info });
3599 },3599 },
3600 else => {},3600 else => {},
...@@ -3606,7 +3606,7 @@ fn ReverseIterator(comptime T: type) type {...@@ -3606,7 +3606,7 @@ fn ReverseIterator(comptime T: type) type {
3606 const Element = std.meta.Elem(Pointer);3606 const Element = std.meta.Elem(Pointer);
3607 const ElementPointer = @Type(.{ .pointer = ptr: {3607 const ElementPointer = @Type(.{ .pointer = ptr: {
3608 var ptr = @typeInfo(Pointer).pointer;3608 var ptr = @typeInfo(Pointer).pointer;
3609 ptr.size = .One;3609 ptr.size = .one;
3610 ptr.child = Element;3610 ptr.child = Element;
3611 ptr.sentinel = null;3611 ptr.sentinel = null;
3612 break :ptr ptr;3612 break :ptr ptr;
...@@ -3912,7 +3912,7 @@ pub fn alignPointerOffset(ptr: anytype, align_to: usize) ?usize {...@@ -3912,7 +3912,7 @@ pub fn alignPointerOffset(ptr: anytype, align_to: usize) ?usize {
39123912
3913 const T = @TypeOf(ptr);3913 const T = @TypeOf(ptr);
3914 const info = @typeInfo(T);3914 const info = @typeInfo(T);
3915 if (info != .pointer or info.pointer.size != .Many)3915 if (info != .pointer or info.pointer.size != .many)
3916 @compileError("expected many item pointer, got " ++ @typeName(T));3916 @compileError("expected many item pointer, got " ++ @typeName(T));
39173917
3918 // Do nothing if the pointer is already well-aligned.3918 // Do nothing if the pointer is already well-aligned.
...@@ -3986,9 +3986,9 @@ fn CopyPtrAttrs(...@@ -3986,9 +3986,9 @@ fn CopyPtrAttrs(
39863986
3987fn AsBytesReturnType(comptime P: type) type {3987fn AsBytesReturnType(comptime P: type) type {
3988 const pointer = @typeInfo(P).pointer;3988 const pointer = @typeInfo(P).pointer;
3989 assert(pointer.size == .One);3989 assert(pointer.size == .one);
3990 const size = @sizeOf(pointer.child);3990 const size = @sizeOf(pointer.child);
3991 return CopyPtrAttrs(P, .One, [size]u8);3991 return CopyPtrAttrs(P, .one, [size]u8);
3992}3992}
39933993
3994/// Given a pointer to a single item, returns a slice of the underlying bytes, preserving pointer attributes.3994/// Given a pointer to a single item, returns a slice of the underlying bytes, preserving pointer attributes.
...@@ -4071,7 +4071,7 @@ test toBytes {...@@ -4071,7 +4071,7 @@ test toBytes {
4071}4071}
40724072
4073fn BytesAsValueReturnType(comptime T: type, comptime B: type) type {4073fn BytesAsValueReturnType(comptime T: type, comptime B: type) type {
4074 return CopyPtrAttrs(B, .One, T);4074 return CopyPtrAttrs(B, .one, T);
4075}4075}
40764076
4077/// Given a pointer to an array of bytes, returns a pointer to a value of the specified type4077/// Given a pointer to an array of bytes, returns a pointer to a value of the specified type
...@@ -4150,7 +4150,7 @@ test bytesToValue {...@@ -4150,7 +4150,7 @@ test bytesToValue {
4150}4150}
41514151
4152fn BytesAsSliceReturnType(comptime T: type, comptime bytesType: type) type {4152fn BytesAsSliceReturnType(comptime T: type, comptime bytesType: type) type {
4153 return CopyPtrAttrs(bytesType, .Slice, T);4153 return CopyPtrAttrs(bytesType, .slice, T);
4154}4154}
41554155
4156/// Given a slice of bytes, returns a slice of the specified type4156/// Given a slice of bytes, returns a slice of the specified type
...@@ -4162,7 +4162,7 @@ pub fn bytesAsSlice(comptime T: type, bytes: anytype) BytesAsSliceReturnType(T,...@@ -4162,7 +4162,7 @@ pub fn bytesAsSlice(comptime T: type, bytes: anytype) BytesAsSliceReturnType(T,
4162 return &[0]T{};4162 return &[0]T{};
4163 }4163 }
41644164
4165 const cast_target = CopyPtrAttrs(@TypeOf(bytes), .Many, T);4165 const cast_target = CopyPtrAttrs(@TypeOf(bytes), .many, T);
41664166
4167 return @as(cast_target, @ptrCast(bytes))[0..@divExact(bytes.len, @sizeOf(T))];4167 return @as(cast_target, @ptrCast(bytes))[0..@divExact(bytes.len, @sizeOf(T))];
4168}4168}
...@@ -4237,7 +4237,7 @@ test "bytesAsSlice preserves pointer attributes" {...@@ -4237,7 +4237,7 @@ test "bytesAsSlice preserves pointer attributes" {
4237}4237}
42384238
4239fn SliceAsBytesReturnType(comptime Slice: type) type {4239fn SliceAsBytesReturnType(comptime Slice: type) type {
4240 return CopyPtrAttrs(Slice, .Slice, u8);4240 return CopyPtrAttrs(Slice, .slice, u8);
4241}4241}
42424242
4243/// Given a slice, returns a slice of the underlying bytes, preserving pointer attributes.4243/// Given a slice, returns a slice of the underlying bytes, preserving pointer attributes.
...@@ -4251,7 +4251,7 @@ pub fn sliceAsBytes(slice: anytype) SliceAsBytesReturnType(@TypeOf(slice)) {...@@ -4251,7 +4251,7 @@ pub fn sliceAsBytes(slice: anytype) SliceAsBytesReturnType(@TypeOf(slice)) {
4251 // it may be equal to zero and fail a null check4251 // it may be equal to zero and fail a null check
4252 if (slice.len == 0 and std.meta.sentinel(Slice) == null) return &[0]u8{};4252 if (slice.len == 0 and std.meta.sentinel(Slice) == null) return &[0]u8{};
42534253
4254 const cast_target = CopyPtrAttrs(Slice, .Many, u8);4254 const cast_target = CopyPtrAttrs(Slice, .many, u8);
42554255
4256 return @as(cast_target, @ptrCast(slice))[0 .. slice.len * @sizeOf(std.meta.Elem(Slice))];4256 return @as(cast_target, @ptrCast(slice))[0 .. slice.len * @sizeOf(std.meta.Elem(Slice))];
4257}4257}
...@@ -4540,7 +4540,7 @@ fn AlignedSlice(comptime AttributeSource: type, comptime new_alignment: usize) t...@@ -4540,7 +4540,7 @@ fn AlignedSlice(comptime AttributeSource: type, comptime new_alignment: usize) t
4540 const info = @typeInfo(AttributeSource).pointer;4540 const info = @typeInfo(AttributeSource).pointer;
4541 return @Type(.{4541 return @Type(.{
4542 .pointer = .{4542 .pointer = .{
4543 .size = .Slice,4543 .size = .slice,
4544 .is_const = info.is_const,4544 .is_const = info.is_const,
4545 .is_volatile = info.is_volatile,4545 .is_volatile = info.is_volatile,
4546 .is_allowzero = info.is_allowzero,4546 .is_allowzero = info.is_allowzero,
lib/std/mem/Allocator.zig+1-1
...@@ -110,7 +110,7 @@ pub fn create(self: Allocator, comptime T: type) Error!*T {...@@ -110,7 +110,7 @@ pub fn create(self: Allocator, comptime T: type) Error!*T {
110/// have the same address and alignment property.110/// have the same address and alignment property.
111pub fn destroy(self: Allocator, ptr: anytype) void {111pub fn destroy(self: Allocator, ptr: anytype) void {
112 const info = @typeInfo(@TypeOf(ptr)).pointer;112 const info = @typeInfo(@TypeOf(ptr)).pointer;
113 if (info.size != .One) @compileError("ptr must be a single item pointer");113 if (info.size != .one) @compileError("ptr must be a single item pointer");
114 const T = info.child;114 const T = info.child;
115 if (@sizeOf(T) == 0) return;115 if (@sizeOf(T) == 0) return;
116 const non_const_ptr = @as([*]u8, @ptrCast(@constCast(ptr)));116 const non_const_ptr = @as([*]u8, @ptrCast(@constCast(ptr)));
lib/std/meta.zig+15-15
...@@ -103,12 +103,12 @@ pub fn Elem(comptime T: type) type {...@@ -103,12 +103,12 @@ pub fn Elem(comptime T: type) type {
103 .array => |info| return info.child,103 .array => |info| return info.child,
104 .vector => |info| return info.child,104 .vector => |info| return info.child,
105 .pointer => |info| switch (info.size) {105 .pointer => |info| switch (info.size) {
106 .One => switch (@typeInfo(info.child)) {106 .one => switch (@typeInfo(info.child)) {
107 .array => |array_info| return array_info.child,107 .array => |array_info| return array_info.child,
108 .vector => |vector_info| return vector_info.child,108 .vector => |vector_info| return vector_info.child,
109 else => {},109 else => {},
110 },110 },
111 .Many, .C, .Slice => return info.child,111 .many, .c, .slice => return info.child,
112 },112 },
113 .optional => |info| return Elem(info.child),113 .optional => |info| return Elem(info.child),
114 else => {},114 else => {},
...@@ -138,11 +138,11 @@ pub inline fn sentinel(comptime T: type) ?Elem(T) {...@@ -138,11 +138,11 @@ pub inline fn sentinel(comptime T: type) ?Elem(T) {
138 },138 },
139 .pointer => |info| {139 .pointer => |info| {
140 switch (info.size) {140 switch (info.size) {
141 .Many, .Slice => {141 .many, .slice => {
142 const sentinel_ptr = info.sentinel orelse return null;142 const sentinel_ptr = info.sentinel orelse return null;
143 return @as(*align(1) const info.child, @ptrCast(sentinel_ptr)).*;143 return @as(*align(1) const info.child, @ptrCast(sentinel_ptr)).*;
144 },144 },
145 .One => switch (@typeInfo(info.child)) {145 .one => switch (@typeInfo(info.child)) {
146 .array => |array_info| {146 .array => |array_info| {
147 const sentinel_ptr = array_info.sentinel orelse return null;147 const sentinel_ptr = array_info.sentinel orelse return null;
148 return @as(*align(1) const array_info.child, @ptrCast(sentinel_ptr)).*;148 return @as(*align(1) const array_info.child, @ptrCast(sentinel_ptr)).*;
...@@ -178,7 +178,7 @@ fn testSentinel() !void {...@@ -178,7 +178,7 @@ fn testSentinel() !void {
178pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type {178pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type {
179 switch (@typeInfo(T)) {179 switch (@typeInfo(T)) {
180 .pointer => |info| switch (info.size) {180 .pointer => |info| switch (info.size) {
181 .One => switch (@typeInfo(info.child)) {181 .one => switch (@typeInfo(info.child)) {
182 .array => |array_info| return @Type(.{182 .array => |array_info| return @Type(.{
183 .pointer = .{183 .pointer = .{
184 .size = info.size,184 .size = info.size,
...@@ -199,7 +199,7 @@ pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type {...@@ -199,7 +199,7 @@ pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type {
199 }),199 }),
200 else => {},200 else => {},
201 },201 },
202 .Many, .Slice => return @Type(.{202 .many, .slice => return @Type(.{
203 .pointer = .{203 .pointer = .{
204 .size = info.size,204 .size = info.size,
205 .is_const = info.is_const,205 .is_const = info.is_const,
...@@ -215,7 +215,7 @@ pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type {...@@ -215,7 +215,7 @@ pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type {
215 },215 },
216 .optional => |info| switch (@typeInfo(info.child)) {216 .optional => |info| switch (@typeInfo(info.child)) {
217 .pointer => |ptr_info| switch (ptr_info.size) {217 .pointer => |ptr_info| switch (ptr_info.size) {
218 .Many => return @Type(.{218 .many => return @Type(.{
219 .optional = .{219 .optional = .{
220 .child = @Type(.{220 .child = @Type(.{
221 .pointer = .{221 .pointer = .{
...@@ -786,8 +786,8 @@ pub fn eql(a: anytype, b: @TypeOf(a)) bool {...@@ -786,8 +786,8 @@ pub fn eql(a: anytype, b: @TypeOf(a)) bool {
786 },786 },
787 .pointer => |info| {787 .pointer => |info| {
788 return switch (info.size) {788 return switch (info.size) {
789 .One, .Many, .C => a == b,789 .one, .many, .c => a == b,
790 .Slice => a.ptr == b.ptr and a.len == b.len,790 .slice => a.ptr == b.ptr and a.len == b.len,
791 };791 };
792 },792 },
793 .optional => {793 .optional => {
...@@ -1090,7 +1090,7 @@ test "Tuple deduplication" {...@@ -1090,7 +1090,7 @@ test "Tuple deduplication" {
1090test "ArgsTuple forwarding" {1090test "ArgsTuple forwarding" {
1091 const T1 = std.meta.Tuple(&.{ u32, f32, i8 });1091 const T1 = std.meta.Tuple(&.{ u32, f32, i8 });
1092 const T2 = std.meta.ArgsTuple(fn (u32, f32, i8) void);1092 const T2 = std.meta.ArgsTuple(fn (u32, f32, i8) void);
1093 const T3 = std.meta.ArgsTuple(fn (u32, f32, i8) callconv(.C) noreturn);1093 const T3 = std.meta.ArgsTuple(fn (u32, f32, i8) callconv(.c) noreturn);
10941094
1095 if (T1 != T2) {1095 if (T1 != T2) {
1096 @compileError("std.meta.ArgsTuple produces different types than std.meta.Tuple");1096 @compileError("std.meta.ArgsTuple produces different types than std.meta.Tuple");
...@@ -1144,8 +1144,8 @@ test hasFn {...@@ -1144,8 +1144,8 @@ test hasFn {
1144pub inline fn hasMethod(comptime T: type, comptime name: []const u8) bool {1144pub inline fn hasMethod(comptime T: type, comptime name: []const u8) bool {
1145 return switch (@typeInfo(T)) {1145 return switch (@typeInfo(T)) {
1146 .pointer => |P| switch (P.size) {1146 .pointer => |P| switch (P.size) {
1147 .One => hasFn(P.child, name),1147 .one => hasFn(P.child, name),
1148 .Many, .Slice, .C => false,1148 .many, .slice, .c => false,
1149 },1149 },
1150 else => hasFn(T, name),1150 else => hasFn(T, name),
1151 };1151 };
...@@ -1200,12 +1200,12 @@ pub inline fn hasUniqueRepresentation(comptime T: type) bool {...@@ -1200,12 +1200,12 @@ pub inline fn hasUniqueRepresentation(comptime T: type) bool {
12001200
1201 .int => |info| @sizeOf(T) * 8 == info.bits,1201 .int => |info| @sizeOf(T) * 8 == info.bits,
12021202
1203 .pointer => |info| info.size != .Slice,1203 .pointer => |info| info.size != .slice,
12041204
1205 .optional => |info| switch (@typeInfo(info.child)) {1205 .optional => |info| switch (@typeInfo(info.child)) {
1206 .pointer => |ptr| !ptr.is_allowzero and switch (ptr.size) {1206 .pointer => |ptr| !ptr.is_allowzero and switch (ptr.size) {
1207 .Slice, .C => false,1207 .slice, .c => false,
1208 .One, .Many => true,1208 .one, .many => true,
1209 },1209 },
1210 else => false,1210 else => false,
1211 },1211 },
lib/std/os/emscripten.zig+22-22
...@@ -12,7 +12,7 @@ const c = std.c;...@@ -12,7 +12,7 @@ const c = std.c;
12pub const FILE = c.FILE;12pub const FILE = c.FILE;
1313
14var __stack_chk_guard: usize = 0;14var __stack_chk_guard: usize = 0;
15fn __stack_chk_fail() callconv(.C) void {15fn __stack_chk_fail() callconv(.c) void {
16 std.debug.print("stack smashing detected: terminated\n", .{});16 std.debug.print("stack smashing detected: terminated\n", .{});
17 emscripten_force_exit(127);17 emscripten_force_exit(127);
18}18}
...@@ -547,8 +547,8 @@ pub const SIG = struct {...@@ -547,8 +547,8 @@ pub const SIG = struct {
547};547};
548548
549pub const Sigaction = extern struct {549pub const Sigaction = extern struct {
550 pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;550 pub const handler_fn = *align(1) const fn (i32) callconv(.c) void;
551 pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;551 pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
552552
553 handler: extern union {553 handler: extern union {
554 handler: ?handler_fn,554 handler: ?handler_fn,
...@@ -556,7 +556,7 @@ pub const Sigaction = extern struct {...@@ -556,7 +556,7 @@ pub const Sigaction = extern struct {
556 },556 },
557 mask: sigset_t,557 mask: sigset_t,
558 flags: c_uint,558 flags: c_uint,
559 restorer: ?*const fn () callconv(.C) void = null,559 restorer: ?*const fn () callconv(.c) void = null,
560};560};
561561
562pub const sigset_t = [1024 / 32]u32;562pub const sigset_t = [1024 / 32]u32;
...@@ -909,23 +909,23 @@ pub const LOG = struct {...@@ -909,23 +909,23 @@ pub const LOG = struct {
909 pub const INFO = 512;909 pub const INFO = 512;
910};910};
911911
912pub const em_callback_func = ?*const fn () callconv(.C) void;912pub const em_callback_func = ?*const fn () callconv(.c) void;
913pub const em_arg_callback_func = ?*const fn (?*anyopaque) callconv(.C) void;913pub const em_arg_callback_func = ?*const fn (?*anyopaque) callconv(.c) void;
914pub const em_str_callback_func = ?*const fn ([*:0]const u8) callconv(.C) void;914pub const em_str_callback_func = ?*const fn ([*:0]const u8) callconv(.c) void;
915915
916pub extern "c" fn emscripten_async_wget(url: [*:0]const u8, file: [*:0]const u8, onload: em_str_callback_func, onerror: em_str_callback_func) void;916pub extern "c" fn emscripten_async_wget(url: [*:0]const u8, file: [*:0]const u8, onload: em_str_callback_func, onerror: em_str_callback_func) void;
917917
918pub const em_async_wget_onload_func = ?*const fn (?*anyopaque, ?*anyopaque, c_int) callconv(.C) void;918pub const em_async_wget_onload_func = ?*const fn (?*anyopaque, ?*anyopaque, c_int) callconv(.c) void;
919pub extern "c" fn emscripten_async_wget_data(url: [*:0]const u8, arg: ?*anyopaque, onload: em_async_wget_onload_func, onerror: em_arg_callback_func) void;919pub extern "c" fn emscripten_async_wget_data(url: [*:0]const u8, arg: ?*anyopaque, onload: em_async_wget_onload_func, onerror: em_arg_callback_func) void;
920920
921pub const em_async_wget2_onload_func = ?*const fn (c_uint, ?*anyopaque, [*:0]const u8) callconv(.C) void;921pub const em_async_wget2_onload_func = ?*const fn (c_uint, ?*anyopaque, [*:0]const u8) callconv(.c) void;
922pub const em_async_wget2_onstatus_func = ?*const fn (c_uint, ?*anyopaque, c_int) callconv(.C) void;922pub const em_async_wget2_onstatus_func = ?*const fn (c_uint, ?*anyopaque, c_int) callconv(.c) void;
923923
924pub extern "c" fn emscripten_async_wget2(url: [*:0]const u8, file: [*:0]const u8, requesttype: [*:0]const u8, param: [*:0]const u8, arg: ?*anyopaque, onload: em_async_wget2_onload_func, onerror: em_async_wget2_onstatus_func, onprogress: em_async_wget2_onstatus_func) c_int;924pub extern "c" fn emscripten_async_wget2(url: [*:0]const u8, file: [*:0]const u8, requesttype: [*:0]const u8, param: [*:0]const u8, arg: ?*anyopaque, onload: em_async_wget2_onload_func, onerror: em_async_wget2_onstatus_func, onprogress: em_async_wget2_onstatus_func) c_int;
925925
926pub const em_async_wget2_data_onload_func = ?*const fn (c_uint, ?*anyopaque, ?*anyopaque, c_uint) callconv(.C) void;926pub const em_async_wget2_data_onload_func = ?*const fn (c_uint, ?*anyopaque, ?*anyopaque, c_uint) callconv(.c) void;
927pub const em_async_wget2_data_onerror_func = ?*const fn (c_uint, ?*anyopaque, c_int, [*:0]const u8) callconv(.C) void;927pub const em_async_wget2_data_onerror_func = ?*const fn (c_uint, ?*anyopaque, c_int, [*:0]const u8) callconv(.c) void;
928pub const em_async_wget2_data_onprogress_func = ?*const fn (c_uint, ?*anyopaque, c_int, c_int) callconv(.C) void;928pub const em_async_wget2_data_onprogress_func = ?*const fn (c_uint, ?*anyopaque, c_int, c_int) callconv(.c) void;
929929
930pub extern "c" fn emscripten_async_wget2_data(url: [*:0]const u8, requesttype: [*:0]const u8, param: [*:0]const u8, arg: ?*anyopaque, free: c_int, onload: em_async_wget2_data_onload_func, onerror: em_async_wget2_data_onerror_func, onprogress: em_async_wget2_data_onprogress_func) c_int;930pub extern "c" fn emscripten_async_wget2_data(url: [*:0]const u8, requesttype: [*:0]const u8, param: [*:0]const u8, arg: ?*anyopaque, free: c_int, onload: em_async_wget2_data_onload_func, onerror: em_async_wget2_data_onerror_func, onprogress: em_async_wget2_data_onprogress_func) c_int;
931pub extern "c" fn emscripten_async_wget2_abort(handle: c_int) void;931pub extern "c" fn emscripten_async_wget2_abort(handle: c_int) void;
...@@ -944,8 +944,8 @@ pub extern "c" fn emscripten_pause_main_loop() void;...@@ -944,8 +944,8 @@ pub extern "c" fn emscripten_pause_main_loop() void;
944pub extern "c" fn emscripten_resume_main_loop() void;944pub extern "c" fn emscripten_resume_main_loop() void;
945pub extern "c" fn emscripten_cancel_main_loop() void;945pub extern "c" fn emscripten_cancel_main_loop() void;
946946
947pub const em_socket_callback = ?*const fn (c_int, ?*anyopaque) callconv(.C) void;947pub const em_socket_callback = ?*const fn (c_int, ?*anyopaque) callconv(.c) void;
948pub const em_socket_error_callback = ?*const fn (c_int, c_int, [*:0]const u8, ?*anyopaque) callconv(.C) void;948pub const em_socket_error_callback = ?*const fn (c_int, c_int, [*:0]const u8, ?*anyopaque) callconv(.c) void;
949949
950pub extern "c" fn emscripten_set_socket_error_callback(userData: ?*anyopaque, callback: em_socket_error_callback) void;950pub extern "c" fn emscripten_set_socket_error_callback(userData: ?*anyopaque, callback: em_socket_error_callback) void;
951pub extern "c" fn emscripten_set_socket_open_callback(userData: ?*anyopaque, callback: em_socket_callback) void;951pub extern "c" fn emscripten_set_socket_open_callback(userData: ?*anyopaque, callback: em_socket_callback) void;
...@@ -968,11 +968,11 @@ pub extern "c" fn emscripten_set_canvas_size(width: c_int, height: c_int) void;...@@ -968,11 +968,11 @@ pub extern "c" fn emscripten_set_canvas_size(width: c_int, height: c_int) void;
968pub extern "c" fn emscripten_get_canvas_size(width: *c_int, height: *c_int, isFullscreen: *c_int) void;968pub extern "c" fn emscripten_get_canvas_size(width: *c_int, height: *c_int, isFullscreen: *c_int) void;
969pub extern "c" fn emscripten_get_now() f64;969pub extern "c" fn emscripten_get_now() f64;
970pub extern "c" fn emscripten_random() f32;970pub extern "c" fn emscripten_random() f32;
971pub const em_idb_onload_func = ?*const fn (?*anyopaque, ?*anyopaque, c_int) callconv(.C) void;971pub const em_idb_onload_func = ?*const fn (?*anyopaque, ?*anyopaque, c_int) callconv(.c) void;
972pub extern "c" fn emscripten_idb_async_load(db_name: [*:0]const u8, file_id: [*:0]const u8, arg: ?*anyopaque, onload: em_idb_onload_func, onerror: em_arg_callback_func) void;972pub extern "c" fn emscripten_idb_async_load(db_name: [*:0]const u8, file_id: [*:0]const u8, arg: ?*anyopaque, onload: em_idb_onload_func, onerror: em_arg_callback_func) void;
973pub extern "c" fn emscripten_idb_async_store(db_name: [*:0]const u8, file_id: [*:0]const u8, ptr: ?*anyopaque, num: c_int, arg: ?*anyopaque, onstore: em_arg_callback_func, onerror: em_arg_callback_func) void;973pub extern "c" fn emscripten_idb_async_store(db_name: [*:0]const u8, file_id: [*:0]const u8, ptr: ?*anyopaque, num: c_int, arg: ?*anyopaque, onstore: em_arg_callback_func, onerror: em_arg_callback_func) void;
974pub extern "c" fn emscripten_idb_async_delete(db_name: [*:0]const u8, file_id: [*:0]const u8, arg: ?*anyopaque, ondelete: em_arg_callback_func, onerror: em_arg_callback_func) void;974pub extern "c" fn emscripten_idb_async_delete(db_name: [*:0]const u8, file_id: [*:0]const u8, arg: ?*anyopaque, ondelete: em_arg_callback_func, onerror: em_arg_callback_func) void;
975pub const em_idb_exists_func = ?*const fn (?*anyopaque, c_int) callconv(.C) void;975pub const em_idb_exists_func = ?*const fn (?*anyopaque, c_int) callconv(.c) void;
976pub extern "c" fn emscripten_idb_async_exists(db_name: [*:0]const u8, file_id: [*:0]const u8, arg: ?*anyopaque, oncheck: em_idb_exists_func, onerror: em_arg_callback_func) void;976pub extern "c" fn emscripten_idb_async_exists(db_name: [*:0]const u8, file_id: [*:0]const u8, arg: ?*anyopaque, oncheck: em_idb_exists_func, onerror: em_arg_callback_func) void;
977pub extern "c" fn emscripten_idb_load(db_name: [*:0]const u8, file_id: [*:0]const u8, pbuffer: *?*anyopaque, pnum: *c_int, perror: *c_int) void;977pub extern "c" fn emscripten_idb_load(db_name: [*:0]const u8, file_id: [*:0]const u8, pbuffer: *?*anyopaque, pnum: *c_int, perror: *c_int) void;
978pub extern "c" fn emscripten_idb_store(db_name: [*:0]const u8, file_id: [*:0]const u8, buffer: *anyopaque, num: c_int, perror: *c_int) void;978pub extern "c" fn emscripten_idb_store(db_name: [*:0]const u8, file_id: [*:0]const u8, buffer: *anyopaque, num: c_int, perror: *c_int) void;
...@@ -983,13 +983,13 @@ pub extern "c" fn emscripten_idb_store_blob(db_name: [*:0]const u8, file_id: [*:...@@ -983,13 +983,13 @@ pub extern "c" fn emscripten_idb_store_blob(db_name: [*:0]const u8, file_id: [*:
983pub extern "c" fn emscripten_idb_read_from_blob(blob: c_int, start: c_int, num: c_int, buffer: ?*anyopaque) void;983pub extern "c" fn emscripten_idb_read_from_blob(blob: c_int, start: c_int, num: c_int, buffer: ?*anyopaque) void;
984pub extern "c" fn emscripten_idb_free_blob(blob: c_int) void;984pub extern "c" fn emscripten_idb_free_blob(blob: c_int) void;
985pub extern "c" fn emscripten_run_preload_plugins(file: [*:0]const u8, onload: em_str_callback_func, onerror: em_str_callback_func) c_int;985pub extern "c" fn emscripten_run_preload_plugins(file: [*:0]const u8, onload: em_str_callback_func, onerror: em_str_callback_func) c_int;
986pub const em_run_preload_plugins_data_onload_func = ?*const fn (?*anyopaque, [*:0]const u8) callconv(.C) void;986pub const em_run_preload_plugins_data_onload_func = ?*const fn (?*anyopaque, [*:0]const u8) callconv(.c) void;
987pub extern "c" fn emscripten_run_preload_plugins_data(data: [*]u8, size: c_int, suffix: [*:0]const u8, arg: ?*anyopaque, onload: em_run_preload_plugins_data_onload_func, onerror: em_arg_callback_func) void;987pub extern "c" fn emscripten_run_preload_plugins_data(data: [*]u8, size: c_int, suffix: [*:0]const u8, arg: ?*anyopaque, onload: em_run_preload_plugins_data_onload_func, onerror: em_arg_callback_func) void;
988pub extern "c" fn emscripten_lazy_load_code() void;988pub extern "c" fn emscripten_lazy_load_code() void;
989pub const worker_handle = c_int;989pub const worker_handle = c_int;
990pub extern "c" fn emscripten_create_worker(url: [*:0]const u8) worker_handle;990pub extern "c" fn emscripten_create_worker(url: [*:0]const u8) worker_handle;
991pub extern "c" fn emscripten_destroy_worker(worker: worker_handle) void;991pub extern "c" fn emscripten_destroy_worker(worker: worker_handle) void;
992pub const em_worker_callback_func = ?*const fn ([*]u8, c_int, ?*anyopaque) callconv(.C) void;992pub const em_worker_callback_func = ?*const fn ([*]u8, c_int, ?*anyopaque) callconv(.c) void;
993pub extern "c" fn emscripten_call_worker(worker: worker_handle, funcname: [*:0]const u8, data: [*]u8, size: c_int, callback: em_worker_callback_func, arg: ?*anyopaque) void;993pub extern "c" fn emscripten_call_worker(worker: worker_handle, funcname: [*:0]const u8, data: [*]u8, size: c_int, callback: em_worker_callback_func, arg: ?*anyopaque) void;
994pub extern "c" fn emscripten_worker_respond(data: [*]u8, size: c_int) void;994pub extern "c" fn emscripten_worker_respond(data: [*]u8, size: c_int) void;
995pub extern "c" fn emscripten_worker_respond_provisionally(data: [*]u8, size: c_int) void;995pub extern "c" fn emscripten_worker_respond_provisionally(data: [*]u8, size: c_int) void;
...@@ -1003,10 +1003,10 @@ pub extern "c" fn emscripten_get_preloaded_image_data_from_FILE(file: *FILE, w:...@@ -1003,10 +1003,10 @@ pub extern "c" fn emscripten_get_preloaded_image_data_from_FILE(file: *FILE, w:
1003pub extern "c" fn emscripten_log(flags: c_int, format: [*:0]const u8, ...) void;1003pub extern "c" fn emscripten_log(flags: c_int, format: [*:0]const u8, ...) void;
1004pub extern "c" fn emscripten_get_callstack(flags: c_int, out: ?[*]u8, maxbytes: c_int) c_int;1004pub extern "c" fn emscripten_get_callstack(flags: c_int, out: ?[*]u8, maxbytes: c_int) c_int;
1005pub extern "c" fn emscripten_print_double(x: f64, to: ?[*]u8, max: c_int) c_int;1005pub extern "c" fn emscripten_print_double(x: f64, to: ?[*]u8, max: c_int) c_int;
1006pub const em_scan_func = ?*const fn (?*anyopaque, ?*anyopaque) callconv(.C) void;1006pub const em_scan_func = ?*const fn (?*anyopaque, ?*anyopaque) callconv(.c) void;
1007pub extern "c" fn emscripten_scan_registers(func: em_scan_func) void;1007pub extern "c" fn emscripten_scan_registers(func: em_scan_func) void;
1008pub extern "c" fn emscripten_scan_stack(func: em_scan_func) void;1008pub extern "c" fn emscripten_scan_stack(func: em_scan_func) void;
1009pub const em_dlopen_callback = ?*const fn (?*anyopaque, ?*anyopaque) callconv(.C) void;1009pub const em_dlopen_callback = ?*const fn (?*anyopaque, ?*anyopaque) callconv(.c) void;
1010pub extern "c" fn emscripten_dlopen(filename: [*:0]const u8, flags: c_int, user_data: ?*anyopaque, onsuccess: em_dlopen_callback, onerror: em_arg_callback_func) void;1010pub extern "c" fn emscripten_dlopen(filename: [*:0]const u8, flags: c_int, user_data: ?*anyopaque, onsuccess: em_dlopen_callback, onerror: em_arg_callback_func) void;
1011pub extern "c" fn emscripten_dlopen_promise(filename: [*:0]const u8, flags: c_int) em_promise_t;1011pub extern "c" fn emscripten_dlopen_promise(filename: [*:0]const u8, flags: c_int) em_promise_t;
1012pub extern "c" fn emscripten_throw_number(number: f64) void;1012pub extern "c" fn emscripten_throw_number(number: f64) void;
...@@ -1024,7 +1024,7 @@ pub const struct__em_promise = opaque {};...@@ -1024,7 +1024,7 @@ pub const struct__em_promise = opaque {};
1024pub const em_promise_t = ?*struct__em_promise;1024pub const em_promise_t = ?*struct__em_promise;
1025pub const enum_em_promise_result_t = c_uint;1025pub const enum_em_promise_result_t = c_uint;
1026pub const em_promise_result_t = enum_em_promise_result_t;1026pub const em_promise_result_t = enum_em_promise_result_t;
1027pub const em_promise_callback_t = ?*const fn (?*?*anyopaque, ?*anyopaque, ?*anyopaque) callconv(.C) em_promise_result_t;1027pub const em_promise_callback_t = ?*const fn (?*?*anyopaque, ?*anyopaque, ?*anyopaque) callconv(.c) em_promise_result_t;
10281028
1029pub extern "c" fn emscripten_promise_create() em_promise_t;1029pub extern "c" fn emscripten_promise_create() em_promise_t;
1030pub extern "c" fn emscripten_promise_destroy(promise: em_promise_t) void;1030pub extern "c" fn emscripten_promise_destroy(promise: em_promise_t) void;
lib/std/os/linux.zig+11-11
...@@ -67,7 +67,7 @@ pub const syscall_pipe = syscall_bits.syscall_pipe;...@@ -67,7 +67,7 @@ pub const syscall_pipe = syscall_bits.syscall_pipe;
67pub const syscall_fork = syscall_bits.syscall_fork;67pub const syscall_fork = syscall_bits.syscall_fork;
6868
69pub fn clone(69pub fn clone(
70 func: *const fn (arg: usize) callconv(.C) u8,70 func: *const fn (arg: usize) callconv(.c) u8,
71 stack: usize,71 stack: usize,
72 flags: u32,72 flags: u32,
73 arg: usize,73 arg: usize,
...@@ -77,14 +77,14 @@ pub fn clone(...@@ -77,14 +77,14 @@ pub fn clone(
77) usize {77) usize {
78 // Can't directly call a naked function; cast to C calling convention first.78 // Can't directly call a naked function; cast to C calling convention first.
79 return @as(*const fn (79 return @as(*const fn (
80 *const fn (arg: usize) callconv(.C) u8,80 *const fn (arg: usize) callconv(.c) u8,
81 usize,81 usize,
82 u32,82 u32,
83 usize,83 usize,
84 ?*i32,84 ?*i32,
85 usize,85 usize,
86 ?*i32,86 ?*i32,
87 ) callconv(.C) usize, @ptrCast(&syscall_bits.clone))(func, stack, flags, arg, ptid, tp, ctid);87 ) callconv(.c) usize, @ptrCast(&syscall_bits.clone))(func, stack, flags, arg, ptid, tp, ctid);
88}88}
8989
90pub const ARCH = arch_bits.ARCH;90pub const ARCH = arch_bits.ARCH;
...@@ -494,7 +494,7 @@ pub const getauxval = if (extern_getauxval) struct {...@@ -494,7 +494,7 @@ pub const getauxval = if (extern_getauxval) struct {
494 extern fn getauxval(index: usize) usize;494 extern fn getauxval(index: usize) usize;
495}.getauxval else getauxvalImpl;495}.getauxval else getauxvalImpl;
496496
497fn getauxvalImpl(index: usize) callconv(.C) usize {497fn getauxvalImpl(index: usize) callconv(.c) usize {
498 const auxv = elf_aux_maybe orelse return 0;498 const auxv = elf_aux_maybe orelse return 0;
499 var i: usize = 0;499 var i: usize = 0;
500 while (auxv[i].a_type != std.elf.AT_NULL) : (i += 1) {500 while (auxv[i].a_type != std.elf.AT_NULL) : (i += 1) {
...@@ -1485,7 +1485,7 @@ pub fn flock(fd: fd_t, operation: i32) usize {...@@ -1485,7 +1485,7 @@ pub fn flock(fd: fd_t, operation: i32) usize {
1485}1485}
14861486
1487// We must follow the C calling convention when we call into the VDSO1487// We must follow the C calling convention when we call into the VDSO
1488const VdsoClockGettime = *align(1) const fn (clockid_t, *timespec) callconv(.C) usize;1488const VdsoClockGettime = *align(1) const fn (clockid_t, *timespec) callconv(.c) usize;
1489var vdso_clock_gettime: ?VdsoClockGettime = &init_vdso_clock_gettime;1489var vdso_clock_gettime: ?VdsoClockGettime = &init_vdso_clock_gettime;
14901490
1491pub fn clock_gettime(clk_id: clockid_t, tp: *timespec) usize {1491pub fn clock_gettime(clk_id: clockid_t, tp: *timespec) usize {
...@@ -1502,7 +1502,7 @@ pub fn clock_gettime(clk_id: clockid_t, tp: *timespec) usize {...@@ -1502,7 +1502,7 @@ pub fn clock_gettime(clk_id: clockid_t, tp: *timespec) usize {
1502 return syscall2(.clock_gettime, @intFromEnum(clk_id), @intFromPtr(tp));1502 return syscall2(.clock_gettime, @intFromEnum(clk_id), @intFromPtr(tp));
1503}1503}
15041504
1505fn init_vdso_clock_gettime(clk: clockid_t, ts: *timespec) callconv(.C) usize {1505fn init_vdso_clock_gettime(clk: clockid_t, ts: *timespec) callconv(.c) usize {
1506 const ptr: ?VdsoClockGettime = @ptrFromInt(vdso.lookup(VDSO.CGT_VER, VDSO.CGT_SYM));1506 const ptr: ?VdsoClockGettime = @ptrFromInt(vdso.lookup(VDSO.CGT_VER, VDSO.CGT_SYM));
1507 // Note that we may not have a VDSO at all, update the stub address anyway1507 // Note that we may not have a VDSO at all, update the stub address anyway
1508 // so that clock_gettime will fall back on the good old (and slow) syscall1508 // so that clock_gettime will fall back on the good old (and slow) syscall
...@@ -5070,8 +5070,8 @@ pub const all_mask: sigset_t = [_]u32{0xffffffff} ** @typeInfo(sigset_t).array.l...@@ -5070,8 +5070,8 @@ pub const all_mask: sigset_t = [_]u32{0xffffffff} ** @typeInfo(sigset_t).array.l
5070pub const app_mask: sigset_t = [2]u32{ 0xfffffffc, 0x7fffffff } ++ [_]u32{0xffffffff} ** 30;5070pub const app_mask: sigset_t = [2]u32{ 0xfffffffc, 0x7fffffff } ++ [_]u32{0xffffffff} ** 30;
50715071
5072const k_sigaction_funcs = struct {5072const k_sigaction_funcs = struct {
5073 const handler = ?*align(1) const fn (i32) callconv(.C) void;5073 const handler = ?*align(1) const fn (i32) callconv(.c) void;
5074 const restorer = *const fn () callconv(.C) void;5074 const restorer = *const fn () callconv(.c) void;
5075};5075};
50765076
5077pub const k_sigaction = switch (native_arch) {5077pub const k_sigaction = switch (native_arch) {
...@@ -5097,8 +5097,8 @@ pub const k_sigaction = switch (native_arch) {...@@ -5097,8 +5097,8 @@ pub const k_sigaction = switch (native_arch) {
50975097
5098/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.5098/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
5099pub const Sigaction = extern struct {5099pub const Sigaction = extern struct {
5100 pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;5100 pub const handler_fn = *align(1) const fn (i32) callconv(.c) void;
5101 pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;5101 pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
51025102
5103 handler: extern union {5103 handler: extern union {
5104 handler: ?handler_fn,5104 handler: ?handler_fn,
...@@ -5106,7 +5106,7 @@ pub const Sigaction = extern struct {...@@ -5106,7 +5106,7 @@ pub const Sigaction = extern struct {
5106 },5106 },
5107 mask: sigset_t,5107 mask: sigset_t,
5108 flags: c_uint,5108 flags: c_uint,
5109 restorer: ?*const fn () callconv(.C) void = null,5109 restorer: ?*const fn () callconv(.c) void = null,
5110};5110};
51115111
5112const sigset_len = @typeInfo(sigset_t).array.len;5112const sigset_len = @typeInfo(sigset_t).array.len;
lib/std/os/linux/sparc64.zig+1-1
...@@ -233,7 +233,7 @@ pub const restore = restore_rt;...@@ -233,7 +233,7 @@ pub const restore = restore_rt;
233233
234// Need to use C ABI here instead of naked234// Need to use C ABI here instead of naked
235// to prevent an infinite loop when calling rt_sigreturn.235// to prevent an infinite loop when calling rt_sigreturn.
236pub fn restore_rt() callconv(.C) void {236pub fn restore_rt() callconv(.c) void {
237 return asm volatile ("t 0x6d"237 return asm volatile ("t 0x6d"
238 :238 :
239 : [number] "{g1}" (@intFromEnum(SYS.rt_sigreturn)),239 : [number] "{g1}" (@intFromEnum(SYS.rt_sigreturn)),
lib/std/os/plan9.zig+2-2
...@@ -186,8 +186,8 @@ pub const empty_sigset = 0;...@@ -186,8 +186,8 @@ pub const empty_sigset = 0;
186pub const siginfo_t = c_long;186pub const siginfo_t = c_long;
187// TODO plan9 doesn't have sigaction_fn. Sigaction is not a union, but we include it here to be compatible.187// TODO plan9 doesn't have sigaction_fn. Sigaction is not a union, but we include it here to be compatible.
188pub const Sigaction = extern struct {188pub const Sigaction = extern struct {
189 pub const handler_fn = *const fn (i32) callconv(.C) void;189 pub const handler_fn = *const fn (i32) callconv(.c) void;
190 pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;190 pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.c) void;
191191
192 handler: extern union {192 handler: extern union {
193 handler: ?handler_fn,193 handler: ?handler_fn,
lib/std/os/uefi/tables/boot_services.zig+2-2
...@@ -149,11 +149,11 @@ pub const BootServices = extern struct {...@@ -149,11 +149,11 @@ pub const BootServices = extern struct {
149149
150 /// Installs one or more protocol interfaces into the boot services environment150 /// Installs one or more protocol interfaces into the boot services environment
151 // TODO: use callconv(cc) instead once that works151 // TODO: use callconv(cc) instead once that works
152 installMultipleProtocolInterfaces: *const fn (handle: *Handle, ...) callconv(.C) Status,152 installMultipleProtocolInterfaces: *const fn (handle: *Handle, ...) callconv(.c) Status,
153153
154 /// Removes one or more protocol interfaces into the boot services environment154 /// Removes one or more protocol interfaces into the boot services environment
155 // TODO: use callconv(cc) instead once that works155 // TODO: use callconv(cc) instead once that works
156 uninstallMultipleProtocolInterfaces: *const fn (handle: *Handle, ...) callconv(.C) Status,156 uninstallMultipleProtocolInterfaces: *const fn (handle: *Handle, ...) callconv(.c) Status,
157157
158 /// Computes and returns a 32-bit CRC for a data buffer.158 /// Computes and returns a 32-bit CRC for a data buffer.
159 calculateCrc32: *const fn (data: [*]const u8, data_size: usize, *u32) callconv(cc) Status,159 calculateCrc32: *const fn (data: [*]const u8, data_size: usize, *u32) callconv(cc) Status,
lib/std/posix.zig+1-1
...@@ -5552,7 +5552,7 @@ pub fn dl_iterate_phdr(...@@ -5552,7 +5552,7 @@ pub fn dl_iterate_phdr(
55525552
5553 if (builtin.link_libc) {5553 if (builtin.link_libc) {
5554 switch (system.dl_iterate_phdr(struct {5554 switch (system.dl_iterate_phdr(struct {
5555 fn callbackC(info: *dl_phdr_info, size: usize, data: ?*anyopaque) callconv(.C) c_int {5555 fn callbackC(info: *dl_phdr_info, size: usize, data: ?*anyopaque) callconv(.c) c_int {
5556 const context_ptr: *const Context = @ptrCast(@alignCast(data));5556 const context_ptr: *const Context = @ptrCast(@alignCast(data));
5557 callback(info, size, context_ptr.*) catch |err| return @intFromError(err);5557 callback(info, size, context_ptr.*) catch |err| return @intFromError(err);
5558 return 0;5558 return 0;
lib/std/posix/test.zig+1-1
...@@ -849,7 +849,7 @@ test "sigaction" {...@@ -849,7 +849,7 @@ test "sigaction" {
849 const S = struct {849 const S = struct {
850 var handler_called_count: u32 = 0;850 var handler_called_count: u32 = 0;
851851
852 fn handler(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.C) void {852 fn handler(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.c) void {
853 _ = ctx_ptr;853 _ = ctx_ptr;
854 // Check that we received the correct signal.854 // Check that we received the correct signal.
855 switch (native_os) {855 switch (native_os) {
lib/std/testing.zig+5-5
...@@ -100,13 +100,13 @@ fn expectEqualInner(comptime T: type, expected: T, actual: T) !void {...@@ -100,13 +100,13 @@ fn expectEqualInner(comptime T: type, expected: T, actual: T) !void {
100100
101 .pointer => |pointer| {101 .pointer => |pointer| {
102 switch (pointer.size) {102 switch (pointer.size) {
103 .One, .Many, .C => {103 .one, .many, .c => {
104 if (actual != expected) {104 if (actual != expected) {
105 print("expected {*}, found {*}\n", .{ expected, actual });105 print("expected {*}, found {*}\n", .{ expected, actual });
106 return error.TestExpectedEqual;106 return error.TestExpectedEqual;
107 }107 }
108 },108 },
109 .Slice => {109 .slice => {
110 if (actual.ptr != expected.ptr) {110 if (actual.ptr != expected.ptr) {
111 print("expected slice ptr {*}, found {*}\n", .{ expected.ptr, actual.ptr });111 print("expected slice ptr {*}, found {*}\n", .{ expected.ptr, actual.ptr });
112 return error.TestExpectedEqual;112 return error.TestExpectedEqual;
...@@ -726,13 +726,13 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe...@@ -726,13 +726,13 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe
726 .pointer => |pointer| {726 .pointer => |pointer| {
727 switch (pointer.size) {727 switch (pointer.size) {
728 // We have no idea what is behind those pointers, so the best we can do is `==` check.728 // We have no idea what is behind those pointers, so the best we can do is `==` check.
729 .C, .Many => {729 .c, .many => {
730 if (actual != expected) {730 if (actual != expected) {
731 print("expected {*}, found {*}\n", .{ expected, actual });731 print("expected {*}, found {*}\n", .{ expected, actual });
732 return error.TestExpectedEqual;732 return error.TestExpectedEqual;
733 }733 }
734 },734 },
735 .One => {735 .one => {
736 // Length of those pointers are runtime value, so the best we can do is `==` check.736 // Length of those pointers are runtime value, so the best we can do is `==` check.
737 switch (@typeInfo(pointer.child)) {737 switch (@typeInfo(pointer.child)) {
738 .@"fn", .@"opaque" => {738 .@"fn", .@"opaque" => {
...@@ -744,7 +744,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe...@@ -744,7 +744,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe
744 else => try expectEqualDeep(expected.*, actual.*),744 else => try expectEqualDeep(expected.*, actual.*),
745 }745 }
746 },746 },
747 .Slice => {747 .slice => {
748 if (expected.len != actual.len) {748 if (expected.len != actual.len) {
749 print("Slice len not the same, expected {d}, found {d}\n", .{ expected.len, actual.len });749 print("Slice len not the same, expected {d}, found {d}\n", .{ expected.len, actual.len });
750 return error.TestExpectedEqual;750 return error.TestExpectedEqual;
lib/std/zig/Ast.zig+5-6
...@@ -2157,14 +2157,13 @@ fn fullFnProtoComponents(tree: Ast, info: full.FnProto.Components) full.FnProto...@@ -2157,14 +2157,13 @@ fn fullFnProtoComponents(tree: Ast, info: full.FnProto.Components) full.FnProto
21572157
2158fn fullPtrTypeComponents(tree: Ast, info: full.PtrType.Components) full.PtrType {2158fn fullPtrTypeComponents(tree: Ast, info: full.PtrType.Components) full.PtrType {
2159 const token_tags = tree.tokens.items(.tag);2159 const token_tags = tree.tokens.items(.tag);
2160 const Size = std.builtin.Type.Pointer.Size;2160 const size: std.builtin.Type.Pointer.Size = switch (token_tags[info.main_token]) {
2161 const size: Size = switch (token_tags[info.main_token]) {
2162 .asterisk,2161 .asterisk,
2163 .asterisk_asterisk,2162 .asterisk_asterisk,
2164 => .One,2163 => .one,
2165 .l_bracket => switch (token_tags[info.main_token + 1]) {2164 .l_bracket => switch (token_tags[info.main_token + 1]) {
2166 .asterisk => if (token_tags[info.main_token + 2] == .identifier) Size.C else Size.Many,2165 .asterisk => if (token_tags[info.main_token + 2] == .identifier) .c else .many,
2167 else => Size.Slice,2166 else => .slice,
2168 },2167 },
2169 else => unreachable,2168 else => unreachable,
2170 };2169 };
...@@ -2180,7 +2179,7 @@ fn fullPtrTypeComponents(tree: Ast, info: full.PtrType.Components) full.PtrType...@@ -2180,7 +2179,7 @@ fn fullPtrTypeComponents(tree: Ast, info: full.PtrType.Components) full.PtrType
2180 // positives. Therefore, start after a sentinel if there is one and2179 // positives. Therefore, start after a sentinel if there is one and
2181 // skip over any align node and bit range nodes.2180 // skip over any align node and bit range nodes.
2182 var i = if (info.sentinel != 0) tree.lastToken(info.sentinel) + 1 else switch (size) {2181 var i = if (info.sentinel != 0) tree.lastToken(info.sentinel) + 1 else switch (size) {
2183 .Many, .C => info.main_token + 1,2182 .many, .c => info.main_token + 1,
2184 else => info.main_token,2183 else => info.main_token,
2185 };2184 };
2186 const end = tree.firstToken(info.child_type);2185 const end = tree.firstToken(info.child_type);
lib/std/zig/AstGen.zig+2-2
...@@ -3917,7 +3917,7 @@ fn ptrType(...@@ -3917,7 +3917,7 @@ fn ptrType(
3917 node: Ast.Node.Index,3917 node: Ast.Node.Index,
3918 ptr_info: Ast.full.PtrType,3918 ptr_info: Ast.full.PtrType,
3919) InnerError!Zir.Inst.Ref {3919) InnerError!Zir.Inst.Ref {
3920 if (ptr_info.size == .C and ptr_info.allowzero_token != null) {3920 if (ptr_info.size == .c and ptr_info.allowzero_token != null) {
3921 return gz.astgen.failTok(ptr_info.allowzero_token.?, "C pointers always allow address zero", .{});3921 return gz.astgen.failTok(ptr_info.allowzero_token.?, "C pointers always allow address zero", .{});
3922 }3922 }
39233923
...@@ -3946,7 +3946,7 @@ fn ptrType(...@@ -3946,7 +3946,7 @@ fn ptrType(
3946 .{ .rl = .{ .ty = elem_type } },3946 .{ .rl = .{ .ty = elem_type } },
3947 ptr_info.ast.sentinel,3947 ptr_info.ast.sentinel,
3948 switch (ptr_info.size) {3948 switch (ptr_info.size) {
3949 .Slice => .slice_sentinel,3949 .slice => .slice_sentinel,
3950 else => .pointer_sentinel,3950 else => .pointer_sentinel,
3951 },3951 },
3952 );3952 );
lib/std/zig/c_translation.zig+3-3
...@@ -170,7 +170,7 @@ pub fn sizeof(target: anytype) usize {...@@ -170,7 +170,7 @@ pub fn sizeof(target: anytype) usize {
170 }170 }
171 },171 },
172 .pointer => |ptr| {172 .pointer => |ptr| {
173 if (ptr.size == .Slice) {173 if (ptr.size == .slice) {
174 @compileError("Cannot use C sizeof on slice type " ++ @typeName(T));174 @compileError("Cannot use C sizeof on slice type " ++ @typeName(T));
175 }175 }
176 // for strings, sizeof("a") returns 2.176 // for strings, sizeof("a") returns 2.
...@@ -178,7 +178,7 @@ pub fn sizeof(target: anytype) usize {...@@ -178,7 +178,7 @@ pub fn sizeof(target: anytype) usize {
178 // in the .array case above, but strings remain literals178 // in the .array case above, but strings remain literals
179 // and are therefore always pointers, so they need to be179 // and are therefore always pointers, so they need to be
180 // specially handled here.180 // specially handled here.
181 if (ptr.size == .One and ptr.is_const and @typeInfo(ptr.child) == .array) {181 if (ptr.size == .one and ptr.is_const and @typeInfo(ptr.child) == .array) {
182 const array_info = @typeInfo(ptr.child).array;182 const array_info = @typeInfo(ptr.child).array;
183 if ((array_info.child == u8 or array_info.child == u16) and183 if ((array_info.child == u8 or array_info.child == u16) and
184 array_info.sentinel != null and184 array_info.sentinel != null and
...@@ -341,7 +341,7 @@ pub fn FlexibleArrayType(comptime SelfType: type, comptime ElementType: type) ty...@@ -341,7 +341,7 @@ pub fn FlexibleArrayType(comptime SelfType: type, comptime ElementType: type) ty
341 switch (@typeInfo(SelfType)) {341 switch (@typeInfo(SelfType)) {
342 .pointer => |ptr| {342 .pointer => |ptr| {
343 return @Type(.{ .pointer = .{343 return @Type(.{ .pointer = .{
344 .size = .C,344 .size = .c,
345 .is_const = ptr.is_const,345 .is_const = ptr.is_const,
346 .is_volatile = ptr.is_volatile,346 .is_volatile = ptr.is_volatile,
347 .alignment = @alignOf(ElementType),347 .alignment = @alignOf(ElementType),
lib/std/zig/parser_test.zig+4-4
...@@ -552,7 +552,7 @@ test "zig fmt: trailing comma in fn parameter list" {...@@ -552,7 +552,7 @@ test "zig fmt: trailing comma in fn parameter list" {
552 \\pub fn f(552 \\pub fn f(
553 \\ a: i32,553 \\ a: i32,
554 \\ b: i32,554 \\ b: i32,
555 \\) callconv(.C) i32 {}555 \\) callconv(.c) i32 {}
556 \\pub fn f(556 \\pub fn f(
557 \\ a: i32,557 \\ a: i32,
558 \\ b: i32,558 \\ b: i32,
...@@ -560,15 +560,15 @@ test "zig fmt: trailing comma in fn parameter list" {...@@ -560,15 +560,15 @@ test "zig fmt: trailing comma in fn parameter list" {
560 \\pub fn f(560 \\pub fn f(
561 \\ a: i32,561 \\ a: i32,
562 \\ b: i32,562 \\ b: i32,
563 \\) align(8) callconv(.C) i32 {}563 \\) align(8) callconv(.c) i32 {}
564 \\pub fn f(564 \\pub fn f(
565 \\ a: i32,565 \\ a: i32,
566 \\ b: i32,566 \\ b: i32,
567 \\) align(8) linksection(".text") callconv(.C) i32 {}567 \\) align(8) linksection(".text") callconv(.c) i32 {}
568 \\pub fn f(568 \\pub fn f(
569 \\ a: i32,569 \\ a: i32,
570 \\ b: i32,570 \\ b: i32,
571 \\) linksection(".text") callconv(.C) i32 {}571 \\) linksection(".text") callconv(.c) i32 {}
572 \\572 \\
573 );573 );
574}574}
lib/std/zig/render.zig+4-4
...@@ -938,7 +938,7 @@ fn renderArrayType(...@@ -938,7 +938,7 @@ fn renderArrayType(
938fn renderPtrType(r: *Render, ptr_type: Ast.full.PtrType, space: Space) Error!void {938fn renderPtrType(r: *Render, ptr_type: Ast.full.PtrType, space: Space) Error!void {
939 const tree = r.tree;939 const tree = r.tree;
940 switch (ptr_type.size) {940 switch (ptr_type.size) {
941 .One => {941 .one => {
942 // Since ** tokens exist and the same token is shared by two942 // Since ** tokens exist and the same token is shared by two
943 // nested pointer types, we check to see if we are the parent943 // nested pointer types, we check to see if we are the parent
944 // in such a relationship. If so, skip rendering anything for944 // in such a relationship. If so, skip rendering anything for
...@@ -951,7 +951,7 @@ fn renderPtrType(r: *Render, ptr_type: Ast.full.PtrType, space: Space) Error!voi...@@ -951,7 +951,7 @@ fn renderPtrType(r: *Render, ptr_type: Ast.full.PtrType, space: Space) Error!voi
951 }951 }
952 try renderToken(r, ptr_type.ast.main_token, .none); // asterisk952 try renderToken(r, ptr_type.ast.main_token, .none); // asterisk
953 },953 },
954 .Many => {954 .many => {
955 if (ptr_type.ast.sentinel == 0) {955 if (ptr_type.ast.sentinel == 0) {
956 try renderToken(r, ptr_type.ast.main_token, .none); // lbracket956 try renderToken(r, ptr_type.ast.main_token, .none); // lbracket
957 try renderToken(r, ptr_type.ast.main_token + 1, .none); // asterisk957 try renderToken(r, ptr_type.ast.main_token + 1, .none); // asterisk
...@@ -964,13 +964,13 @@ fn renderPtrType(r: *Render, ptr_type: Ast.full.PtrType, space: Space) Error!voi...@@ -964,13 +964,13 @@ fn renderPtrType(r: *Render, ptr_type: Ast.full.PtrType, space: Space) Error!voi
964 try renderToken(r, tree.lastToken(ptr_type.ast.sentinel) + 1, .none); // rbracket964 try renderToken(r, tree.lastToken(ptr_type.ast.sentinel) + 1, .none); // rbracket
965 }965 }
966 },966 },
967 .C => {967 .c => {
968 try renderToken(r, ptr_type.ast.main_token, .none); // lbracket968 try renderToken(r, ptr_type.ast.main_token, .none); // lbracket
969 try renderToken(r, ptr_type.ast.main_token + 1, .none); // asterisk969 try renderToken(r, ptr_type.ast.main_token + 1, .none); // asterisk
970 try renderToken(r, ptr_type.ast.main_token + 2, .none); // c970 try renderToken(r, ptr_type.ast.main_token + 2, .none); // c
971 try renderToken(r, ptr_type.ast.main_token + 3, .none); // rbracket971 try renderToken(r, ptr_type.ast.main_token + 3, .none); // rbracket
972 },972 },
973 .Slice => {973 .slice => {
974 if (ptr_type.ast.sentinel == 0) {974 if (ptr_type.ast.sentinel == 0) {
975 try renderToken(r, ptr_type.ast.main_token, .none); // lbracket975 try renderToken(r, ptr_type.ast.main_token, .none); // lbracket
976 try renderToken(r, ptr_type.ast.main_token + 1, .none); // rbracket976 try renderToken(r, ptr_type.ast.main_token + 1, .none); // rbracket
lib/std/zig/system/x86.zig+2-2
...@@ -475,7 +475,7 @@ const CpuidLeaf = packed struct {...@@ -475,7 +475,7 @@ const CpuidLeaf = packed struct {
475475
476/// This is a workaround for the C backend until zig has the ability to put476/// This is a workaround for the C backend until zig has the ability to put
477/// C code in inline assembly.477/// C code in inline assembly.
478extern fn zig_x86_cpuid(leaf_id: u32, subid: u32, eax: *u32, ebx: *u32, ecx: *u32, edx: *u32) callconv(.C) void;478extern fn zig_x86_cpuid(leaf_id: u32, subid: u32, eax: *u32, ebx: *u32, ecx: *u32, edx: *u32) callconv(.c) void;
479479
480fn cpuid(leaf_id: u32, subid: u32) CpuidLeaf {480fn cpuid(leaf_id: u32, subid: u32) CpuidLeaf {
481 // valid for both x86 and x86_64481 // valid for both x86 and x86_64
...@@ -502,7 +502,7 @@ fn cpuid(leaf_id: u32, subid: u32) CpuidLeaf {...@@ -502,7 +502,7 @@ fn cpuid(leaf_id: u32, subid: u32) CpuidLeaf {
502502
503/// This is a workaround for the C backend until zig has the ability to put503/// This is a workaround for the C backend until zig has the ability to put
504/// C code in inline assembly.504/// C code in inline assembly.
505extern fn zig_x86_get_xcr0() callconv(.C) u32;505extern fn zig_x86_get_xcr0() callconv(.c) u32;
506506
507// Read control register 0 (XCR0). Used to detect features such as AVX.507// Read control register 0 (XCR0). Used to detect features such as AVX.
508fn getXCR0() u32 {508fn getXCR0() u32 {
src/InternPool.zig+31-31
...@@ -1176,17 +1176,17 @@ const Local = struct {...@@ -1176,17 +1176,17 @@ const Local = struct {
1176 } });1176 } });
1177 }1177 }
11781178
1179 pub fn addOne(mutable: Mutable) Allocator.Error!PtrElem(.{ .size = .One }) {1179 pub fn addOne(mutable: Mutable) Allocator.Error!PtrElem(.{ .size = .one }) {
1180 try mutable.ensureUnusedCapacity(1);1180 try mutable.ensureUnusedCapacity(1);
1181 return mutable.addOneAssumeCapacity();1181 return mutable.addOneAssumeCapacity();
1182 }1182 }
11831183
1184 pub fn addOneAssumeCapacity(mutable: Mutable) PtrElem(.{ .size = .One }) {1184 pub fn addOneAssumeCapacity(mutable: Mutable) PtrElem(.{ .size = .one }) {
1185 const index = mutable.mutate.len;1185 const index = mutable.mutate.len;
1186 assert(index < mutable.list.header().capacity);1186 assert(index < mutable.list.header().capacity);
1187 mutable.mutate.len = index + 1;1187 mutable.mutate.len = index + 1;
1188 const mutable_view = mutable.view().slice();1188 const mutable_view = mutable.view().slice();
1189 var ptr: PtrElem(.{ .size = .One }) = undefined;1189 var ptr: PtrElem(.{ .size = .one }) = undefined;
1190 inline for (fields) |field| {1190 inline for (fields) |field| {
1191 @field(ptr, @tagName(field)) = &mutable_view.items(field)[index];1191 @field(ptr, @tagName(field)) = &mutable_view.items(field)[index];
1192 }1192 }
...@@ -1206,7 +1206,7 @@ const Local = struct {...@@ -1206,7 +1206,7 @@ const Local = struct {
12061206
1207 pub fn appendSliceAssumeCapacity(1207 pub fn appendSliceAssumeCapacity(
1208 mutable: Mutable,1208 mutable: Mutable,
1209 slice: PtrElem(.{ .size = .Slice, .is_const = true }),1209 slice: PtrElem(.{ .size = .slice, .is_const = true }),
1210 ) void {1210 ) void {
1211 if (fields.len == 0) return;1211 if (fields.len == 0) return;
1212 const start = mutable.mutate.len;1212 const start = mutable.mutate.len;
...@@ -1253,17 +1253,17 @@ const Local = struct {...@@ -1253,17 +1253,17 @@ const Local = struct {
1253 return ptr_array;1253 return ptr_array;
1254 }1254 }
12551255
1256 pub fn addManyAsSlice(mutable: Mutable, len: usize) Allocator.Error!PtrElem(.{ .size = .Slice }) {1256 pub fn addManyAsSlice(mutable: Mutable, len: usize) Allocator.Error!PtrElem(.{ .size = .slice }) {
1257 try mutable.ensureUnusedCapacity(len);1257 try mutable.ensureUnusedCapacity(len);
1258 return mutable.addManyAsSliceAssumeCapacity(len);1258 return mutable.addManyAsSliceAssumeCapacity(len);
1259 }1259 }
12601260
1261 pub fn addManyAsSliceAssumeCapacity(mutable: Mutable, len: usize) PtrElem(.{ .size = .Slice }) {1261 pub fn addManyAsSliceAssumeCapacity(mutable: Mutable, len: usize) PtrElem(.{ .size = .slice }) {
1262 const start = mutable.mutate.len;1262 const start = mutable.mutate.len;
1263 assert(len <= mutable.list.header().capacity - start);1263 assert(len <= mutable.list.header().capacity - start);
1264 mutable.mutate.len = @intCast(start + len);1264 mutable.mutate.len = @intCast(start + len);
1265 const mutable_view = mutable.view().slice();1265 const mutable_view = mutable.view().slice();
1266 var slice: PtrElem(.{ .size = .Slice }) = undefined;1266 var slice: PtrElem(.{ .size = .slice }) = undefined;
1267 inline for (fields) |field| {1267 inline for (fields) |field| {
1268 @field(slice, @tagName(field)) = mutable_view.items(field)[start..][0..len];1268 @field(slice, @tagName(field)) = mutable_view.items(field)[start..][0..len];
1269 }1269 }
...@@ -2060,7 +2060,7 @@ pub const Key = union(enum) {...@@ -2060,7 +2060,7 @@ pub const Key = union(enum) {
2060 };2060 };
20612061
2062 pub const Flags = packed struct(u32) {2062 pub const Flags = packed struct(u32) {
2063 size: Size = .One,2063 size: Size = .one,
2064 /// `none` indicates the ABI alignment of the pointee_type. In this2064 /// `none` indicates the ABI alignment of the pointee_type. In this
2065 /// case, this field *must* be set to `none`, otherwise the2065 /// case, this field *must* be set to `none`, otherwise the
2066 /// `InternPool` equality and hashing functions will return incorrect2066 /// `InternPool` equality and hashing functions will return incorrect
...@@ -4891,7 +4891,7 @@ pub const Index = enum(u32) {...@@ -4891,7 +4891,7 @@ pub const Index = enum(u32) {
4891 checkField(name ++ ".?", info.child);4891 checkField(name ++ ".?", info.child);
4892 },4892 },
4893 .pointer => |info| {4893 .pointer => |info| {
4894 assert(info.size == .Slice);4894 assert(info.size == .slice);
4895 checkConfig(name ++ ".len");4895 checkConfig(name ++ ".len");
4896 checkField(name ++ "[0]", info.child);4896 checkField(name ++ "[0]", info.child);
4897 },4897 },
...@@ -5016,7 +5016,7 @@ pub const static_keys = [_]Key{...@@ -5016,7 +5016,7 @@ pub const static_keys = [_]Key{
5016 .{ .ptr_type = .{5016 .{ .ptr_type = .{
5017 .child = .u8_type,5017 .child = .u8_type,
5018 .flags = .{5018 .flags = .{
5019 .size = .Many,5019 .size = .many,
5020 },5020 },
5021 } },5021 } },
50225022
...@@ -5024,7 +5024,7 @@ pub const static_keys = [_]Key{...@@ -5024,7 +5024,7 @@ pub const static_keys = [_]Key{
5024 .{ .ptr_type = .{5024 .{ .ptr_type = .{
5025 .child = .u8_type,5025 .child = .u8_type,
5026 .flags = .{5026 .flags = .{
5027 .size = .Many,5027 .size = .many,
5028 .is_const = true,5028 .is_const = true,
5029 },5029 },
5030 } },5030 } },
...@@ -5034,7 +5034,7 @@ pub const static_keys = [_]Key{...@@ -5034,7 +5034,7 @@ pub const static_keys = [_]Key{
5034 .child = .u8_type,5034 .child = .u8_type,
5035 .sentinel = .zero_u8,5035 .sentinel = .zero_u8,
5036 .flags = .{5036 .flags = .{
5037 .size = .Many,5037 .size = .many,
5038 .is_const = true,5038 .is_const = true,
5039 },5039 },
5040 } },5040 } },
...@@ -5043,7 +5043,7 @@ pub const static_keys = [_]Key{...@@ -5043,7 +5043,7 @@ pub const static_keys = [_]Key{
5043 .{ .ptr_type = .{5043 .{ .ptr_type = .{
5044 .child = .comptime_int_type,5044 .child = .comptime_int_type,
5045 .flags = .{5045 .flags = .{
5046 .size = .One,5046 .size = .one,
5047 .is_const = true,5047 .is_const = true,
5048 },5048 },
5049 } },5049 } },
...@@ -5052,7 +5052,7 @@ pub const static_keys = [_]Key{...@@ -5052,7 +5052,7 @@ pub const static_keys = [_]Key{
5052 .{ .ptr_type = .{5052 .{ .ptr_type = .{
5053 .child = .u8_type,5053 .child = .u8_type,
5054 .flags = .{5054 .flags = .{
5055 .size = .Slice,5055 .size = .slice,
5056 .is_const = true,5056 .is_const = true,
5057 },5057 },
5058 } },5058 } },
...@@ -5062,7 +5062,7 @@ pub const static_keys = [_]Key{...@@ -5062,7 +5062,7 @@ pub const static_keys = [_]Key{
5062 .child = .u8_type,5062 .child = .u8_type,
5063 .sentinel = .zero_u8,5063 .sentinel = .zero_u8,
5064 .flags = .{5064 .flags = .{
5065 .size = .Slice,5065 .size = .slice,
5066 .is_const = true,5066 .is_const = true,
5067 },5067 },
5068 } },5068 } },
...@@ -6749,7 +6749,7 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key {...@@ -6749,7 +6749,7 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key {
6749 const many_ptr_item = many_ptr_unwrapped.getItem(ip);6749 const many_ptr_item = many_ptr_unwrapped.getItem(ip);
6750 assert(many_ptr_item.tag == .type_pointer);6750 assert(many_ptr_item.tag == .type_pointer);
6751 var ptr_info = extraData(many_ptr_unwrapped.getExtra(ip), Tag.TypePointer, many_ptr_item.data);6751 var ptr_info = extraData(many_ptr_unwrapped.getExtra(ip), Tag.TypePointer, many_ptr_item.data);
6752 ptr_info.flags.size = .Slice;6752 ptr_info.flags.size = .slice;
6753 return .{ .ptr_type = ptr_info };6753 return .{ .ptr_type = ptr_info };
6754 },6754 },
67556755
...@@ -7572,10 +7572,10 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All...@@ -7572,10 +7572,10 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All
7572 assert(ptr_type.child != .none);7572 assert(ptr_type.child != .none);
7573 assert(ptr_type.sentinel == .none or ip.typeOf(ptr_type.sentinel) == ptr_type.child);7573 assert(ptr_type.sentinel == .none or ip.typeOf(ptr_type.sentinel) == ptr_type.child);
75747574
7575 if (ptr_type.flags.size == .Slice) {7575 if (ptr_type.flags.size == .slice) {
7576 gop.cancel();7576 gop.cancel();
7577 var new_key = key;7577 var new_key = key;
7578 new_key.ptr_type.flags.size = .Many;7578 new_key.ptr_type.flags.size = .many;
7579 const ptr_type_index = try ip.get(gpa, tid, new_key);7579 const ptr_type_index = try ip.get(gpa, tid, new_key);
7580 gop = try ip.getOrPutKey(gpa, tid, key);7580 gop = try ip.getOrPutKey(gpa, tid, key);
75817581
...@@ -7588,7 +7588,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All...@@ -7588,7 +7588,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All
7588 }7588 }
75897589
7590 var ptr_type_adjusted = ptr_type;7590 var ptr_type_adjusted = ptr_type;
7591 if (ptr_type.flags.size == .C) ptr_type_adjusted.flags.is_allowzero = true;7591 if (ptr_type.flags.size == .c) ptr_type_adjusted.flags.is_allowzero = true;
75927592
7593 items.appendAssumeCapacity(.{7593 items.appendAssumeCapacity(.{
7594 .tag = .type_pointer,7594 .tag = .type_pointer,
...@@ -7731,8 +7731,8 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All...@@ -7731,8 +7731,8 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All
7731 },7731 },
77327732
7733 .slice => |slice| {7733 .slice => |slice| {
7734 assert(ip.indexToKey(slice.ty).ptr_type.flags.size == .Slice);7734 assert(ip.indexToKey(slice.ty).ptr_type.flags.size == .slice);
7735 assert(ip.indexToKey(ip.typeOf(slice.ptr)).ptr_type.flags.size == .Many);7735 assert(ip.indexToKey(ip.typeOf(slice.ptr)).ptr_type.flags.size == .many);
7736 items.appendAssumeCapacity(.{7736 items.appendAssumeCapacity(.{
7737 .tag = .ptr_slice,7737 .tag = .ptr_slice,
7738 .data = try addExtra(extra, PtrSlice{7738 .data = try addExtra(extra, PtrSlice{
...@@ -7745,7 +7745,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All...@@ -7745,7 +7745,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All
77457745
7746 .ptr => |ptr| {7746 .ptr => |ptr| {
7747 const ptr_type = ip.indexToKey(ptr.ty).ptr_type;7747 const ptr_type = ip.indexToKey(ptr.ty).ptr_type;
7748 assert(ptr_type.flags.size != .Slice);7748 assert(ptr_type.flags.size != .slice);
7749 items.appendAssumeCapacity(switch (ptr.base_addr) {7749 items.appendAssumeCapacity(switch (ptr.base_addr) {
7750 .nav => |nav| .{7750 .nav => |nav| .{
7751 .tag = .ptr_nav,7751 .tag = .ptr_nav,
...@@ -7804,9 +7804,9 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All...@@ -7804,9 +7804,9 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All
7804 .arr_elem, .field => |base_index| {7804 .arr_elem, .field => |base_index| {
7805 const base_ptr_type = ip.indexToKey(ip.typeOf(base_index.base)).ptr_type;7805 const base_ptr_type = ip.indexToKey(ip.typeOf(base_index.base)).ptr_type;
7806 switch (ptr.base_addr) {7806 switch (ptr.base_addr) {
7807 .arr_elem => assert(base_ptr_type.flags.size == .Many),7807 .arr_elem => assert(base_ptr_type.flags.size == .many),
7808 .field => {7808 .field => {
7809 assert(base_ptr_type.flags.size == .One);7809 assert(base_ptr_type.flags.size == .one);
7810 switch (ip.indexToKey(base_ptr_type.child)) {7810 switch (ip.indexToKey(base_ptr_type.child)) {
7811 .tuple_type => |tuple_type| {7811 .tuple_type => |tuple_type| {
7812 assert(ptr.base_addr == .field);7812 assert(ptr.base_addr == .field);
...@@ -7823,7 +7823,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All...@@ -7823,7 +7823,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All
7823 },7823 },
7824 .ptr_type => |slice_type| {7824 .ptr_type => |slice_type| {
7825 assert(ptr.base_addr == .field);7825 assert(ptr.base_addr == .field);
7826 assert(slice_type.flags.size == .Slice);7826 assert(slice_type.flags.size == .slice);
7827 assert(base_index.index < 2);7827 assert(base_index.index < 2);
7828 },7828 },
7829 else => unreachable,7829 else => unreachable,
...@@ -10314,12 +10314,12 @@ pub fn getCoerced(...@@ -10314,12 +10314,12 @@ pub fn getCoerced(
10314 } });10314 } });
1031510315
10316 if (ip.isPointerType(new_ty)) switch (ip.indexToKey(new_ty).ptr_type.flags.size) {10316 if (ip.isPointerType(new_ty)) switch (ip.indexToKey(new_ty).ptr_type.flags.size) {
10317 .One, .Many, .C => return ip.get(gpa, tid, .{ .ptr = .{10317 .one, .many, .c => return ip.get(gpa, tid, .{ .ptr = .{
10318 .ty = new_ty,10318 .ty = new_ty,
10319 .base_addr = .int,10319 .base_addr = .int,
10320 .byte_offset = 0,10320 .byte_offset = 0,
10321 } }),10321 } }),
10322 .Slice => return ip.get(gpa, tid, .{ .slice = .{10322 .slice => return ip.get(gpa, tid, .{ .slice = .{
10323 .ty = new_ty,10323 .ty = new_ty,
10324 .ptr = try ip.get(gpa, tid, .{ .ptr = .{10324 .ptr = try ip.get(gpa, tid, .{ .ptr = .{
10325 .ty = ip.slicePtrType(new_ty),10325 .ty = ip.slicePtrType(new_ty),
...@@ -10408,7 +10408,7 @@ pub fn getCoerced(...@@ -10408,7 +10408,7 @@ pub fn getCoerced(
10408 },10408 },
10409 else => {},10409 else => {},
10410 },10410 },
10411 .slice => |slice| if (ip.isPointerType(new_ty) and ip.indexToKey(new_ty).ptr_type.flags.size == .Slice)10411 .slice => |slice| if (ip.isPointerType(new_ty) and ip.indexToKey(new_ty).ptr_type.flags.size == .slice)
10412 return ip.get(gpa, tid, .{ .slice = .{10412 return ip.get(gpa, tid, .{ .slice = .{
10413 .ty = new_ty,10413 .ty = new_ty,
10414 .ptr = try ip.getCoerced(gpa, tid, slice.ptr, ip.slicePtrType(new_ty)),10414 .ptr = try ip.getCoerced(gpa, tid, slice.ptr, ip.slicePtrType(new_ty)),
...@@ -10416,7 +10416,7 @@ pub fn getCoerced(...@@ -10416,7 +10416,7 @@ pub fn getCoerced(
10416 } })10416 } })
10417 else if (ip.isIntegerType(new_ty))10417 else if (ip.isIntegerType(new_ty))
10418 return ip.getCoerced(gpa, tid, slice.ptr, new_ty),10418 return ip.getCoerced(gpa, tid, slice.ptr, new_ty),
10419 .ptr => |ptr| if (ip.isPointerType(new_ty) and ip.indexToKey(new_ty).ptr_type.flags.size != .Slice)10419 .ptr => |ptr| if (ip.isPointerType(new_ty) and ip.indexToKey(new_ty).ptr_type.flags.size != .slice)
10420 return ip.get(gpa, tid, .{ .ptr = .{10420 return ip.get(gpa, tid, .{ .ptr = .{
10421 .ty = new_ty,10421 .ty = new_ty,
10422 .base_addr = ptr.base_addr,10422 .base_addr = ptr.base_addr,
...@@ -10433,12 +10433,12 @@ pub fn getCoerced(...@@ -10433,12 +10433,12 @@ pub fn getCoerced(
10433 .opt => |opt| switch (ip.indexToKey(new_ty)) {10433 .opt => |opt| switch (ip.indexToKey(new_ty)) {
10434 .ptr_type => |ptr_type| return switch (opt.val) {10434 .ptr_type => |ptr_type| return switch (opt.val) {
10435 .none => switch (ptr_type.flags.size) {10435 .none => switch (ptr_type.flags.size) {
10436 .One, .Many, .C => try ip.get(gpa, tid, .{ .ptr = .{10436 .one, .many, .c => try ip.get(gpa, tid, .{ .ptr = .{
10437 .ty = new_ty,10437 .ty = new_ty,
10438 .base_addr = .int,10438 .base_addr = .int,
10439 .byte_offset = 0,10439 .byte_offset = 0,
10440 } }),10440 } }),
10441 .Slice => try ip.get(gpa, tid, .{ .slice = .{10441 .slice => try ip.get(gpa, tid, .{ .slice = .{
10442 .ty = new_ty,10442 .ty = new_ty,
10443 .ptr = try ip.get(gpa, tid, .{ .ptr = .{10443 .ptr = try ip.get(gpa, tid, .{ .ptr = .{
10444 .ty = ip.slicePtrType(new_ty),10444 .ty = ip.slicePtrType(new_ty),
src/Sema.zig+165-165
...@@ -2479,7 +2479,7 @@ fn typeSupportsFieldAccess(zcu: *const Zcu, ty: Type, field_name: InternPool.Nul...@@ -2479,7 +2479,7 @@ fn typeSupportsFieldAccess(zcu: *const Zcu, ty: Type, field_name: InternPool.Nul
2479 .array => return field_name.eqlSlice("len", ip),2479 .array => return field_name.eqlSlice("len", ip),
2480 .pointer => {2480 .pointer => {
2481 const ptr_info = ty.ptrInfo(zcu);2481 const ptr_info = ty.ptrInfo(zcu);
2482 if (ptr_info.flags.size == .Slice) {2482 if (ptr_info.flags.size == .slice) {
2483 return field_name.eqlSlice("ptr", ip) or field_name.eqlSlice("len", ip);2483 return field_name.eqlSlice("ptr", ip) or field_name.eqlSlice("len", ip);
2484 } else if (Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .array) {2484 } else if (Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .array) {
2485 return field_name.eqlSlice("len", ip);2485 return field_name.eqlSlice("len", ip);
...@@ -3653,7 +3653,7 @@ fn indexablePtrLenOrNone(...@@ -3653,7 +3653,7 @@ fn indexablePtrLenOrNone(
3653 const zcu = pt.zcu;3653 const zcu = pt.zcu;
3654 const operand_ty = sema.typeOf(operand);3654 const operand_ty = sema.typeOf(operand);
3655 try checkMemOperand(sema, block, src, operand_ty);3655 try checkMemOperand(sema, block, src, operand_ty);
3656 if (operand_ty.ptrSize(zcu) == .Many) return .none;3656 if (operand_ty.ptrSize(zcu) == .many) return .none;
3657 const field_name = try zcu.intern_pool.getOrPutString(sema.gpa, pt.tid, "len", .no_embedded_nulls);3657 const field_name = try zcu.intern_pool.getOrPutString(sema.gpa, pt.tid, "len", .no_embedded_nulls);
3658 return sema.fieldVal(block, src, operand, field_name, src);3658 return sema.fieldVal(block, src, operand, field_name, src);
3659}3659}
...@@ -4544,7 +4544,7 @@ fn zirCoercePtrElemTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE...@@ -4544,7 +4544,7 @@ fn zirCoercePtrElemTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE
4544 assert(ptr_ty.zigTypeTag(zcu) == .pointer); // validated by a previous instruction4544 assert(ptr_ty.zigTypeTag(zcu) == .pointer); // validated by a previous instruction
4545 const elem_ty = ptr_ty.childType(zcu);4545 const elem_ty = ptr_ty.childType(zcu);
4546 switch (ptr_ty.ptrSize(zcu)) {4546 switch (ptr_ty.ptrSize(zcu)) {
4547 .One => {4547 .one => {
4548 const uncoerced_ty = sema.typeOf(uncoerced_val);4548 const uncoerced_ty = sema.typeOf(uncoerced_val);
4549 if (elem_ty.zigTypeTag(zcu) == .array and elem_ty.childType(zcu).toIntern() == uncoerced_ty.toIntern()) {4549 if (elem_ty.zigTypeTag(zcu) == .array and elem_ty.childType(zcu).toIntern() == uncoerced_ty.toIntern()) {
4550 // We're trying to initialize a *[1]T with a reference to a T - don't perform any coercion.4550 // We're trying to initialize a *[1]T with a reference to a T - don't perform any coercion.
...@@ -4557,7 +4557,7 @@ fn zirCoercePtrElemTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE...@@ -4557,7 +4557,7 @@ fn zirCoercePtrElemTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE
4557 return sema.coerce(block, elem_ty, uncoerced_val, src);4557 return sema.coerce(block, elem_ty, uncoerced_val, src);
4558 }4558 }
4559 },4559 },
4560 .Slice, .Many => {4560 .slice, .many => {
4561 // Our goal is to coerce `uncoerced_val` to an array of `elem_ty`.4561 // Our goal is to coerce `uncoerced_val` to an array of `elem_ty`.
4562 const val_ty = sema.typeOf(uncoerced_val);4562 const val_ty = sema.typeOf(uncoerced_val);
4563 switch (val_ty.zigTypeTag(zcu)) {4563 switch (val_ty.zigTypeTag(zcu)) {
...@@ -4573,7 +4573,7 @@ fn zirCoercePtrElemTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE...@@ -4573,7 +4573,7 @@ fn zirCoercePtrElemTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE
4573 });4573 });
4574 return sema.coerce(block, want_ty, uncoerced_val, src);4574 return sema.coerce(block, want_ty, uncoerced_val, src);
4575 },4575 },
4576 .C => {4576 .c => {
4577 // There's nothing meaningful to do here, because we don't know if this is meant to be a4577 // There's nothing meaningful to do here, because we don't know if this is meant to be a
4578 // single-pointer or a many-pointer.4578 // single-pointer or a many-pointer.
4579 return uncoerced_val;4579 return uncoerced_val;
...@@ -4685,7 +4685,7 @@ fn zirValidateArrayInitRefTy(...@@ -4685,7 +4685,7 @@ fn zirValidateArrayInitRefTy(
4685 assert(ptr_ty.zigTypeTag(zcu) == .pointer); // validated by a previous instruction4685 assert(ptr_ty.zigTypeTag(zcu) == .pointer); // validated by a previous instruction
4686 switch (zcu.intern_pool.indexToKey(ptr_ty.toIntern())) {4686 switch (zcu.intern_pool.indexToKey(ptr_ty.toIntern())) {
4687 .ptr_type => |ptr_type| switch (ptr_type.flags.size) {4687 .ptr_type => |ptr_type| switch (ptr_type.flags.size) {
4688 .Slice, .Many => {4688 .slice, .many => {
4689 // Use array of correct length4689 // Use array of correct length
4690 const arr_ty = try pt.arrayType(.{4690 const arr_ty = try pt.arrayType(.{
4691 .len = extra.elem_count,4691 .len = extra.elem_count,
...@@ -5502,9 +5502,9 @@ fn zirValidateDeref(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr...@@ -5502,9 +5502,9 @@ fn zirValidateDeref(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr
5502 if (operand_ty.zigTypeTag(zcu) != .pointer) {5502 if (operand_ty.zigTypeTag(zcu) != .pointer) {
5503 return sema.fail(block, src, "cannot dereference non-pointer type '{}'", .{operand_ty.fmt(pt)});5503 return sema.fail(block, src, "cannot dereference non-pointer type '{}'", .{operand_ty.fmt(pt)});
5504 } else switch (operand_ty.ptrSize(zcu)) {5504 } else switch (operand_ty.ptrSize(zcu)) {
5505 .One, .C => {},5505 .one, .c => {},
5506 .Many => return sema.fail(block, src, "index syntax required for unknown-length pointer type '{}'", .{operand_ty.fmt(pt)}),5506 .many => return sema.fail(block, src, "index syntax required for unknown-length pointer type '{}'", .{operand_ty.fmt(pt)}),
5507 .Slice => return sema.fail(block, src, "index syntax required for slice type '{}'", .{operand_ty.fmt(pt)}),5507 .slice => return sema.fail(block, src, "index syntax required for slice type '{}'", .{operand_ty.fmt(pt)}),
5508 }5508 }
55095509
5510 if ((try sema.typeHasOnePossibleValue(operand_ty.childType(zcu))) != null) {5510 if ((try sema.typeHasOnePossibleValue(operand_ty.childType(zcu))) != null) {
...@@ -6521,7 +6521,7 @@ fn zirExport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void...@@ -6521,7 +6521,7 @@ fn zirExport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void
6521 return sema.fail(block, ptr_src, "expected pointer type, found '{}'", .{ptr_ty.fmt(pt)});6521 return sema.fail(block, ptr_src, "expected pointer type, found '{}'", .{ptr_ty.fmt(pt)});
6522 }6522 }
6523 const ptr_ty_info = ptr_ty.ptrInfo(zcu);6523 const ptr_ty_info = ptr_ty.ptrInfo(zcu);
6524 if (ptr_ty_info.flags.size == .Slice) {6524 if (ptr_ty_info.flags.size == .slice) {
6525 return sema.fail(block, ptr_src, "export target cannot be slice", .{});6525 return sema.fail(block, ptr_src, "export target cannot be slice", .{});
6526 }6526 }
6527 if (ptr_ty_info.packed_offset.host_size != 0) {6527 if (ptr_ty_info.packed_offset.host_size != 0) {
...@@ -7271,7 +7271,7 @@ fn checkCallArgumentCount(...@@ -7271,7 +7271,7 @@ fn checkCallArgumentCount(
7271 .@"fn" => break :func_ty callee_ty,7271 .@"fn" => break :func_ty callee_ty,
7272 .pointer => {7272 .pointer => {
7273 const ptr_info = callee_ty.ptrInfo(zcu);7273 const ptr_info = callee_ty.ptrInfo(zcu);
7274 if (ptr_info.flags.size == .One and Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .@"fn") {7274 if (ptr_info.flags.size == .one and Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .@"fn") {
7275 break :func_ty Type.fromInterned(ptr_info.child);7275 break :func_ty Type.fromInterned(ptr_info.child);
7276 }7276 }
7277 },7277 },
...@@ -7350,7 +7350,7 @@ fn callBuiltin(...@@ -7350,7 +7350,7 @@ fn callBuiltin(
7350 .@"fn" => break :func_ty callee_ty,7350 .@"fn" => break :func_ty callee_ty,
7351 .pointer => {7351 .pointer => {
7352 const ptr_info = callee_ty.ptrInfo(zcu);7352 const ptr_info = callee_ty.ptrInfo(zcu);
7353 if (ptr_info.flags.size == .One and Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .@"fn") {7353 if (ptr_info.flags.size == .one and Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .@"fn") {
7354 break :func_ty Type.fromInterned(ptr_info.child);7354 break :func_ty Type.fromInterned(ptr_info.child);
7355 }7355 }
7356 },7356 },
...@@ -8344,8 +8344,8 @@ fn zirIndexablePtrElemType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com...@@ -8344,8 +8344,8 @@ fn zirIndexablePtrElemType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com
8344 };8344 };
8345 try sema.checkMemOperand(block, src, ptr_ty);8345 try sema.checkMemOperand(block, src, ptr_ty);
8346 const elem_ty = switch (ptr_ty.ptrSize(zcu)) {8346 const elem_ty = switch (ptr_ty.ptrSize(zcu)) {
8347 .Slice, .Many, .C => ptr_ty.childType(zcu),8347 .slice, .many, .c => ptr_ty.childType(zcu),
8348 .One => ptr_ty.childType(zcu).childType(zcu),8348 .one => ptr_ty.childType(zcu).childType(zcu),
8349 };8349 };
8350 return Air.internedToRef(elem_ty.toIntern());8350 return Air.internedToRef(elem_ty.toIntern());
8351}8351}
...@@ -8943,7 +8943,7 @@ fn zirOptionalPayload(...@@ -8943,7 +8943,7 @@ fn zirOptionalPayload(
8943 const result_ty = switch (operand_ty.zigTypeTag(zcu)) {8943 const result_ty = switch (operand_ty.zigTypeTag(zcu)) {
8944 .optional => operand_ty.optionalChild(zcu),8944 .optional => operand_ty.optionalChild(zcu),
8945 .pointer => t: {8945 .pointer => t: {
8946 if (operand_ty.ptrSize(zcu) != .C) {8946 if (operand_ty.ptrSize(zcu) != .c) {
8947 return sema.failWithExpectedOptionalType(block, src, operand_ty);8947 return sema.failWithExpectedOptionalType(block, src, operand_ty);
8948 }8948 }
8949 // TODO https://github.com/ziglang/zig/issues/65978949 // TODO https://github.com/ziglang/zig/issues/6597
...@@ -13972,7 +13972,7 @@ fn zirHasField(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -13972,7 +13972,7 @@ fn zirHasField(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
13972 const has_field = hf: {13972 const has_field = hf: {
13973 switch (ip.indexToKey(ty.toIntern())) {13973 switch (ip.indexToKey(ty.toIntern())) {
13974 .ptr_type => |ptr_type| switch (ptr_type.flags.size) {13974 .ptr_type => |ptr_type| switch (ptr_type.flags.size) {
13975 .Slice => {13975 .slice => {
13976 if (field_name.eqlSlice("ptr", ip)) break :hf true;13976 if (field_name.eqlSlice("ptr", ip)) break :hf true;
13977 if (field_name.eqlSlice("len", ip)) break :hf true;13977 if (field_name.eqlSlice("len", ip)) break :hf true;
13978 break :hf false;13978 break :hf false;
...@@ -14797,7 +14797,7 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -14797,7 +14797,7 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
14797 const slice_ty = try pt.ptrTypeSema(.{14797 const slice_ty = try pt.ptrTypeSema(.{
14798 .child = resolved_elem_ty.toIntern(),14798 .child = resolved_elem_ty.toIntern(),
14799 .flags = .{14799 .flags = .{
14800 .size = .Slice,14800 .size = .slice,
14801 .address_space = ptr_as,14801 .address_space = ptr_as,
14802 },14802 },
14803 });14803 });
...@@ -14925,7 +14925,7 @@ fn getArrayCatInfo(sema: *Sema, block: *Block, src: LazySrcLoc, operand: Air.Ins...@@ -14925,7 +14925,7 @@ fn getArrayCatInfo(sema: *Sema, block: *Block, src: LazySrcLoc, operand: Air.Ins
14925 .pointer => {14925 .pointer => {
14926 const ptr_info = operand_ty.ptrInfo(zcu);14926 const ptr_info = operand_ty.ptrInfo(zcu);
14927 switch (ptr_info.flags.size) {14927 switch (ptr_info.flags.size) {
14928 .Slice => {14928 .slice => {
14929 const val = try sema.resolveConstDefinedValue(block, src, operand, .{ .simple = .slice_cat_operand });14929 const val = try sema.resolveConstDefinedValue(block, src, operand, .{ .simple = .slice_cat_operand });
14930 return Type.ArrayInfo{14930 return Type.ArrayInfo{
14931 .elem_type = Type.fromInterned(ptr_info.child),14931 .elem_type = Type.fromInterned(ptr_info.child),
...@@ -14936,12 +14936,12 @@ fn getArrayCatInfo(sema: *Sema, block: *Block, src: LazySrcLoc, operand: Air.Ins...@@ -14936,12 +14936,12 @@ fn getArrayCatInfo(sema: *Sema, block: *Block, src: LazySrcLoc, operand: Air.Ins
14936 .len = try val.sliceLen(pt),14936 .len = try val.sliceLen(pt),
14937 };14937 };
14938 },14938 },
14939 .One => {14939 .one => {
14940 if (Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .array) {14940 if (Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .array) {
14941 return Type.fromInterned(ptr_info.child).arrayInfo(zcu);14941 return Type.fromInterned(ptr_info.child).arrayInfo(zcu);
14942 }14942 }
14943 },14943 },
14944 .C, .Many => {},14944 .c, .many => {},
14945 }14945 }
14946 },14946 },
14947 .@"struct" => {14947 .@"struct" => {
...@@ -16610,7 +16610,7 @@ fn analyzeArithmetic(...@@ -16610,7 +16610,7 @@ fn analyzeArithmetic(
1661016610
16611 if (lhs_zig_ty_tag == .pointer) {16611 if (lhs_zig_ty_tag == .pointer) {
16612 if (rhs_zig_ty_tag == .pointer) {16612 if (rhs_zig_ty_tag == .pointer) {
16613 if (lhs_ty.ptrSize(zcu) != .Slice and rhs_ty.ptrSize(zcu) != .Slice) {16613 if (lhs_ty.ptrSize(zcu) != .slice and rhs_ty.ptrSize(zcu) != .slice) {
16614 if (zir_tag != .sub) {16614 if (zir_tag != .sub) {
16615 return sema.failWithInvalidPtrArithmetic(block, src, "pointer-pointer", "subtraction");16615 return sema.failWithInvalidPtrArithmetic(block, src, "pointer-pointer", "subtraction");
16616 }16616 }
...@@ -16662,8 +16662,8 @@ fn analyzeArithmetic(...@@ -16662,8 +16662,8 @@ fn analyzeArithmetic(
16662 }16662 }
16663 } else {16663 } else {
16664 switch (lhs_ty.ptrSize(zcu)) {16664 switch (lhs_ty.ptrSize(zcu)) {
16665 .One, .Slice => {},16665 .one, .slice => {},
16666 .Many, .C => {16666 .many, .c => {
16667 const air_tag: Air.Inst.Tag = switch (zir_tag) {16667 const air_tag: Air.Inst.Tag = switch (zir_tag) {
16668 .add => .ptr_add,16668 .add => .ptr_add,
16669 .sub => .ptr_sub,16669 .sub => .ptr_sub,
...@@ -17160,7 +17160,7 @@ fn analyzePtrArithmetic(...@@ -17160,7 +17160,7 @@ fn analyzePtrArithmetic(
17160 const opt_off_val = try sema.resolveDefinedValue(block, offset_src, offset);17160 const opt_off_val = try sema.resolveDefinedValue(block, offset_src, offset);
17161 const ptr_ty = sema.typeOf(ptr);17161 const ptr_ty = sema.typeOf(ptr);
17162 const ptr_info = ptr_ty.ptrInfo(zcu);17162 const ptr_info = ptr_ty.ptrInfo(zcu);
17163 assert(ptr_info.flags.size == .Many or ptr_info.flags.size == .C);17163 assert(ptr_info.flags.size == .many or ptr_info.flags.size == .c);
1716417164
17165 const new_ptr_ty = t: {17165 const new_ptr_ty = t: {
17166 // Calculate the new pointer alignment.17166 // Calculate the new pointer alignment.
...@@ -18092,7 +18092,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -18092,7 +18092,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
18092 const slice_ty = (try pt.ptrTypeSema(.{18092 const slice_ty = (try pt.ptrTypeSema(.{
18093 .child = param_info_ty.toIntern(),18093 .child = param_info_ty.toIntern(),
18094 .flags = .{18094 .flags = .{
18095 .size = .Slice,18095 .size = .slice,
18096 .is_const = true,18096 .is_const = true,
18097 },18097 },
18098 })).toIntern();18098 })).toIntern();
...@@ -18335,7 +18335,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -18335,7 +18335,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
18335 const slice_errors_ty = try pt.ptrTypeSema(.{18335 const slice_errors_ty = try pt.ptrTypeSema(.{
18336 .child = error_field_ty.toIntern(),18336 .child = error_field_ty.toIntern(),
18337 .flags = .{18337 .flags = .{
18338 .size = .Slice,18338 .size = .slice,
18339 .is_const = true,18339 .is_const = true,
18340 },18340 },
18341 });18341 });
...@@ -18462,7 +18462,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -18462,7 +18462,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
18462 const slice_ty = (try pt.ptrTypeSema(.{18462 const slice_ty = (try pt.ptrTypeSema(.{
18463 .child = enum_field_ty.toIntern(),18463 .child = enum_field_ty.toIntern(),
18464 .flags = .{18464 .flags = .{
18465 .size = .Slice,18465 .size = .slice,
18466 .is_const = true,18466 .is_const = true,
18467 },18467 },
18468 })).toIntern();18468 })).toIntern();
...@@ -18575,7 +18575,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -18575,7 +18575,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
18575 const slice_ty = (try pt.ptrTypeSema(.{18575 const slice_ty = (try pt.ptrTypeSema(.{
18576 .child = union_field_ty.toIntern(),18576 .child = union_field_ty.toIntern(),
18577 .flags = .{18577 .flags = .{
18578 .size = .Slice,18578 .size = .slice,
18579 .is_const = true,18579 .is_const = true,
18580 },18580 },
18581 })).toIntern();18581 })).toIntern();
...@@ -18770,7 +18770,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -18770,7 +18770,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
18770 const slice_ty = (try pt.ptrTypeSema(.{18770 const slice_ty = (try pt.ptrTypeSema(.{
18771 .child = struct_field_ty.toIntern(),18771 .child = struct_field_ty.toIntern(),
18772 .flags = .{18772 .flags = .{
18773 .size = .Slice,18773 .size = .slice,
18774 .is_const = true,18774 .is_const = true,
18775 },18775 },
18776 })).toIntern();18776 })).toIntern();
...@@ -18879,7 +18879,7 @@ fn typeInfoDecls(...@@ -18879,7 +18879,7 @@ fn typeInfoDecls(
18879 const slice_ty = (try pt.ptrTypeSema(.{18879 const slice_ty = (try pt.ptrTypeSema(.{
18880 .child = declaration_ty.toIntern(),18880 .child = declaration_ty.toIntern(),
18881 .flags = .{18881 .flags = .{
18882 .size = .Slice,18882 .size = .slice,
18883 .is_const = true,18883 .is_const = true,
18884 },18884 },
18885 })).toIntern();18885 })).toIntern();
...@@ -20138,12 +20138,12 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -20138,12 +20138,12 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
20138 }20138 }
2013920139
20140 if (elem_ty.zigTypeTag(zcu) == .@"fn") {20140 if (elem_ty.zigTypeTag(zcu) == .@"fn") {
20141 if (inst_data.size != .One) {20141 if (inst_data.size != .one) {
20142 return sema.fail(block, elem_ty_src, "function pointers must be single pointers", .{});20142 return sema.fail(block, elem_ty_src, "function pointers must be single pointers", .{});
20143 }20143 }
20144 } else if (inst_data.size == .Many and elem_ty.zigTypeTag(zcu) == .@"opaque") {20144 } else if (inst_data.size == .many and elem_ty.zigTypeTag(zcu) == .@"opaque") {
20145 return sema.fail(block, elem_ty_src, "unknown-length pointer to opaque not allowed", .{});20145 return sema.fail(block, elem_ty_src, "unknown-length pointer to opaque not allowed", .{});
20146 } else if (inst_data.size == .C) {20146 } else if (inst_data.size == .c) {
20147 if (!try sema.validateExternType(elem_ty, .other)) {20147 if (!try sema.validateExternType(elem_ty, .other)) {
20148 const msg = msg: {20148 const msg = msg: {
20149 const msg = try sema.errMsg(elem_ty_src, "C pointers cannot point to non-C-ABI-compatible type '{}'", .{elem_ty.fmt(pt)});20149 const msg = try sema.errMsg(elem_ty_src, "C pointers cannot point to non-C-ABI-compatible type '{}'", .{elem_ty.fmt(pt)});
...@@ -21645,7 +21645,7 @@ fn zirReify(...@@ -21645,7 +21645,7 @@ fn zirReify(
2164521645
21646 const actual_sentinel: InternPool.Index = s: {21646 const actual_sentinel: InternPool.Index = s: {
21647 if (!sentinel_val.isNull(zcu)) {21647 if (!sentinel_val.isNull(zcu)) {
21648 if (ptr_size == .One or ptr_size == .C) {21648 if (ptr_size == .one or ptr_size == .c) {
21649 return sema.fail(block, src, "sentinels are only allowed on slices and unknown-length pointers", .{});21649 return sema.fail(block, src, "sentinels are only allowed on slices and unknown-length pointers", .{});
21650 }21650 }
21651 const sentinel_ptr_val = sentinel_val.optionalValue(zcu).?;21651 const sentinel_ptr_val = sentinel_val.optionalValue(zcu).?;
...@@ -21660,12 +21660,12 @@ fn zirReify(...@@ -21660,12 +21660,12 @@ fn zirReify(
21660 if (elem_ty.zigTypeTag(zcu) == .noreturn) {21660 if (elem_ty.zigTypeTag(zcu) == .noreturn) {
21661 return sema.fail(block, src, "pointer to noreturn not allowed", .{});21661 return sema.fail(block, src, "pointer to noreturn not allowed", .{});
21662 } else if (elem_ty.zigTypeTag(zcu) == .@"fn") {21662 } else if (elem_ty.zigTypeTag(zcu) == .@"fn") {
21663 if (ptr_size != .One) {21663 if (ptr_size != .one) {
21664 return sema.fail(block, src, "function pointers must be single pointers", .{});21664 return sema.fail(block, src, "function pointers must be single pointers", .{});
21665 }21665 }
21666 } else if (ptr_size == .Many and elem_ty.zigTypeTag(zcu) == .@"opaque") {21666 } else if (ptr_size == .many and elem_ty.zigTypeTag(zcu) == .@"opaque") {
21667 return sema.fail(block, src, "unknown-length pointer to opaque not allowed", .{});21667 return sema.fail(block, src, "unknown-length pointer to opaque not allowed", .{});
21668 } else if (ptr_size == .C) {21668 } else if (ptr_size == .c) {
21669 if (!try sema.validateExternType(elem_ty, .other)) {21669 if (!try sema.validateExternType(elem_ty, .other)) {
21670 const msg = msg: {21670 const msg = msg: {
21671 const msg = try sema.errMsg(src, "C pointers cannot point to non-C-ABI-compatible type '{}'", .{elem_ty.fmt(pt)});21671 const msg = try sema.errMsg(src, "C pointers cannot point to non-C-ABI-compatible type '{}'", .{elem_ty.fmt(pt)});
...@@ -23321,21 +23321,21 @@ fn ptrCastFull(...@@ -23321,21 +23321,21 @@ fn ptrCastFull(
23321 try Type.fromInterned(src_info.child).resolveLayout(pt);23321 try Type.fromInterned(src_info.child).resolveLayout(pt);
23322 try Type.fromInterned(dest_info.child).resolveLayout(pt);23322 try Type.fromInterned(dest_info.child).resolveLayout(pt);
2332323323
23324 const src_slice_like = src_info.flags.size == .Slice or23324 const src_slice_like = src_info.flags.size == .slice or
23325 (src_info.flags.size == .One and Type.fromInterned(src_info.child).zigTypeTag(zcu) == .array);23325 (src_info.flags.size == .one and Type.fromInterned(src_info.child).zigTypeTag(zcu) == .array);
2332623326
23327 const dest_slice_like = dest_info.flags.size == .Slice or23327 const dest_slice_like = dest_info.flags.size == .slice or
23328 (dest_info.flags.size == .One and Type.fromInterned(dest_info.child).zigTypeTag(zcu) == .array);23328 (dest_info.flags.size == .one and Type.fromInterned(dest_info.child).zigTypeTag(zcu) == .array);
2332923329
23330 if (dest_info.flags.size == .Slice and !src_slice_like) {23330 if (dest_info.flags.size == .slice and !src_slice_like) {
23331 return sema.fail(block, src, "illegal pointer cast to slice", .{});23331 return sema.fail(block, src, "illegal pointer cast to slice", .{});
23332 }23332 }
2333323333
23334 if (dest_info.flags.size == .Slice) {23334 if (dest_info.flags.size == .slice) {
23335 const src_elem_size = switch (src_info.flags.size) {23335 const src_elem_size = switch (src_info.flags.size) {
23336 .Slice => Type.fromInterned(src_info.child).abiSize(zcu),23336 .slice => Type.fromInterned(src_info.child).abiSize(zcu),
23337 // pointer to array23337 // pointer to array
23338 .One => Type.fromInterned(src_info.child).childType(zcu).abiSize(zcu),23338 .one => Type.fromInterned(src_info.child).childType(zcu).abiSize(zcu),
23339 else => unreachable,23339 else => unreachable,
23340 };23340 };
23341 const dest_elem_size = Type.fromInterned(dest_info.child).abiSize(zcu);23341 const dest_elem_size = Type.fromInterned(dest_info.child).abiSize(zcu);
...@@ -23350,17 +23350,17 @@ fn ptrCastFull(...@@ -23350,17 +23350,17 @@ fn ptrCastFull(
23350 check_size: {23350 check_size: {
23351 if (src_info.flags.size == dest_info.flags.size) break :check_size;23351 if (src_info.flags.size == dest_info.flags.size) break :check_size;
23352 if (src_slice_like and dest_slice_like) break :check_size;23352 if (src_slice_like and dest_slice_like) break :check_size;
23353 if (src_info.flags.size == .C) break :check_size;23353 if (src_info.flags.size == .c) break :check_size;
23354 if (dest_info.flags.size == .C) break :check_size;23354 if (dest_info.flags.size == .c) break :check_size;
23355 return sema.failWithOwnedErrorMsg(block, msg: {23355 return sema.failWithOwnedErrorMsg(block, msg: {
23356 const msg = try sema.errMsg(src, "cannot implicitly convert {s} to {s}", .{23356 const msg = try sema.errMsg(src, "cannot implicitly convert {s} to {s}", .{
23357 pointerSizeString(src_info.flags.size),23357 pointerSizeString(src_info.flags.size),
23358 pointerSizeString(dest_info.flags.size),23358 pointerSizeString(dest_info.flags.size),
23359 });23359 });
23360 errdefer msg.destroy(sema.gpa);23360 errdefer msg.destroy(sema.gpa);
23361 if (dest_info.flags.size == .Many and23361 if (dest_info.flags.size == .many and
23362 (src_info.flags.size == .Slice or23362 (src_info.flags.size == .slice or
23363 (src_info.flags.size == .One and Type.fromInterned(src_info.child).zigTypeTag(zcu) == .array)))23363 (src_info.flags.size == .one and Type.fromInterned(src_info.child).zigTypeTag(zcu) == .array)))
23364 {23364 {
23365 try sema.errNote(src, msg, "use 'ptr' field to convert slice to many pointer", .{});23365 try sema.errNote(src, msg, "use 'ptr' field to convert slice to many pointer", .{});
23366 } else {23366 } else {
...@@ -23371,7 +23371,7 @@ fn ptrCastFull(...@@ -23371,7 +23371,7 @@ fn ptrCastFull(
23371 }23371 }
2337223372
23373 check_child: {23373 check_child: {
23374 const src_child = if (dest_info.flags.size == .Slice and src_info.flags.size == .One) blk: {23374 const src_child = if (dest_info.flags.size == .slice and src_info.flags.size == .one) blk: {
23375 // *[n]T -> []T23375 // *[n]T -> []T
23376 break :blk Type.fromInterned(src_info.child).childType(zcu);23376 break :blk Type.fromInterned(src_info.child).childType(zcu);
23377 } else Type.fromInterned(src_info.child);23377 } else Type.fromInterned(src_info.child);
...@@ -23402,12 +23402,12 @@ fn ptrCastFull(...@@ -23402,12 +23402,12 @@ fn ptrCastFull(
2340223402
23403 check_sent: {23403 check_sent: {
23404 if (dest_info.sentinel == .none) break :check_sent;23404 if (dest_info.sentinel == .none) break :check_sent;
23405 if (src_info.flags.size == .C) break :check_sent;23405 if (src_info.flags.size == .c) break :check_sent;
23406 if (src_info.sentinel != .none) {23406 if (src_info.sentinel != .none) {
23407 const coerced_sent = try zcu.intern_pool.getCoerced(sema.gpa, pt.tid, src_info.sentinel, dest_info.child);23407 const coerced_sent = try zcu.intern_pool.getCoerced(sema.gpa, pt.tid, src_info.sentinel, dest_info.child);
23408 if (dest_info.sentinel == coerced_sent) break :check_sent;23408 if (dest_info.sentinel == coerced_sent) break :check_sent;
23409 }23409 }
23410 if (src_slice_like and src_info.flags.size == .One and dest_info.flags.size == .Slice) {23410 if (src_slice_like and src_info.flags.size == .one and dest_info.flags.size == .slice) {
23411 // [*]nT -> []T23411 // [*]nT -> []T
23412 const arr_ty = Type.fromInterned(src_info.child);23412 const arr_ty = Type.fromInterned(src_info.child);
23413 if (arr_ty.sentinel(zcu)) |src_sentinel| {23413 if (arr_ty.sentinel(zcu)) |src_sentinel| {
...@@ -23555,7 +23555,7 @@ fn ptrCastFull(...@@ -23555,7 +23555,7 @@ fn ptrCastFull(
23555 }23555 }
23556 }23556 }
2355723557
23558 const ptr = if (src_info.flags.size == .Slice and dest_info.flags.size != .Slice) ptr: {23558 const ptr = if (src_info.flags.size == .slice and dest_info.flags.size != .slice) ptr: {
23559 if (operand_ty.zigTypeTag(zcu) == .optional) {23559 if (operand_ty.zigTypeTag(zcu) == .optional) {
23560 break :ptr try sema.analyzeOptionalSlicePtr(block, operand_src, operand, operand_ty);23560 break :ptr try sema.analyzeOptionalSlicePtr(block, operand_src, operand, operand_ty);
23561 } else {23561 } else {
...@@ -23563,10 +23563,10 @@ fn ptrCastFull(...@@ -23563,10 +23563,10 @@ fn ptrCastFull(
23563 }23563 }
23564 } else operand;23564 } else operand;
2356523565
23566 const dest_ptr_ty = if (dest_info.flags.size == .Slice and src_info.flags.size != .Slice) blk: {23566 const dest_ptr_ty = if (dest_info.flags.size == .slice and src_info.flags.size != .slice) blk: {
23567 // Only convert to a many-pointer at first23567 // Only convert to a many-pointer at first
23568 var info = dest_info;23568 var info = dest_info;
23569 info.flags.size = .Many;23569 info.flags.size = .many;
23570 const ty = try pt.ptrTypeSema(info);23570 const ty = try pt.ptrTypeSema(info);
23571 if (dest_ty.zigTypeTag(zcu) == .optional) {23571 if (dest_ty.zigTypeTag(zcu) == .optional) {
23572 break :blk try pt.optionalType(ty.toIntern());23572 break :blk try pt.optionalType(ty.toIntern());
...@@ -23594,7 +23594,7 @@ fn ptrCastFull(...@@ -23594,7 +23594,7 @@ fn ptrCastFull(
23594 }23594 }
23595 }23595 }
23596 }23596 }
23597 if (dest_info.flags.size == .Slice and src_info.flags.size != .Slice) {23597 if (dest_info.flags.size == .slice and src_info.flags.size != .slice) {
23598 if (ptr_val.isUndef(zcu)) return pt.undefRef(dest_ty);23598 if (ptr_val.isUndef(zcu)) return pt.undefRef(dest_ty);
23599 const arr_len = try pt.intValue(Type.usize, Type.fromInterned(src_info.child).arrayLen(zcu));23599 const arr_len = try pt.intValue(Type.usize, Type.fromInterned(src_info.child).arrayLen(zcu));
23600 const ptr_val_key = zcu.intern_pool.indexToKey(ptr_val.toIntern()).ptr;23600 const ptr_val_key = zcu.intern_pool.indexToKey(ptr_val.toIntern()).ptr;
...@@ -23622,7 +23622,7 @@ fn ptrCastFull(...@@ -23622,7 +23622,7 @@ fn ptrCastFull(
23622 {23622 {
23623 const ptr_int = try block.addUnOp(.int_from_ptr, ptr);23623 const ptr_int = try block.addUnOp(.int_from_ptr, ptr);
23624 const is_non_zero = try block.addBinOp(.cmp_neq, ptr_int, .zero_usize);23624 const is_non_zero = try block.addBinOp(.cmp_neq, ptr_int, .zero_usize);
23625 const ok = if (src_info.flags.size == .Slice and dest_info.flags.size == .Slice) ok: {23625 const ok = if (src_info.flags.size == .slice and dest_info.flags.size == .slice) ok: {
23626 const len = try sema.analyzeSliceLen(block, operand_src, ptr);23626 const len = try sema.analyzeSliceLen(block, operand_src, ptr);
23627 const len_zero = try block.addBinOp(.cmp_eq, len, .zero_usize);23627 const len_zero = try block.addBinOp(.cmp_eq, len, .zero_usize);
23628 break :ok try block.addBinOp(.bool_or, len_zero, is_non_zero);23628 break :ok try block.addBinOp(.bool_or, len_zero, is_non_zero);
...@@ -23639,7 +23639,7 @@ fn ptrCastFull(...@@ -23639,7 +23639,7 @@ fn ptrCastFull(
23639 const ptr_int = try block.addUnOp(.int_from_ptr, ptr);23639 const ptr_int = try block.addUnOp(.int_from_ptr, ptr);
23640 const remainder = try block.addBinOp(.bit_and, ptr_int, align_minus_1);23640 const remainder = try block.addBinOp(.bit_and, ptr_int, align_minus_1);
23641 const is_aligned = try block.addBinOp(.cmp_eq, remainder, .zero_usize);23641 const is_aligned = try block.addBinOp(.cmp_eq, remainder, .zero_usize);
23642 const ok = if (src_info.flags.size == .Slice and dest_info.flags.size == .Slice) ok: {23642 const ok = if (src_info.flags.size == .slice and dest_info.flags.size == .slice) ok: {
23643 const len = try sema.analyzeSliceLen(block, operand_src, ptr);23643 const len = try sema.analyzeSliceLen(block, operand_src, ptr);
23644 const len_zero = try block.addBinOp(.cmp_eq, len, .zero_usize);23644 const len_zero = try block.addBinOp(.cmp_eq, len, .zero_usize);
23645 break :ok try block.addBinOp(.bool_or, len_zero, is_aligned);23645 break :ok try block.addBinOp(.bool_or, len_zero, is_aligned);
...@@ -23672,7 +23672,7 @@ fn ptrCastFull(...@@ -23672,7 +23672,7 @@ fn ptrCastFull(
23672 break :ptr try block.addBitCast(dest_ptr_ty, ptr);23672 break :ptr try block.addBitCast(dest_ptr_ty, ptr);
23673 };23673 };
2367423674
23675 if (dest_info.flags.size == .Slice and src_info.flags.size != .Slice) {23675 if (dest_info.flags.size == .slice and src_info.flags.size != .slice) {
23676 // We have to construct a slice using the operand's child's array length23676 // We have to construct a slice using the operand's child's array length
23677 // Note that we know from the check at the start of the function that operand_ty is slice-like23677 // Note that we know from the check at the start of the function that operand_ty is slice-like
23678 const arr_len = Air.internedToRef((try pt.intValue(Type.usize, Type.fromInterned(src_info.child).arrayLen(zcu))).toIntern());23678 const arr_len = Air.internedToRef((try pt.intValue(Type.usize, Type.fromInterned(src_info.child).arrayLen(zcu))).toIntern());
...@@ -24066,8 +24066,8 @@ fn checkInvalidPtrIntArithmetic(...@@ -24066,8 +24066,8 @@ fn checkInvalidPtrIntArithmetic(
24066 const zcu = pt.zcu;24066 const zcu = pt.zcu;
24067 switch (try ty.zigTypeTagOrPoison(zcu)) {24067 switch (try ty.zigTypeTagOrPoison(zcu)) {
24068 .pointer => switch (ty.ptrSize(zcu)) {24068 .pointer => switch (ty.ptrSize(zcu)) {
24069 .One, .Slice => return,24069 .one, .slice => return,
24070 .Many, .C => return sema.failWithInvalidPtrArithmetic(block, src, "pointer-integer", "addition and subtraction"),24070 .many, .c => return sema.failWithInvalidPtrArithmetic(block, src, "pointer-integer", "addition and subtraction"),
24071 },24071 },
24072 else => return,24072 else => return,
24073 }24073 }
...@@ -25384,7 +25384,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins...@@ -25384,7 +25384,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins
25384 const parent_ptr_ty = try sema.resolveDestType(block, inst_src, extra.parent_ptr_type, .remove_eu, "@fieldParentPtr");25384 const parent_ptr_ty = try sema.resolveDestType(block, inst_src, extra.parent_ptr_type, .remove_eu, "@fieldParentPtr");
25385 try sema.checkPtrType(block, inst_src, parent_ptr_ty, true);25385 try sema.checkPtrType(block, inst_src, parent_ptr_ty, true);
25386 const parent_ptr_info = parent_ptr_ty.ptrInfo(zcu);25386 const parent_ptr_info = parent_ptr_ty.ptrInfo(zcu);
25387 if (parent_ptr_info.flags.size != .One) {25387 if (parent_ptr_info.flags.size != .one) {
25388 return sema.fail(block, inst_src, "expected single pointer type, found '{}'", .{parent_ptr_ty.fmt(pt)});25388 return sema.fail(block, inst_src, "expected single pointer type, found '{}'", .{parent_ptr_ty.fmt(pt)});
25389 }25389 }
25390 const parent_ty = Type.fromInterned(parent_ptr_info.child);25390 const parent_ty = Type.fromInterned(parent_ptr_info.child);
...@@ -25862,7 +25862,7 @@ fn upgradeToArrayPtr(sema: *Sema, block: *Block, ptr: Air.Inst.Ref, len: u64) !A...@@ -25862,7 +25862,7 @@ fn upgradeToArrayPtr(sema: *Sema, block: *Block, ptr: Air.Inst.Ref, len: u64) !A
25862 const zcu = pt.zcu;25862 const zcu = pt.zcu;
25863 const ptr_ty = sema.typeOf(ptr);25863 const ptr_ty = sema.typeOf(ptr);
25864 const info = ptr_ty.ptrInfo(zcu);25864 const info = ptr_ty.ptrInfo(zcu);
25865 if (info.flags.size == .One) {25865 if (info.flags.size == .one) {
25866 // Already an array pointer.25866 // Already an array pointer.
25867 return ptr;25867 return ptr;
25868 }25868 }
...@@ -25880,7 +25880,7 @@ fn upgradeToArrayPtr(sema: *Sema, block: *Block, ptr: Air.Inst.Ref, len: u64) !A...@@ -25880,7 +25880,7 @@ fn upgradeToArrayPtr(sema: *Sema, block: *Block, ptr: Air.Inst.Ref, len: u64) !A
25880 .address_space = info.flags.address_space,25880 .address_space = info.flags.address_space,
25881 },25881 },
25882 });25882 });
25883 const non_slice_ptr = if (info.flags.size == .Slice)25883 const non_slice_ptr = if (info.flags.size == .slice)
25884 try block.addTyOp(.slice_ptr, ptr_ty.slicePtrFieldType(zcu), ptr)25884 try block.addTyOp(.slice_ptr, ptr_ty.slicePtrFieldType(zcu), ptr)
25885 else25885 else
25886 ptr;25886 ptr;
...@@ -26069,22 +26069,22 @@ fn zirMemcpy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void...@@ -26069,22 +26069,22 @@ fn zirMemcpy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void
26069 const new_dest_ptr_ty = sema.typeOf(new_dest_ptr);26069 const new_dest_ptr_ty = sema.typeOf(new_dest_ptr);
26070 const raw_dest_ptr = if (new_dest_ptr_ty.isSlice(zcu))26070 const raw_dest_ptr = if (new_dest_ptr_ty.isSlice(zcu))
26071 try sema.analyzeSlicePtr(block, dest_src, new_dest_ptr, new_dest_ptr_ty)26071 try sema.analyzeSlicePtr(block, dest_src, new_dest_ptr, new_dest_ptr_ty)
26072 else if (new_dest_ptr_ty.ptrSize(zcu) == .One) ptr: {26072 else if (new_dest_ptr_ty.ptrSize(zcu) == .one) ptr: {
26073 var dest_manyptr_ty_key = zcu.intern_pool.indexToKey(new_dest_ptr_ty.toIntern()).ptr_type;26073 var dest_manyptr_ty_key = zcu.intern_pool.indexToKey(new_dest_ptr_ty.toIntern()).ptr_type;
26074 assert(dest_manyptr_ty_key.flags.size == .One);26074 assert(dest_manyptr_ty_key.flags.size == .one);
26075 dest_manyptr_ty_key.child = dest_elem_ty.toIntern();26075 dest_manyptr_ty_key.child = dest_elem_ty.toIntern();
26076 dest_manyptr_ty_key.flags.size = .Many;26076 dest_manyptr_ty_key.flags.size = .many;
26077 break :ptr try sema.coerceCompatiblePtrs(block, try pt.ptrTypeSema(dest_manyptr_ty_key), new_dest_ptr, dest_src);26077 break :ptr try sema.coerceCompatiblePtrs(block, try pt.ptrTypeSema(dest_manyptr_ty_key), new_dest_ptr, dest_src);
26078 } else new_dest_ptr;26078 } else new_dest_ptr;
2607926079
26080 const new_src_ptr_ty = sema.typeOf(new_src_ptr);26080 const new_src_ptr_ty = sema.typeOf(new_src_ptr);
26081 const raw_src_ptr = if (new_src_ptr_ty.isSlice(zcu))26081 const raw_src_ptr = if (new_src_ptr_ty.isSlice(zcu))
26082 try sema.analyzeSlicePtr(block, src_src, new_src_ptr, new_src_ptr_ty)26082 try sema.analyzeSlicePtr(block, src_src, new_src_ptr, new_src_ptr_ty)
26083 else if (new_src_ptr_ty.ptrSize(zcu) == .One) ptr: {26083 else if (new_src_ptr_ty.ptrSize(zcu) == .one) ptr: {
26084 var src_manyptr_ty_key = zcu.intern_pool.indexToKey(new_src_ptr_ty.toIntern()).ptr_type;26084 var src_manyptr_ty_key = zcu.intern_pool.indexToKey(new_src_ptr_ty.toIntern()).ptr_type;
26085 assert(src_manyptr_ty_key.flags.size == .One);26085 assert(src_manyptr_ty_key.flags.size == .one);
26086 src_manyptr_ty_key.child = src_elem_ty.toIntern();26086 src_manyptr_ty_key.child = src_elem_ty.toIntern();
26087 src_manyptr_ty_key.flags.size = .Many;26087 src_manyptr_ty_key.flags.size = .many;
26088 break :ptr try sema.coerceCompatiblePtrs(block, try pt.ptrTypeSema(src_manyptr_ty_key), new_src_ptr, src_src);26088 break :ptr try sema.coerceCompatiblePtrs(block, try pt.ptrTypeSema(src_manyptr_ty_key), new_src_ptr, src_src);
26089 } else new_src_ptr;26089 } else new_src_ptr;
2609026090
...@@ -26129,13 +26129,13 @@ fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void...@@ -26129,13 +26129,13 @@ fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void
26129 const dest_elem_ty: Type = dest_elem_ty: {26129 const dest_elem_ty: Type = dest_elem_ty: {
26130 const ptr_info = dest_ptr_ty.ptrInfo(zcu);26130 const ptr_info = dest_ptr_ty.ptrInfo(zcu);
26131 switch (ptr_info.flags.size) {26131 switch (ptr_info.flags.size) {
26132 .Slice => break :dest_elem_ty Type.fromInterned(ptr_info.child),26132 .slice => break :dest_elem_ty Type.fromInterned(ptr_info.child),
26133 .One => {26133 .one => {
26134 if (Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .array) {26134 if (Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .array) {
26135 break :dest_elem_ty Type.fromInterned(ptr_info.child).childType(zcu);26135 break :dest_elem_ty Type.fromInterned(ptr_info.child).childType(zcu);
26136 }26136 }
26137 },26137 },
26138 .Many, .C => {},26138 .many, .c => {},
26139 }26139 }
26140 return sema.failWithOwnedErrorMsg(block, msg: {26140 return sema.failWithOwnedErrorMsg(block, msg: {
26141 const msg = try sema.errMsg(src, "unknown @memset length", .{});26141 const msg = try sema.errMsg(src, "unknown @memset length", .{});
...@@ -26172,7 +26172,7 @@ fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void...@@ -26172,7 +26172,7 @@ fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void
26172 } }));26172 } }));
26173 const array_ptr_ty = ty: {26173 const array_ptr_ty = ty: {
26174 var info = dest_ptr_ty.ptrInfo(zcu);26174 var info = dest_ptr_ty.ptrInfo(zcu);
26175 info.flags.size = .One;26175 info.flags.size = .one;
26176 info.child = array_ty.toIntern();26176 info.child = array_ty.toIntern();
26177 break :ty try pt.ptrType(info);26177 break :ty try pt.ptrType(info);
26178 };26178 };
...@@ -26754,15 +26754,15 @@ fn zirInplaceArithResultTy(sema: *Sema, extended: Zir.Inst.Extended.InstData) Co...@@ -26754,15 +26754,15 @@ fn zirInplaceArithResultTy(sema: *Sema, extended: Zir.Inst.Extended.InstData) Co
26754 .add_eq => ty: {26754 .add_eq => ty: {
26755 const ptr_size = lhs_ty.ptrSizeOrNull(zcu) orelse break :ty lhs_ty;26755 const ptr_size = lhs_ty.ptrSizeOrNull(zcu) orelse break :ty lhs_ty;
26756 switch (ptr_size) {26756 switch (ptr_size) {
26757 .One, .Slice => break :ty lhs_ty, // invalid, let it error26757 .one, .slice => break :ty lhs_ty, // invalid, let it error
26758 .Many, .C => break :ty .usize, // `[*]T + usize`26758 .many, .c => break :ty .usize, // `[*]T + usize`
26759 }26759 }
26760 },26760 },
26761 .sub_eq => ty: {26761 .sub_eq => ty: {
26762 const ptr_size = lhs_ty.ptrSizeOrNull(zcu) orelse break :ty lhs_ty;26762 const ptr_size = lhs_ty.ptrSizeOrNull(zcu) orelse break :ty lhs_ty;
26763 switch (ptr_size) {26763 switch (ptr_size) {
26764 .One, .Slice => break :ty lhs_ty, // invalid, let it error26764 .one, .slice => break :ty lhs_ty, // invalid, let it error
26765 .Many, .C => break :ty .generic_poison, // could be `[*]T - [*]T` or `[*]T - usize`26765 .many, .c => break :ty .generic_poison, // could be `[*]T - [*]T` or `[*]T - usize`
26766 }26766 }
26767 },26767 },
26768 };26768 };
...@@ -27556,7 +27556,7 @@ fn fieldVal(...@@ -27556,7 +27556,7 @@ fn fieldVal(
27556 .child = Type.fromInterned(ptr_info.child).childType(zcu).toIntern(),27556 .child = Type.fromInterned(ptr_info.child).childType(zcu).toIntern(),
27557 .sentinel = if (inner_ty.sentinel(zcu)) |s| s.toIntern() else .none,27557 .sentinel = if (inner_ty.sentinel(zcu)) |s| s.toIntern() else .none,
27558 .flags = .{27558 .flags = .{
27559 .size = .Many,27559 .size = .many,
27560 .alignment = ptr_info.flags.alignment,27560 .alignment = ptr_info.flags.alignment,
27561 .is_const = ptr_info.flags.is_const,27561 .is_const = ptr_info.flags.is_const,
27562 .is_volatile = ptr_info.flags.is_volatile,27562 .is_volatile = ptr_info.flags.is_volatile,
...@@ -27578,7 +27578,7 @@ fn fieldVal(...@@ -27578,7 +27578,7 @@ fn fieldVal(
27578 },27578 },
27579 .pointer => {27579 .pointer => {
27580 const ptr_info = inner_ty.ptrInfo(zcu);27580 const ptr_info = inner_ty.ptrInfo(zcu);
27581 if (ptr_info.flags.size == .Slice) {27581 if (ptr_info.flags.size == .slice) {
27582 if (field_name.eqlSlice("ptr", ip)) {27582 if (field_name.eqlSlice("ptr", ip)) {
27583 const slice = if (is_pointer_to)27583 const slice = if (is_pointer_to)
27584 try sema.analyzeLoad(block, src, object, object_src)27584 try sema.analyzeLoad(block, src, object, object_src)
...@@ -27740,7 +27740,7 @@ fn fieldPtr(...@@ -27740,7 +27740,7 @@ fn fieldPtr(
27740 .child = Type.fromInterned(ptr_info.child).childType(zcu).toIntern(),27740 .child = Type.fromInterned(ptr_info.child).childType(zcu).toIntern(),
27741 .sentinel = if (object_ty.sentinel(zcu)) |s| s.toIntern() else .none,27741 .sentinel = if (object_ty.sentinel(zcu)) |s| s.toIntern() else .none,
27742 .flags = .{27742 .flags = .{
27743 .size = .Many,27743 .size = .many,
27744 .alignment = ptr_info.flags.alignment,27744 .alignment = ptr_info.flags.alignment,
27745 .is_const = ptr_info.flags.is_const,27745 .is_const = ptr_info.flags.is_const,
27746 .is_volatile = ptr_info.flags.is_volatile,27746 .is_volatile = ptr_info.flags.is_volatile,
...@@ -27953,13 +27953,13 @@ fn fieldCallBind(...@@ -27953,13 +27953,13 @@ fn fieldCallBind(
27953 const ip = &zcu.intern_pool;27953 const ip = &zcu.intern_pool;
27954 const raw_ptr_src = src; // TODO better source location27954 const raw_ptr_src = src; // TODO better source location
27955 const raw_ptr_ty = sema.typeOf(raw_ptr);27955 const raw_ptr_ty = sema.typeOf(raw_ptr);
27956 const inner_ty = if (raw_ptr_ty.zigTypeTag(zcu) == .pointer and (raw_ptr_ty.ptrSize(zcu) == .One or raw_ptr_ty.ptrSize(zcu) == .C))27956 const inner_ty = if (raw_ptr_ty.zigTypeTag(zcu) == .pointer and (raw_ptr_ty.ptrSize(zcu) == .one or raw_ptr_ty.ptrSize(zcu) == .c))
27957 raw_ptr_ty.childType(zcu)27957 raw_ptr_ty.childType(zcu)
27958 else27958 else
27959 return sema.fail(block, raw_ptr_src, "expected single pointer, found '{}'", .{raw_ptr_ty.fmt(pt)});27959 return sema.fail(block, raw_ptr_src, "expected single pointer, found '{}'", .{raw_ptr_ty.fmt(pt)});
2796027960
27961 // Optionally dereference a second pointer to get the concrete type.27961 // Optionally dereference a second pointer to get the concrete type.
27962 const is_double_ptr = inner_ty.zigTypeTag(zcu) == .pointer and inner_ty.ptrSize(zcu) == .One;27962 const is_double_ptr = inner_ty.zigTypeTag(zcu) == .pointer and inner_ty.ptrSize(zcu) == .one;
27963 const concrete_ty = if (is_double_ptr) inner_ty.childType(zcu) else inner_ty;27963 const concrete_ty = if (is_double_ptr) inner_ty.childType(zcu) else inner_ty;
27964 const ptr_ty = if (is_double_ptr) inner_ty else raw_ptr_ty;27964 const ptr_ty = if (is_double_ptr) inner_ty else raw_ptr_ty;
27965 const object_ptr = if (is_double_ptr)27965 const object_ptr = if (is_double_ptr)
...@@ -28025,8 +28025,8 @@ fn fieldCallBind(...@@ -28025,8 +28025,8 @@ fn fieldCallBind(
28025 const first_param_type = Type.fromInterned(func_type.param_types.get(ip)[0]);28025 const first_param_type = Type.fromInterned(func_type.param_types.get(ip)[0]);
28026 if (first_param_type.isGenericPoison() or28026 if (first_param_type.isGenericPoison() or
28027 (first_param_type.zigTypeTag(zcu) == .pointer and28027 (first_param_type.zigTypeTag(zcu) == .pointer and
28028 (first_param_type.ptrSize(zcu) == .One or28028 (first_param_type.ptrSize(zcu) == .one or
28029 first_param_type.ptrSize(zcu) == .C) and28029 first_param_type.ptrSize(zcu) == .c) and
28030 first_param_type.childType(zcu).eql(concrete_ty, zcu)))28030 first_param_type.childType(zcu).eql(concrete_ty, zcu)))
28031 {28031 {
28032 // Note that if the param type is generic poison, we know that it must28032 // Note that if the param type is generic poison, we know that it must
...@@ -28053,7 +28053,7 @@ fn fieldCallBind(...@@ -28053,7 +28053,7 @@ fn fieldCallBind(
28053 .arg0_inst = deref,28053 .arg0_inst = deref,
28054 } };28054 } };
28055 } else if (child.zigTypeTag(zcu) == .pointer and28055 } else if (child.zigTypeTag(zcu) == .pointer and
28056 child.ptrSize(zcu) == .One and28056 child.ptrSize(zcu) == .one and
28057 child.childType(zcu).eql(concrete_ty, zcu))28057 child.childType(zcu).eql(concrete_ty, zcu))
28058 {28058 {
28059 return .{ .method = .{28059 return .{ .method = .{
...@@ -28673,8 +28673,8 @@ fn elemPtrOneLayerOnly(...@@ -28673,8 +28673,8 @@ fn elemPtrOneLayerOnly(
28673 try checkIndexable(sema, block, src, indexable_ty);28673 try checkIndexable(sema, block, src, indexable_ty);
2867428674
28675 switch (indexable_ty.ptrSize(zcu)) {28675 switch (indexable_ty.ptrSize(zcu)) {
28676 .Slice => return sema.elemPtrSlice(block, src, indexable_src, indexable, elem_index_src, elem_index, oob_safety),28676 .slice => return sema.elemPtrSlice(block, src, indexable_src, indexable, elem_index_src, elem_index, oob_safety),
28677 .Many, .C => {28677 .many, .c => {
28678 const maybe_ptr_val = try sema.resolveDefinedValue(block, indexable_src, indexable);28678 const maybe_ptr_val = try sema.resolveDefinedValue(block, indexable_src, indexable);
28679 const maybe_index_val = try sema.resolveDefinedValue(block, elem_index_src, elem_index);28679 const maybe_index_val = try sema.resolveDefinedValue(block, elem_index_src, elem_index);
28680 ct: {28680 ct: {
...@@ -28688,7 +28688,7 @@ fn elemPtrOneLayerOnly(...@@ -28688,7 +28688,7 @@ fn elemPtrOneLayerOnly(
2868828688
28689 return block.addPtrElemPtr(indexable, elem_index, result_ty);28689 return block.addPtrElemPtr(indexable, elem_index, result_ty);
28690 },28690 },
28691 .One => {28691 .one => {
28692 const child_ty = indexable_ty.childType(zcu);28692 const child_ty = indexable_ty.childType(zcu);
28693 const elem_ptr = switch (child_ty.zigTypeTag(zcu)) {28693 const elem_ptr = switch (child_ty.zigTypeTag(zcu)) {
28694 .array, .vector => try sema.elemPtrArray(block, src, indexable_src, indexable, elem_index_src, elem_index, init, oob_safety),28694 .array, .vector => try sema.elemPtrArray(block, src, indexable_src, indexable, elem_index_src, elem_index, init, oob_safety),
...@@ -28728,8 +28728,8 @@ fn elemVal(...@@ -28728,8 +28728,8 @@ fn elemVal(
2872828728
28729 switch (indexable_ty.zigTypeTag(zcu)) {28729 switch (indexable_ty.zigTypeTag(zcu)) {
28730 .pointer => switch (indexable_ty.ptrSize(zcu)) {28730 .pointer => switch (indexable_ty.ptrSize(zcu)) {
28731 .Slice => return sema.elemValSlice(block, src, indexable_src, indexable, elem_index_src, elem_index, oob_safety),28731 .slice => return sema.elemValSlice(block, src, indexable_src, indexable, elem_index_src, elem_index, oob_safety),
28732 .Many, .C => {28732 .many, .c => {
28733 const maybe_indexable_val = try sema.resolveDefinedValue(block, indexable_src, indexable);28733 const maybe_indexable_val = try sema.resolveDefinedValue(block, indexable_src, indexable);
28734 const maybe_index_val = try sema.resolveDefinedValue(block, elem_index_src, elem_index);28734 const maybe_index_val = try sema.resolveDefinedValue(block, elem_index_src, elem_index);
2873528735
...@@ -28748,7 +28748,7 @@ fn elemVal(...@@ -28748,7 +28748,7 @@ fn elemVal(
2874828748
28749 return block.addBinOp(.ptr_elem_val, indexable, elem_index);28749 return block.addBinOp(.ptr_elem_val, indexable, elem_index);
28750 },28750 },
28751 .One => {28751 .one => {
28752 arr_sent: {28752 arr_sent: {
28753 const inner_ty = indexable_ty.childType(zcu);28753 const inner_ty = indexable_ty.childType(zcu);
28754 if (inner_ty.zigTypeTag(zcu) != .array) break :arr_sent;28754 if (inner_ty.zigTypeTag(zcu) != .array) break :arr_sent;
...@@ -29293,7 +29293,7 @@ fn coerceExtra(...@@ -29293,7 +29293,7 @@ fn coerceExtra(
2929329293
29294 // *T to *[1]T29294 // *T to *[1]T
29295 single_item: {29295 single_item: {
29296 if (dest_info.flags.size != .One) break :single_item;29296 if (dest_info.flags.size != .one) break :single_item;
29297 if (!inst_ty.isSinglePointer(zcu)) break :single_item;29297 if (!inst_ty.isSinglePointer(zcu)) break :single_item;
29298 if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :pointer;29298 if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :pointer;
29299 const ptr_elem_ty = inst_ty.childType(zcu);29299 const ptr_elem_ty = inst_ty.childType(zcu);
...@@ -29312,7 +29312,7 @@ fn coerceExtra(...@@ -29312,7 +29312,7 @@ fn coerceExtra(
29312 // Coercions where the source is a single pointer to an array.29312 // Coercions where the source is a single pointer to an array.
29313 src_array_ptr: {29313 src_array_ptr: {
29314 if (!inst_ty.isSinglePointer(zcu)) break :src_array_ptr;29314 if (!inst_ty.isSinglePointer(zcu)) break :src_array_ptr;
29315 if (dest_info.flags.size == .One) break :src_array_ptr; // `*[n]T` -> `*T` isn't valid29315 if (dest_info.flags.size == .one) break :src_array_ptr; // `*[n]T` -> `*T` isn't valid
29316 if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :pointer;29316 if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :pointer;
29317 const array_ty = inst_ty.childType(zcu);29317 const array_ty = inst_ty.childType(zcu);
29318 if (array_ty.zigTypeTag(zcu) != .array) break :src_array_ptr;29318 if (array_ty.zigTypeTag(zcu) != .array) break :src_array_ptr;
...@@ -29356,25 +29356,25 @@ fn coerceExtra(...@@ -29356,25 +29356,25 @@ fn coerceExtra(
29356 }29356 }
2935729357
29358 switch (dest_info.flags.size) {29358 switch (dest_info.flags.size) {
29359 .Slice => {29359 .slice => {
29360 // *[N]T to []T29360 // *[N]T to []T
29361 return sema.coerceArrayPtrToSlice(block, dest_ty, inst, inst_src);29361 return sema.coerceArrayPtrToSlice(block, dest_ty, inst, inst_src);
29362 },29362 },
29363 .C => {29363 .c => {
29364 // *[N]T to [*c]T29364 // *[N]T to [*c]T
29365 return sema.coerceCompatiblePtrs(block, dest_ty, inst, inst_src);29365 return sema.coerceCompatiblePtrs(block, dest_ty, inst, inst_src);
29366 },29366 },
29367 .Many => {29367 .many => {
29368 // *[N]T to [*]T29368 // *[N]T to [*]T
29369 return sema.coerceCompatiblePtrs(block, dest_ty, inst, inst_src);29369 return sema.coerceCompatiblePtrs(block, dest_ty, inst, inst_src);
29370 },29370 },
29371 .One => unreachable, // early exit at top of block29371 .one => unreachable, // early exit at top of block
29372 }29372 }
29373 }29373 }
2937429374
29375 // coercion from C pointer29375 // coercion from C pointer
29376 if (inst_ty.isCPtr(zcu)) src_c_ptr: {29376 if (inst_ty.isCPtr(zcu)) src_c_ptr: {
29377 if (dest_info.flags.size == .Slice) break :src_c_ptr;29377 if (dest_info.flags.size == .slice) break :src_c_ptr;
29378 if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :src_c_ptr;29378 if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :src_c_ptr;
29379 // In this case we must add a safety check because the C pointer29379 // In this case we must add a safety check because the C pointer
29380 // could be null.29380 // could be null.
...@@ -29413,7 +29413,7 @@ fn coerceExtra(...@@ -29413,7 +29413,7 @@ fn coerceExtra(
2941329413
29414 switch (dest_info.flags.size) {29414 switch (dest_info.flags.size) {
29415 // coercion to C pointer29415 // coercion to C pointer
29416 .C => switch (inst_ty.zigTypeTag(zcu)) {29416 .c => switch (inst_ty.zigTypeTag(zcu)) {
29417 .null => return Air.internedToRef(try pt.intern(.{ .ptr = .{29417 .null => return Air.internedToRef(try pt.intern(.{ .ptr = .{
29418 .ty = dest_ty.toIntern(),29418 .ty = dest_ty.toIntern(),
29419 .base_addr = .int,29419 .base_addr = .int,
...@@ -29457,7 +29457,7 @@ fn coerceExtra(...@@ -29457,7 +29457,7 @@ fn coerceExtra(
29457 .ok => {},29457 .ok => {},
29458 else => break :p,29458 else => break :p,
29459 }29459 }
29460 if (inst_info.flags.size == .Slice) {29460 if (inst_info.flags.size == .slice) {
29461 assert(dest_info.sentinel == .none);29461 assert(dest_info.sentinel == .none);
29462 if (inst_info.sentinel == .none or29462 if (inst_info.sentinel == .none or
29463 inst_info.sentinel != (try pt.intValue(Type.fromInterned(inst_info.child), 0)).toIntern())29463 inst_info.sentinel != (try pt.intValue(Type.fromInterned(inst_info.child), 0)).toIntern())
...@@ -29470,8 +29470,8 @@ fn coerceExtra(...@@ -29470,8 +29470,8 @@ fn coerceExtra(
29470 },29470 },
29471 else => {},29471 else => {},
29472 },29472 },
29473 .One => {},29473 .one => {},
29474 .Slice => to_slice: {29474 .slice => to_slice: {
29475 if (inst_ty.zigTypeTag(zcu) == .array) {29475 if (inst_ty.zigTypeTag(zcu) == .array) {
29476 return sema.fail(29476 return sema.fail(
29477 block,29477 block,
...@@ -29512,7 +29512,7 @@ fn coerceExtra(...@@ -29512,7 +29512,7 @@ fn coerceExtra(
29512 }29512 }
29513 return sema.coerceTupleToSlicePtrs(block, dest_ty, dest_ty_src, inst, inst_src);29513 return sema.coerceTupleToSlicePtrs(block, dest_ty, dest_ty_src, inst, inst_src);
29514 },29514 },
29515 .Many => p: {29515 .many => p: {
29516 if (!inst_ty.isSlice(zcu)) break :p;29516 if (!inst_ty.isSlice(zcu)) break :p;
29517 if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :p;29517 if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :p;
29518 const inst_info = inst_ty.ptrInfo(zcu);29518 const inst_info = inst_ty.ptrInfo(zcu);
...@@ -30224,10 +30224,10 @@ const InMemoryCoercionResult = union(enum) {...@@ -30224,10 +30224,10 @@ const InMemoryCoercionResult = union(enum) {
3022430224
30225fn pointerSizeString(size: std.builtin.Type.Pointer.Size) []const u8 {30225fn pointerSizeString(size: std.builtin.Type.Pointer.Size) []const u8 {
30226 return switch (size) {30226 return switch (size) {
30227 .One => "single pointer",30227 .one => "single pointer",
30228 .Many => "many pointer",30228 .many => "many pointer",
30229 .C => "C pointer",30229 .c => "C pointer",
30230 .Slice => "slice",30230 .slice => "slice",
30231 };30231 };
30232}30232}
3023330233
...@@ -30775,7 +30775,7 @@ fn coerceInMemoryAllowedPtrs(...@@ -30775,7 +30775,7 @@ fn coerceInMemoryAllowedPtrs(
30775 const src_info = src_ptr_ty.ptrInfo(zcu);30775 const src_info = src_ptr_ty.ptrInfo(zcu);
3077630776
30777 const ok_ptr_size = src_info.flags.size == dest_info.flags.size or30777 const ok_ptr_size = src_info.flags.size == dest_info.flags.size or
30778 src_info.flags.size == .C or dest_info.flags.size == .C;30778 src_info.flags.size == .c or dest_info.flags.size == .c;
30779 if (!ok_ptr_size) {30779 if (!ok_ptr_size) {
30780 return InMemoryCoercionResult{ .ptr_size = .{30780 return InMemoryCoercionResult{ .ptr_size = .{
30781 .actual = src_info.flags.size,30781 .actual = src_info.flags.size,
...@@ -30874,7 +30874,7 @@ fn coerceInMemoryAllowedPtrs(...@@ -30874,7 +30874,7 @@ fn coerceInMemoryAllowedPtrs(
30874 if (ss != .none and ds != .none) {30874 if (ss != .none and ds != .none) {
30875 if (ds == try zcu.intern_pool.getCoerced(sema.gpa, pt.tid, ss, dest_info.child)) break :ok true;30875 if (ds == try zcu.intern_pool.getCoerced(sema.gpa, pt.tid, ss, dest_info.child)) break :ok true;
30876 }30876 }
30877 if (src_info.flags.size == .C) break :ok true;30877 if (src_info.flags.size == .c) break :ok true;
30878 if (!dest_is_mut and dest_info.sentinel == .none) break :ok true;30878 if (!dest_is_mut and dest_info.sentinel == .none) break :ok true;
30879 break :ok false;30879 break :ok false;
30880 };30880 };
...@@ -31392,7 +31392,7 @@ fn checkPtrAttributes(sema: *Sema, dest_ty: Type, inst_ty: Type, in_memory_resul...@@ -31392,7 +31392,7 @@ fn checkPtrAttributes(sema: *Sema, dest_ty: Type, inst_ty: Type, in_memory_resul
31392 const dest_info = dest_ty.ptrInfo(zcu);31392 const dest_info = dest_ty.ptrInfo(zcu);
31393 const inst_info = inst_ty.ptrInfo(zcu);31393 const inst_info = inst_ty.ptrInfo(zcu);
31394 const len0 = (Type.fromInterned(inst_info.child).zigTypeTag(zcu) == .array and (Type.fromInterned(inst_info.child).arrayLenIncludingSentinel(zcu) == 0 or31394 const len0 = (Type.fromInterned(inst_info.child).zigTypeTag(zcu) == .array and (Type.fromInterned(inst_info.child).arrayLenIncludingSentinel(zcu) == 0 or
31395 (Type.fromInterned(inst_info.child).arrayLen(zcu) == 0 and dest_info.sentinel == .none and dest_info.flags.size != .C and dest_info.flags.size != .Many))) or31395 (Type.fromInterned(inst_info.child).arrayLen(zcu) == 0 and dest_info.sentinel == .none and dest_info.flags.size != .c and dest_info.flags.size != .many))) or
31396 (Type.fromInterned(inst_info.child).isTuple(zcu) and Type.fromInterned(inst_info.child).structFieldCount(zcu) == 0);31396 (Type.fromInterned(inst_info.child).isTuple(zcu) and Type.fromInterned(inst_info.child).structFieldCount(zcu) == 0);
3139731397
31398 const ok_const = (!inst_info.flags.is_const or dest_info.flags.is_const) or len0;31398 const ok_const = (!inst_info.flags.is_const or dest_info.flags.is_const) or len0;
...@@ -32631,7 +32631,7 @@ fn analyzeSlice(...@@ -32631,7 +32631,7 @@ fn analyzeSlice(
32631 elem_ty = ptr_ptr_child_ty.childType(zcu);32631 elem_ty = ptr_ptr_child_ty.childType(zcu);
32632 },32632 },
32633 .pointer => switch (ptr_ptr_child_ty.ptrSize(zcu)) {32633 .pointer => switch (ptr_ptr_child_ty.ptrSize(zcu)) {
32634 .One => {32634 .one => {
32635 const double_child_ty = ptr_ptr_child_ty.childType(zcu);32635 const double_child_ty = ptr_ptr_child_ty.childType(zcu);
32636 ptr_or_slice = try sema.analyzeLoad(block, src, ptr_ptr, ptr_src);32636 ptr_or_slice = try sema.analyzeLoad(block, src, ptr_ptr, ptr_src);
32637 if (double_child_ty.zigTypeTag(zcu) == .array) {32637 if (double_child_ty.zigTypeTag(zcu) == .array) {
...@@ -32721,14 +32721,14 @@ fn analyzeSlice(...@@ -32721,14 +32721,14 @@ fn analyzeSlice(
32721 elem_ty = double_child_ty;32721 elem_ty = double_child_ty;
32722 }32722 }
32723 },32723 },
32724 .Many, .C => {32724 .many, .c => {
32725 ptr_sentinel = ptr_ptr_child_ty.sentinel(zcu);32725 ptr_sentinel = ptr_ptr_child_ty.sentinel(zcu);
32726 ptr_or_slice = try sema.analyzeLoad(block, src, ptr_ptr, ptr_src);32726 ptr_or_slice = try sema.analyzeLoad(block, src, ptr_ptr, ptr_src);
32727 slice_ty = ptr_ptr_child_ty;32727 slice_ty = ptr_ptr_child_ty;
32728 array_ty = ptr_ptr_child_ty;32728 array_ty = ptr_ptr_child_ty;
32729 elem_ty = ptr_ptr_child_ty.childType(zcu);32729 elem_ty = ptr_ptr_child_ty.childType(zcu);
3273032730
32731 if (ptr_ptr_child_ty.ptrSize(zcu) == .C) {32731 if (ptr_ptr_child_ty.ptrSize(zcu) == .c) {
32732 if (try sema.resolveDefinedValue(block, ptr_src, ptr_or_slice)) |ptr_val| {32732 if (try sema.resolveDefinedValue(block, ptr_src, ptr_or_slice)) |ptr_val| {
32733 if (ptr_val.isNull(zcu)) {32733 if (ptr_val.isNull(zcu)) {
32734 return sema.fail(block, src, "slice of null pointer", .{});32734 return sema.fail(block, src, "slice of null pointer", .{});
...@@ -32736,7 +32736,7 @@ fn analyzeSlice(...@@ -32736,7 +32736,7 @@ fn analyzeSlice(
32736 }32736 }
32737 }32737 }
32738 },32738 },
32739 .Slice => {32739 .slice => {
32740 ptr_sentinel = ptr_ptr_child_ty.sentinel(zcu);32740 ptr_sentinel = ptr_ptr_child_ty.sentinel(zcu);
32741 ptr_or_slice = try sema.analyzeLoad(block, src, ptr_ptr, ptr_src);32741 ptr_or_slice = try sema.analyzeLoad(block, src, ptr_ptr, ptr_src);
32742 slice_ty = ptr_ptr_child_ty;32742 slice_ty = ptr_ptr_child_ty;
...@@ -32752,9 +32752,9 @@ fn analyzeSlice(...@@ -32752,9 +32752,9 @@ fn analyzeSlice(
32752 else if (array_ty.zigTypeTag(zcu) == .array) ptr: {32752 else if (array_ty.zigTypeTag(zcu) == .array) ptr: {
32753 var manyptr_ty_key = zcu.intern_pool.indexToKey(slice_ty.toIntern()).ptr_type;32753 var manyptr_ty_key = zcu.intern_pool.indexToKey(slice_ty.toIntern()).ptr_type;
32754 assert(manyptr_ty_key.child == array_ty.toIntern());32754 assert(manyptr_ty_key.child == array_ty.toIntern());
32755 assert(manyptr_ty_key.flags.size == .One);32755 assert(manyptr_ty_key.flags.size == .one);
32756 manyptr_ty_key.child = elem_ty.toIntern();32756 manyptr_ty_key.child = elem_ty.toIntern();
32757 manyptr_ty_key.flags.size = .Many;32757 manyptr_ty_key.flags.size = .many;
32758 break :ptr try sema.coerceCompatiblePtrs(block, try pt.ptrTypeSema(manyptr_ty_key), ptr_or_slice, ptr_src);32758 break :ptr try sema.coerceCompatiblePtrs(block, try pt.ptrTypeSema(manyptr_ty_key), ptr_or_slice, ptr_src);
32759 } else ptr_or_slice;32759 } else ptr_or_slice;
3276032760
...@@ -32967,7 +32967,7 @@ fn analyzeSlice(...@@ -32967,7 +32967,7 @@ fn analyzeSlice(
32967 const opt_new_len_val = try sema.resolveDefinedValue(block, src, new_len);32967 const opt_new_len_val = try sema.resolveDefinedValue(block, src, new_len);
3296832968
32969 const new_ptr_ty_info = new_ptr_ty.ptrInfo(zcu);32969 const new_ptr_ty_info = new_ptr_ty.ptrInfo(zcu);
32970 const new_allowzero = new_ptr_ty_info.flags.is_allowzero and sema.typeOf(ptr).ptrSize(zcu) != .C;32970 const new_allowzero = new_ptr_ty_info.flags.is_allowzero and sema.typeOf(ptr).ptrSize(zcu) != .c;
3297132971
32972 if (opt_new_len_val) |new_len_val| {32972 if (opt_new_len_val) |new_len_val| {
32973 const new_len_int = try new_len_val.toUnsignedIntSema(pt);32973 const new_len_int = try new_len_val.toUnsignedIntSema(pt);
...@@ -33038,7 +33038,7 @@ fn analyzeSlice(...@@ -33038,7 +33038,7 @@ fn analyzeSlice(
33038 .child = elem_ty.toIntern(),33038 .child = elem_ty.toIntern(),
33039 .sentinel = if (sentinel) |s| s.toIntern() else .none,33039 .sentinel = if (sentinel) |s| s.toIntern() else .none,
33040 .flags = .{33040 .flags = .{
33041 .size = .Slice,33041 .size = .slice,
33042 .alignment = new_ptr_ty_info.flags.alignment,33042 .alignment = new_ptr_ty_info.flags.alignment,
33043 .is_const = new_ptr_ty_info.flags.is_const,33043 .is_const = new_ptr_ty_info.flags.is_const,
33044 .is_volatile = new_ptr_ty_info.flags.is_volatile,33044 .is_volatile = new_ptr_ty_info.flags.is_volatile,
...@@ -33739,7 +33739,7 @@ const PeerResolveStrategy = enum {...@@ -33739,7 +33739,7 @@ const PeerResolveStrategy = enum {
33739 .int => .fixed_int,33739 .int => .fixed_int,
33740 .comptime_float => .comptime_float,33740 .comptime_float => .comptime_float,
33741 .float => .fixed_float,33741 .float => .fixed_float,
33742 .pointer => if (ty.ptrInfo(zcu).flags.size == .C) .c_ptr else .ptr,33742 .pointer => if (ty.ptrInfo(zcu).flags.size == .c) .c_ptr else .ptr,
33743 .array => .array,33743 .array => .array,
33744 .vector => .vector,33744 .vector => .vector,
33745 .optional => .optional,33745 .optional => .optional,
...@@ -34235,7 +34235,7 @@ fn resolvePeerTypesInner(...@@ -34235,7 +34235,7 @@ fn resolvePeerTypesInner(
3423534235
34236 var ptr_info = opt_ptr_info orelse {34236 var ptr_info = opt_ptr_info orelse {
34237 opt_ptr_info = peer_info;34237 opt_ptr_info = peer_info;
34238 opt_ptr_info.?.flags.size = .C;34238 opt_ptr_info.?.flags.size = .c;
34239 first_idx = i;34239 first_idx = i;
34240 continue;34240 continue;
34241 };34241 };
...@@ -34323,9 +34323,9 @@ fn resolvePeerTypesInner(...@@ -34323,9 +34323,9 @@ fn resolvePeerTypesInner(
34323 };34323 };
3432434324
34325 switch (peer_info.flags.size) {34325 switch (peer_info.flags.size) {
34326 .One, .Many => {},34326 .one, .many => {},
34327 .Slice => opt_slice_idx = i,34327 .slice => opt_slice_idx = i,
34328 .C => return .{ .conflict = .{34328 .c => return .{ .conflict = .{
34329 .peer_idx_a = strat_reason,34329 .peer_idx_a = strat_reason,
34330 .peer_idx_b = i,34330 .peer_idx_b = i,
34331 } },34331 } },
...@@ -34370,21 +34370,21 @@ fn resolvePeerTypesInner(...@@ -34370,21 +34370,21 @@ fn resolvePeerTypesInner(
34370 ptr_info.flags.is_allowzero = ptr_info.flags.is_allowzero or peer_info.flags.is_allowzero;34370 ptr_info.flags.is_allowzero = ptr_info.flags.is_allowzero or peer_info.flags.is_allowzero;
3437134371
34372 const peer_sentinel: InternPool.Index = switch (peer_info.flags.size) {34372 const peer_sentinel: InternPool.Index = switch (peer_info.flags.size) {
34373 .One => switch (ip.indexToKey(peer_info.child)) {34373 .one => switch (ip.indexToKey(peer_info.child)) {
34374 .array_type => |array_type| array_type.sentinel,34374 .array_type => |array_type| array_type.sentinel,
34375 else => .none,34375 else => .none,
34376 },34376 },
34377 .Many, .Slice => peer_info.sentinel,34377 .many, .slice => peer_info.sentinel,
34378 .C => unreachable,34378 .c => unreachable,
34379 };34379 };
3438034380
34381 const cur_sentinel: InternPool.Index = switch (ptr_info.flags.size) {34381 const cur_sentinel: InternPool.Index = switch (ptr_info.flags.size) {
34382 .One => switch (ip.indexToKey(ptr_info.child)) {34382 .one => switch (ip.indexToKey(ptr_info.child)) {
34383 .array_type => |array_type| array_type.sentinel,34383 .array_type => |array_type| array_type.sentinel,
34384 else => .none,34384 else => .none,
34385 },34385 },
34386 .Many, .Slice => ptr_info.sentinel,34386 .many, .slice => ptr_info.sentinel,
34387 .C => unreachable,34387 .c => unreachable,
34388 };34388 };
3438934389
34390 // We abstract array handling slightly so that tuple pointers can work like array pointers34390 // We abstract array handling slightly so that tuple pointers can work like array pointers
...@@ -34395,8 +34395,8 @@ fn resolvePeerTypesInner(...@@ -34395,8 +34395,8 @@ fn resolvePeerTypesInner(
34395 // single-pointer array sentinel).34395 // single-pointer array sentinel).
34396 good: {34396 good: {
34397 switch (peer_info.flags.size) {34397 switch (peer_info.flags.size) {
34398 .One => switch (ptr_info.flags.size) {34398 .one => switch (ptr_info.flags.size) {
34399 .One => {34399 .one => {
34400 if (try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), Type.fromInterned(peer_info.child))) |pointee| {34400 if (try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), Type.fromInterned(peer_info.child))) |pointee| {
34401 ptr_info.child = pointee.toIntern();34401 ptr_info.child = pointee.toIntern();
34402 break :good;34402 break :good;
...@@ -34415,28 +34415,28 @@ fn resolvePeerTypesInner(...@@ -34415,28 +34415,28 @@ fn resolvePeerTypesInner(
34415 break :good;34415 break :good;
34416 }34416 }
34417 // *[a]T + *[b]T = []T34417 // *[a]T + *[b]T = []T
34418 ptr_info.flags.size = .Slice;34418 ptr_info.flags.size = .slice;
34419 ptr_info.child = elem_ty.toIntern();34419 ptr_info.child = elem_ty.toIntern();
34420 break :good;34420 break :good;
34421 }34421 }
3442234422
34423 if (peer_arr.elem_ty.toIntern() == .noreturn_type) {34423 if (peer_arr.elem_ty.toIntern() == .noreturn_type) {
34424 // *struct{} + *[a]T = []T34424 // *struct{} + *[a]T = []T
34425 ptr_info.flags.size = .Slice;34425 ptr_info.flags.size = .slice;
34426 ptr_info.child = cur_arr.elem_ty.toIntern();34426 ptr_info.child = cur_arr.elem_ty.toIntern();
34427 break :good;34427 break :good;
34428 }34428 }
3442934429
34430 if (cur_arr.elem_ty.toIntern() == .noreturn_type) {34430 if (cur_arr.elem_ty.toIntern() == .noreturn_type) {
34431 // *[a]T + *struct{} = []T34431 // *[a]T + *struct{} = []T
34432 ptr_info.flags.size = .Slice;34432 ptr_info.flags.size = .slice;
34433 ptr_info.child = peer_arr.elem_ty.toIntern();34433 ptr_info.child = peer_arr.elem_ty.toIntern();
34434 break :good;34434 break :good;
34435 }34435 }
3443634436
34437 return generic_err;34437 return generic_err;
34438 },34438 },
34439 .Many => {34439 .many => {
34440 // Only works for *[n]T + [*]T -> [*]T34440 // Only works for *[n]T + [*]T -> [*]T
34441 const arr = peer_pointee_array orelse return generic_err;34441 const arr = peer_pointee_array orelse return generic_err;
34442 if (try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), arr.elem_ty)) |pointee| {34442 if (try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), arr.elem_ty)) |pointee| {
...@@ -34449,7 +34449,7 @@ fn resolvePeerTypesInner(...@@ -34449,7 +34449,7 @@ fn resolvePeerTypesInner(
34449 }34449 }
34450 return generic_err;34450 return generic_err;
34451 },34451 },
34452 .Slice => {34452 .slice => {
34453 // Only works for *[n]T + []T -> []T34453 // Only works for *[n]T + []T -> []T
34454 const arr = peer_pointee_array orelse return generic_err;34454 const arr = peer_pointee_array orelse return generic_err;
34455 if (try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), arr.elem_ty)) |pointee| {34455 if (try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), arr.elem_ty)) |pointee| {
...@@ -34462,33 +34462,33 @@ fn resolvePeerTypesInner(...@@ -34462,33 +34462,33 @@ fn resolvePeerTypesInner(
34462 }34462 }
34463 return generic_err;34463 return generic_err;
34464 },34464 },
34465 .C => unreachable,34465 .c => unreachable,
34466 },34466 },
34467 .Many => switch (ptr_info.flags.size) {34467 .many => switch (ptr_info.flags.size) {
34468 .One => {34468 .one => {
34469 // Only works for [*]T + *[n]T -> [*]T34469 // Only works for [*]T + *[n]T -> [*]T
34470 const arr = cur_pointee_array orelse return generic_err;34470 const arr = cur_pointee_array orelse return generic_err;
34471 if (try sema.resolvePairInMemoryCoercible(block, src, arr.elem_ty, Type.fromInterned(peer_info.child))) |pointee| {34471 if (try sema.resolvePairInMemoryCoercible(block, src, arr.elem_ty, Type.fromInterned(peer_info.child))) |pointee| {
34472 ptr_info.flags.size = .Many;34472 ptr_info.flags.size = .many;
34473 ptr_info.child = pointee.toIntern();34473 ptr_info.child = pointee.toIntern();
34474 break :good;34474 break :good;
34475 }34475 }
34476 if (arr.elem_ty.toIntern() == .noreturn_type) {34476 if (arr.elem_ty.toIntern() == .noreturn_type) {
34477 // [*]T + *struct{} -> [*]T34477 // [*]T + *struct{} -> [*]T
34478 ptr_info.flags.size = .Many;34478 ptr_info.flags.size = .many;
34479 ptr_info.child = peer_info.child;34479 ptr_info.child = peer_info.child;
34480 break :good;34480 break :good;
34481 }34481 }
34482 return generic_err;34482 return generic_err;
34483 },34483 },
34484 .Many => {34484 .many => {
34485 if (try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), Type.fromInterned(peer_info.child))) |pointee| {34485 if (try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), Type.fromInterned(peer_info.child))) |pointee| {
34486 ptr_info.child = pointee.toIntern();34486 ptr_info.child = pointee.toIntern();
34487 break :good;34487 break :good;
34488 }34488 }
34489 return generic_err;34489 return generic_err;
34490 },34490 },
34491 .Slice => {34491 .slice => {
34492 // Only works if no peers are actually slices34492 // Only works if no peers are actually slices
34493 if (opt_slice_idx) |slice_idx| {34493 if (opt_slice_idx) |slice_idx| {
34494 return .{ .conflict = .{34494 return .{ .conflict = .{
...@@ -34498,54 +34498,54 @@ fn resolvePeerTypesInner(...@@ -34498,54 +34498,54 @@ fn resolvePeerTypesInner(
34498 }34498 }
34499 // Okay, then works for [*]T + "[]T" -> [*]T34499 // Okay, then works for [*]T + "[]T" -> [*]T
34500 if (try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), Type.fromInterned(peer_info.child))) |pointee| {34500 if (try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), Type.fromInterned(peer_info.child))) |pointee| {
34501 ptr_info.flags.size = .Many;34501 ptr_info.flags.size = .many;
34502 ptr_info.child = pointee.toIntern();34502 ptr_info.child = pointee.toIntern();
34503 break :good;34503 break :good;
34504 }34504 }
34505 return generic_err;34505 return generic_err;
34506 },34506 },
34507 .C => unreachable,34507 .c => unreachable,
34508 },34508 },
34509 .Slice => switch (ptr_info.flags.size) {34509 .slice => switch (ptr_info.flags.size) {
34510 .One => {34510 .one => {
34511 // Only works for []T + *[n]T -> []T34511 // Only works for []T + *[n]T -> []T
34512 const arr = cur_pointee_array orelse return generic_err;34512 const arr = cur_pointee_array orelse return generic_err;
34513 if (try sema.resolvePairInMemoryCoercible(block, src, arr.elem_ty, Type.fromInterned(peer_info.child))) |pointee| {34513 if (try sema.resolvePairInMemoryCoercible(block, src, arr.elem_ty, Type.fromInterned(peer_info.child))) |pointee| {
34514 ptr_info.flags.size = .Slice;34514 ptr_info.flags.size = .slice;
34515 ptr_info.child = pointee.toIntern();34515 ptr_info.child = pointee.toIntern();
34516 break :good;34516 break :good;
34517 }34517 }
34518 if (arr.elem_ty.toIntern() == .noreturn_type) {34518 if (arr.elem_ty.toIntern() == .noreturn_type) {
34519 // []T + *struct{} -> []T34519 // []T + *struct{} -> []T
34520 ptr_info.flags.size = .Slice;34520 ptr_info.flags.size = .slice;
34521 ptr_info.child = peer_info.child;34521 ptr_info.child = peer_info.child;
34522 break :good;34522 break :good;
34523 }34523 }
34524 return generic_err;34524 return generic_err;
34525 },34525 },
34526 .Many => {34526 .many => {
34527 // Impossible! (current peer is an actual slice)34527 // Impossible! (current peer is an actual slice)
34528 return generic_err;34528 return generic_err;
34529 },34529 },
34530 .Slice => {34530 .slice => {
34531 if (try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), Type.fromInterned(peer_info.child))) |pointee| {34531 if (try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), Type.fromInterned(peer_info.child))) |pointee| {
34532 ptr_info.child = pointee.toIntern();34532 ptr_info.child = pointee.toIntern();
34533 break :good;34533 break :good;
34534 }34534 }
34535 return generic_err;34535 return generic_err;
34536 },34536 },
34537 .C => unreachable,34537 .c => unreachable,
34538 },34538 },
34539 .C => unreachable,34539 .c => unreachable,
34540 }34540 }
34541 }34541 }
3454234542
34543 const sentinel_ty = switch (ptr_info.flags.size) {34543 const sentinel_ty = switch (ptr_info.flags.size) {
34544 .One => switch (ip.indexToKey(ptr_info.child)) {34544 .one => switch (ip.indexToKey(ptr_info.child)) {
34545 .array_type => |array_type| array_type.child,34545 .array_type => |array_type| array_type.child,
34546 else => ptr_info.child,34546 else => ptr_info.child,
34547 },34547 },
34548 .Many, .Slice, .C => ptr_info.child,34548 .many, .slice, .c => ptr_info.child,
34549 };34549 };
3455034550
34551 sentinel: {34551 sentinel: {
...@@ -34556,7 +34556,7 @@ fn resolvePeerTypesInner(...@@ -34556,7 +34556,7 @@ fn resolvePeerTypesInner(
34556 const cur_sent_coerced = try ip.getCoerced(sema.gpa, pt.tid, cur_sentinel, sentinel_ty);34556 const cur_sent_coerced = try ip.getCoerced(sema.gpa, pt.tid, cur_sentinel, sentinel_ty);
34557 if (peer_sent_coerced != cur_sent_coerced) break :no_sentinel;34557 if (peer_sent_coerced != cur_sent_coerced) break :no_sentinel;
34558 // Sentinels match34558 // Sentinels match
34559 if (ptr_info.flags.size == .One) switch (ip.indexToKey(ptr_info.child)) {34559 if (ptr_info.flags.size == .one) switch (ip.indexToKey(ptr_info.child)) {
34560 .array_type => |array_type| ptr_info.child = (try pt.arrayType(.{34560 .array_type => |array_type| ptr_info.child = (try pt.arrayType(.{
34561 .len = array_type.len,34561 .len = array_type.len,
34562 .child = array_type.child,34562 .child = array_type.child,
...@@ -35416,8 +35416,8 @@ fn checkMemOperand(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) !void...@@ -35416,8 +35416,8 @@ fn checkMemOperand(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) !void
35416 const zcu = pt.zcu;35416 const zcu = pt.zcu;
35417 if (ty.zigTypeTag(zcu) == .pointer) {35417 if (ty.zigTypeTag(zcu) == .pointer) {
35418 switch (ty.ptrSize(zcu)) {35418 switch (ty.ptrSize(zcu)) {
35419 .Slice, .Many, .C => return,35419 .slice, .many, .c => return,
35420 .One => {35420 .one => {
35421 const elem_ty = ty.childType(zcu);35421 const elem_ty = ty.childType(zcu);
35422 if (elem_ty.zigTypeTag(zcu) == .array) return;35422 if (elem_ty.zigTypeTag(zcu) == .array) return;
35423 // TODO https://github.com/ziglang/zig/issues/1547935423 // TODO https://github.com/ziglang/zig/issues/15479
...@@ -37248,13 +37248,13 @@ fn typePtrOrOptionalPtrTy(sema: *Sema, ty: Type) !?Type {...@@ -37248,13 +37248,13 @@ fn typePtrOrOptionalPtrTy(sema: *Sema, ty: Type) !?Type {
37248 const zcu = pt.zcu;37248 const zcu = pt.zcu;
37249 return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {37249 return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {
37250 .ptr_type => |ptr_type| switch (ptr_type.flags.size) {37250 .ptr_type => |ptr_type| switch (ptr_type.flags.size) {
37251 .One, .Many, .C => ty,37251 .one, .many, .c => ty,
37252 .Slice => null,37252 .slice => null,
37253 },37253 },
37254 .opt_type => |opt_child| switch (zcu.intern_pool.indexToKey(opt_child)) {37254 .opt_type => |opt_child| switch (zcu.intern_pool.indexToKey(opt_child)) {
37255 .ptr_type => |ptr_type| switch (ptr_type.flags.size) {37255 .ptr_type => |ptr_type| switch (ptr_type.flags.size) {
37256 .Slice, .C => null,37256 .slice, .c => null,
37257 .Many, .One => {37257 .many, .one => {
37258 if (ptr_type.flags.is_allowzero) return null;37258 if (ptr_type.flags.is_allowzero) return null;
3725937259
37260 // optionals of zero sized types behave like bools, not pointers37260 // optionals of zero sized types behave like bools, not pointers
...@@ -38260,7 +38260,7 @@ fn maybeDerefSliceAsArray(...@@ -38260,7 +38260,7 @@ fn maybeDerefSliceAsArray(
38260 });38260 });
38261 const ptr_ty = try pt.ptrTypeSema(p: {38261 const ptr_ty = try pt.ptrTypeSema(p: {
38262 var p = Type.fromInterned(slice.ty).ptrInfo(zcu);38262 var p = Type.fromInterned(slice.ty).ptrInfo(zcu);
38263 p.flags.size = .One;38263 p.flags.size = .one;
38264 p.child = array_ty.toIntern();38264 p.child = array_ty.toIntern();
38265 p.sentinel = .none;38265 p.sentinel = .none;
38266 break :p p;38266 break :p p;
src/Type.zig+32-32
...@@ -192,16 +192,16 @@ pub fn print(ty: Type, writer: anytype, pt: Zcu.PerThread) @TypeOf(writer).Error...@@ -192,16 +192,16 @@ pub fn print(ty: Type, writer: anytype, pt: Zcu.PerThread) @TypeOf(writer).Error
192 const info = ty.ptrInfo(zcu);192 const info = ty.ptrInfo(zcu);
193193
194 if (info.sentinel != .none) switch (info.flags.size) {194 if (info.sentinel != .none) switch (info.flags.size) {
195 .One, .C => unreachable,195 .one, .c => unreachable,
196 .Many => try writer.print("[*:{}]", .{Value.fromInterned(info.sentinel).fmtValue(pt)}),196 .many => try writer.print("[*:{}]", .{Value.fromInterned(info.sentinel).fmtValue(pt)}),
197 .Slice => try writer.print("[:{}]", .{Value.fromInterned(info.sentinel).fmtValue(pt)}),197 .slice => try writer.print("[:{}]", .{Value.fromInterned(info.sentinel).fmtValue(pt)}),
198 } else switch (info.flags.size) {198 } else switch (info.flags.size) {
199 .One => try writer.writeAll("*"),199 .one => try writer.writeAll("*"),
200 .Many => try writer.writeAll("[*]"),200 .many => try writer.writeAll("[*]"),
201 .C => try writer.writeAll("[*c]"),201 .c => try writer.writeAll("[*c]"),
202 .Slice => try writer.writeAll("[]"),202 .slice => try writer.writeAll("[]"),
203 }203 }
204 if (info.flags.is_allowzero and info.flags.size != .C) try writer.writeAll("allowzero ");204 if (info.flags.is_allowzero and info.flags.size != .c) try writer.writeAll("allowzero ");
205 if (info.flags.alignment != .none or205 if (info.flags.alignment != .none or
206 info.packed_offset.host_size != 0 or206 info.packed_offset.host_size != 0 or
207 info.flags.vector_index != .none)207 info.flags.vector_index != .none)
...@@ -686,7 +686,7 @@ pub fn hasWellDefinedLayout(ty: Type, zcu: *const Zcu) bool {...@@ -686,7 +686,7 @@ pub fn hasWellDefinedLayout(ty: Type, zcu: *const Zcu) bool {
686686
687 .array_type => |array_type| Type.fromInterned(array_type.child).hasWellDefinedLayout(zcu),687 .array_type => |array_type| Type.fromInterned(array_type.child).hasWellDefinedLayout(zcu),
688 .opt_type => ty.isPtrLikeOptional(zcu),688 .opt_type => ty.isPtrLikeOptional(zcu),
689 .ptr_type => |ptr_type| ptr_type.flags.size != .Slice,689 .ptr_type => |ptr_type| ptr_type.flags.size != .slice,
690690
691 .simple_type => |t| switch (t) {691 .simple_type => |t| switch (t) {
692 .f16,692 .f16,
...@@ -1303,7 +1303,7 @@ pub fn abiSizeInner(...@@ -1303,7 +1303,7 @@ pub fn abiSizeInner(
1303 return .{ .scalar = intAbiSize(int_type.bits, target, use_llvm) };1303 return .{ .scalar = intAbiSize(int_type.bits, target, use_llvm) };
1304 },1304 },
1305 .ptr_type => |ptr_type| switch (ptr_type.flags.size) {1305 .ptr_type => |ptr_type| switch (ptr_type.flags.size) {
1306 .Slice => return .{ .scalar = @divExact(target.ptrBitWidth(), 8) * 2 },1306 .slice => return .{ .scalar = @divExact(target.ptrBitWidth(), 8) * 2 },
1307 else => return .{ .scalar = @divExact(target.ptrBitWidth(), 8) },1307 else => return .{ .scalar = @divExact(target.ptrBitWidth(), 8) },
1308 },1308 },
1309 .anyframe_type => return .{ .scalar = @divExact(target.ptrBitWidth(), 8) },1309 .anyframe_type => return .{ .scalar = @divExact(target.ptrBitWidth(), 8) },
...@@ -1741,7 +1741,7 @@ pub fn bitSizeInner(...@@ -1741,7 +1741,7 @@ pub fn bitSizeInner(
1741 switch (ip.indexToKey(ty.toIntern())) {1741 switch (ip.indexToKey(ty.toIntern())) {
1742 .int_type => |int_type| return int_type.bits,1742 .int_type => |int_type| return int_type.bits,
1743 .ptr_type => |ptr_type| switch (ptr_type.flags.size) {1743 .ptr_type => |ptr_type| switch (ptr_type.flags.size) {
1744 .Slice => return target.ptrBitWidth() * 2,1744 .slice => return target.ptrBitWidth() * 2,
1745 else => return target.ptrBitWidth(),1745 else => return target.ptrBitWidth(),
1746 },1746 },
1747 .anyframe_type => return target.ptrBitWidth(),1747 .anyframe_type => return target.ptrBitWidth(),
...@@ -1903,7 +1903,7 @@ pub fn layoutIsResolved(ty: Type, zcu: *const Zcu) bool {...@@ -1903,7 +1903,7 @@ pub fn layoutIsResolved(ty: Type, zcu: *const Zcu) bool {
19031903
1904pub fn isSinglePointer(ty: Type, zcu: *const Zcu) bool {1904pub fn isSinglePointer(ty: Type, zcu: *const Zcu) bool {
1905 return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {1905 return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {
1906 .ptr_type => |ptr_info| ptr_info.flags.size == .One,1906 .ptr_type => |ptr_info| ptr_info.flags.size == .one,
1907 else => false,1907 else => false,
1908 };1908 };
1909}1909}
...@@ -1923,7 +1923,7 @@ pub fn ptrSizeOrNull(ty: Type, zcu: *const Zcu) ?std.builtin.Type.Pointer.Size {...@@ -1923,7 +1923,7 @@ pub fn ptrSizeOrNull(ty: Type, zcu: *const Zcu) ?std.builtin.Type.Pointer.Size {
19231923
1924pub fn isSlice(ty: Type, zcu: *const Zcu) bool {1924pub fn isSlice(ty: Type, zcu: *const Zcu) bool {
1925 return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {1925 return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {
1926 .ptr_type => |ptr_type| ptr_type.flags.size == .Slice,1926 .ptr_type => |ptr_type| ptr_type.flags.size == .slice,
1927 else => false,1927 else => false,
1928 };1928 };
1929}1929}
...@@ -1960,7 +1960,7 @@ pub fn isAllowzeroPtr(ty: Type, zcu: *const Zcu) bool {...@@ -1960,7 +1960,7 @@ pub fn isAllowzeroPtr(ty: Type, zcu: *const Zcu) bool {
19601960
1961pub fn isCPtr(ty: Type, zcu: *const Zcu) bool {1961pub fn isCPtr(ty: Type, zcu: *const Zcu) bool {
1962 return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {1962 return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {
1963 .ptr_type => |ptr_type| ptr_type.flags.size == .C,1963 .ptr_type => |ptr_type| ptr_type.flags.size == .c,
1964 else => false,1964 else => false,
1965 };1965 };
1966}1966}
...@@ -1968,13 +1968,13 @@ pub fn isCPtr(ty: Type, zcu: *const Zcu) bool {...@@ -1968,13 +1968,13 @@ pub fn isCPtr(ty: Type, zcu: *const Zcu) bool {
1968pub fn isPtrAtRuntime(ty: Type, zcu: *const Zcu) bool {1968pub fn isPtrAtRuntime(ty: Type, zcu: *const Zcu) bool {
1969 return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {1969 return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {
1970 .ptr_type => |ptr_type| switch (ptr_type.flags.size) {1970 .ptr_type => |ptr_type| switch (ptr_type.flags.size) {
1971 .Slice => false,1971 .slice => false,
1972 .One, .Many, .C => true,1972 .one, .many, .c => true,
1973 },1973 },
1974 .opt_type => |child| switch (zcu.intern_pool.indexToKey(child)) {1974 .opt_type => |child| switch (zcu.intern_pool.indexToKey(child)) {
1975 .ptr_type => |p| switch (p.flags.size) {1975 .ptr_type => |p| switch (p.flags.size) {
1976 .Slice, .C => false,1976 .slice, .c => false,
1977 .Many, .One => !p.flags.is_allowzero,1977 .many, .one => !p.flags.is_allowzero,
1978 },1978 },
1979 else => false,1979 else => false,
1980 },1980 },
...@@ -1995,11 +1995,11 @@ pub fn ptrAllowsZero(ty: Type, zcu: *const Zcu) bool {...@@ -1995,11 +1995,11 @@ pub fn ptrAllowsZero(ty: Type, zcu: *const Zcu) bool {
1995pub fn optionalReprIsPayload(ty: Type, zcu: *const Zcu) bool {1995pub fn optionalReprIsPayload(ty: Type, zcu: *const Zcu) bool {
1996 return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {1996 return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {
1997 .opt_type => |child_type| child_type == .anyerror_type or switch (zcu.intern_pool.indexToKey(child_type)) {1997 .opt_type => |child_type| child_type == .anyerror_type or switch (zcu.intern_pool.indexToKey(child_type)) {
1998 .ptr_type => |ptr_type| ptr_type.flags.size != .C and !ptr_type.flags.is_allowzero,1998 .ptr_type => |ptr_type| ptr_type.flags.size != .c and !ptr_type.flags.is_allowzero,
1999 .error_set_type, .inferred_error_set_type => true,1999 .error_set_type, .inferred_error_set_type => true,
2000 else => false,2000 else => false,
2001 },2001 },
2002 .ptr_type => |ptr_type| ptr_type.flags.size == .C,2002 .ptr_type => |ptr_type| ptr_type.flags.size == .c,
2003 else => false,2003 else => false,
2004 };2004 };
2005}2005}
...@@ -2009,11 +2009,11 @@ pub fn optionalReprIsPayload(ty: Type, zcu: *const Zcu) bool {...@@ -2009,11 +2009,11 @@ pub fn optionalReprIsPayload(ty: Type, zcu: *const Zcu) bool {
2009/// This function must be kept in sync with `Sema.typePtrOrOptionalPtrTy`.2009/// This function must be kept in sync with `Sema.typePtrOrOptionalPtrTy`.
2010pub fn isPtrLikeOptional(ty: Type, zcu: *const Zcu) bool {2010pub fn isPtrLikeOptional(ty: Type, zcu: *const Zcu) bool {
2011 return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {2011 return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {
2012 .ptr_type => |ptr_type| ptr_type.flags.size == .C,2012 .ptr_type => |ptr_type| ptr_type.flags.size == .c,
2013 .opt_type => |child| switch (zcu.intern_pool.indexToKey(child)) {2013 .opt_type => |child| switch (zcu.intern_pool.indexToKey(child)) {
2014 .ptr_type => |ptr_type| switch (ptr_type.flags.size) {2014 .ptr_type => |ptr_type| switch (ptr_type.flags.size) {
2015 .Slice, .C => false,2015 .slice, .c => false,
2016 .Many, .One => !ptr_type.flags.is_allowzero,2016 .many, .one => !ptr_type.flags.is_allowzero,
2017 },2017 },
2018 else => false,2018 else => false,
2019 },2019 },
...@@ -2044,8 +2044,8 @@ pub fn childTypeIp(ty: Type, ip: *const InternPool) Type {...@@ -2044,8 +2044,8 @@ pub fn childTypeIp(ty: Type, ip: *const InternPool) Type {
2044pub fn elemType2(ty: Type, zcu: *const Zcu) Type {2044pub fn elemType2(ty: Type, zcu: *const Zcu) Type {
2045 return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {2045 return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {
2046 .ptr_type => |ptr_type| switch (ptr_type.flags.size) {2046 .ptr_type => |ptr_type| switch (ptr_type.flags.size) {
2047 .One => Type.fromInterned(ptr_type.child).shallowElemType(zcu),2047 .one => Type.fromInterned(ptr_type.child).shallowElemType(zcu),
2048 .Many, .C, .Slice => Type.fromInterned(ptr_type.child),2048 .many, .c, .slice => Type.fromInterned(ptr_type.child),
2049 },2049 },
2050 .anyframe_type => |child| {2050 .anyframe_type => |child| {
2051 assert(child != .none);2051 assert(child != .none);
...@@ -2079,7 +2079,7 @@ pub fn optionalChild(ty: Type, zcu: *const Zcu) Type {...@@ -2079,7 +2079,7 @@ pub fn optionalChild(ty: Type, zcu: *const Zcu) Type {
2079 return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {2079 return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {
2080 .opt_type => |child| Type.fromInterned(child),2080 .opt_type => |child| Type.fromInterned(child),
2081 .ptr_type => |ptr_type| b: {2081 .ptr_type => |ptr_type| b: {
2082 assert(ptr_type.flags.size == .C);2082 assert(ptr_type.flags.size == .c);
2083 break :b ty;2083 break :b ty;
2084 },2084 },
2085 else => unreachable,2085 else => unreachable,
...@@ -2991,8 +2991,8 @@ pub fn isIndexable(ty: Type, zcu: *const Zcu) bool {...@@ -2991,8 +2991,8 @@ pub fn isIndexable(ty: Type, zcu: *const Zcu) bool {
2991 return switch (ty.zigTypeTag(zcu)) {2991 return switch (ty.zigTypeTag(zcu)) {
2992 .array, .vector => true,2992 .array, .vector => true,
2993 .pointer => switch (ty.ptrSize(zcu)) {2993 .pointer => switch (ty.ptrSize(zcu)) {
2994 .Slice, .Many, .C => true,2994 .slice, .many, .c => true,
2995 .One => switch (ty.childType(zcu).zigTypeTag(zcu)) {2995 .one => switch (ty.childType(zcu).zigTypeTag(zcu)) {
2996 .array, .vector => true,2996 .array, .vector => true,
2997 .@"struct" => ty.childType(zcu).isTuple(zcu),2997 .@"struct" => ty.childType(zcu).isTuple(zcu),
2998 else => false,2998 else => false,
...@@ -3007,9 +3007,9 @@ pub fn indexableHasLen(ty: Type, zcu: *const Zcu) bool {...@@ -3007,9 +3007,9 @@ pub fn indexableHasLen(ty: Type, zcu: *const Zcu) bool {
3007 return switch (ty.zigTypeTag(zcu)) {3007 return switch (ty.zigTypeTag(zcu)) {
3008 .array, .vector => true,3008 .array, .vector => true,
3009 .pointer => switch (ty.ptrSize(zcu)) {3009 .pointer => switch (ty.ptrSize(zcu)) {
3010 .Many, .C => false,3010 .many, .c => false,
3011 .Slice => true,3011 .slice => true,
3012 .One => switch (ty.childType(zcu).zigTypeTag(zcu)) {3012 .one => switch (ty.childType(zcu).zigTypeTag(zcu)) {
3013 .array, .vector => true,3013 .array, .vector => true,
3014 .@"struct" => ty.childType(zcu).isTuple(zcu),3014 .@"struct" => ty.childType(zcu).isTuple(zcu),
3015 else => false,3015 else => false,
...@@ -4049,7 +4049,7 @@ pub fn elemPtrType(ptr_ty: Type, offset: ?usize, pt: Zcu.PerThread) !Type {...@@ -4049,7 +4049,7 @@ pub fn elemPtrType(ptr_ty: Type, offset: ?usize, pt: Zcu.PerThread) !Type {
4049 host_size: u16 = 0,4049 host_size: u16 = 0,
4050 alignment: Alignment = .none,4050 alignment: Alignment = .none,
4051 vector_index: VI = .none,4051 vector_index: VI = .none,
4052 } = if (parent_ty.isVector(zcu) and ptr_info.flags.size == .One) blk: {4052 } = if (parent_ty.isVector(zcu) and ptr_info.flags.size == .one) blk: {
4053 const elem_bits = elem_ty.bitSize(zcu);4053 const elem_bits = elem_ty.bitSize(zcu);
4054 if (elem_bits == 0) break :blk .{};4054 if (elem_bits == 0) break :blk .{};
4055 const is_packed = elem_bits < 8 or !std.math.isPowerOfTwo(elem_bits);4055 const is_packed = elem_bits < 8 or !std.math.isPowerOfTwo(elem_bits);
src/Value.zig+16-16
...@@ -3724,7 +3724,7 @@ pub fn ptrOptPayload(parent_ptr: Value, pt: Zcu.PerThread) !Value {...@@ -3724,7 +3724,7 @@ pub fn ptrOptPayload(parent_ptr: Value, pt: Zcu.PerThread) !Value {
3724 const parent_ptr_ty = parent_ptr.typeOf(zcu);3724 const parent_ptr_ty = parent_ptr.typeOf(zcu);
3725 const opt_ty = parent_ptr_ty.childType(zcu);3725 const opt_ty = parent_ptr_ty.childType(zcu);
37263726
3727 assert(parent_ptr_ty.ptrSize(zcu) == .One);3727 assert(parent_ptr_ty.ptrSize(zcu) == .one);
3728 assert(opt_ty.zigTypeTag(zcu) == .optional);3728 assert(opt_ty.zigTypeTag(zcu) == .optional);
37293729
3730 const result_ty = try pt.ptrTypeSema(info: {3730 const result_ty = try pt.ptrTypeSema(info: {
...@@ -3742,7 +3742,7 @@ pub fn ptrOptPayload(parent_ptr: Value, pt: Zcu.PerThread) !Value {...@@ -3742,7 +3742,7 @@ pub fn ptrOptPayload(parent_ptr: Value, pt: Zcu.PerThread) !Value {
3742 return pt.getCoerced(parent_ptr, result_ty);3742 return pt.getCoerced(parent_ptr, result_ty);
3743 }3743 }
37443744
3745 const base_ptr = try parent_ptr.canonicalizeBasePtr(.One, opt_ty, pt);3745 const base_ptr = try parent_ptr.canonicalizeBasePtr(.one, opt_ty, pt);
3746 return Value.fromInterned(try pt.intern(.{ .ptr = .{3746 return Value.fromInterned(try pt.intern(.{ .ptr = .{
3747 .ty = result_ty.toIntern(),3747 .ty = result_ty.toIntern(),
3748 .base_addr = .{ .opt_payload = base_ptr.toIntern() },3748 .base_addr = .{ .opt_payload = base_ptr.toIntern() },
...@@ -3758,7 +3758,7 @@ pub fn ptrEuPayload(parent_ptr: Value, pt: Zcu.PerThread) !Value {...@@ -3758,7 +3758,7 @@ pub fn ptrEuPayload(parent_ptr: Value, pt: Zcu.PerThread) !Value {
3758 const parent_ptr_ty = parent_ptr.typeOf(zcu);3758 const parent_ptr_ty = parent_ptr.typeOf(zcu);
3759 const eu_ty = parent_ptr_ty.childType(zcu);3759 const eu_ty = parent_ptr_ty.childType(zcu);
37603760
3761 assert(parent_ptr_ty.ptrSize(zcu) == .One);3761 assert(parent_ptr_ty.ptrSize(zcu) == .one);
3762 assert(eu_ty.zigTypeTag(zcu) == .error_union);3762 assert(eu_ty.zigTypeTag(zcu) == .error_union);
37633763
3764 const result_ty = try pt.ptrTypeSema(info: {3764 const result_ty = try pt.ptrTypeSema(info: {
...@@ -3771,7 +3771,7 @@ pub fn ptrEuPayload(parent_ptr: Value, pt: Zcu.PerThread) !Value {...@@ -3771,7 +3771,7 @@ pub fn ptrEuPayload(parent_ptr: Value, pt: Zcu.PerThread) !Value {
37713771
3772 if (parent_ptr.isUndef(zcu)) return pt.undefValue(result_ty);3772 if (parent_ptr.isUndef(zcu)) return pt.undefValue(result_ty);
37733773
3774 const base_ptr = try parent_ptr.canonicalizeBasePtr(.One, eu_ty, pt);3774 const base_ptr = try parent_ptr.canonicalizeBasePtr(.one, eu_ty, pt);
3775 return Value.fromInterned(try pt.intern(.{ .ptr = .{3775 return Value.fromInterned(try pt.intern(.{ .ptr = .{
3776 .ty = result_ty.toIntern(),3776 .ty = result_ty.toIntern(),
3777 .base_addr = .{ .eu_payload = base_ptr.toIntern() },3777 .base_addr = .{ .eu_payload = base_ptr.toIntern() },
...@@ -3789,7 +3789,7 @@ pub fn ptrField(parent_ptr: Value, field_idx: u32, pt: Zcu.PerThread) !Value {...@@ -3789,7 +3789,7 @@ pub fn ptrField(parent_ptr: Value, field_idx: u32, pt: Zcu.PerThread) !Value {
3789 const aggregate_ty = parent_ptr_ty.childType(zcu);3789 const aggregate_ty = parent_ptr_ty.childType(zcu);
37903790
3791 const parent_ptr_info = parent_ptr_ty.ptrInfo(zcu);3791 const parent_ptr_info = parent_ptr_ty.ptrInfo(zcu);
3792 assert(parent_ptr_info.flags.size == .One);3792 assert(parent_ptr_info.flags.size == .one);
37933793
3794 // Exiting this `switch` indicates that the `field` pointer representation should be used.3794 // Exiting this `switch` indicates that the `field` pointer representation should be used.
3795 // `field_align` may be `.none` to represent the natural alignment of `field_ty`, but is not necessarily.3795 // `field_align` may be `.none` to represent the natural alignment of `field_ty`, but is not necessarily.
...@@ -3920,7 +3920,7 @@ pub fn ptrField(parent_ptr: Value, field_idx: u32, pt: Zcu.PerThread) !Value {...@@ -3920,7 +3920,7 @@ pub fn ptrField(parent_ptr: Value, field_idx: u32, pt: Zcu.PerThread) !Value {
39203920
3921 if (parent_ptr.isUndef(zcu)) return pt.undefValue(result_ty);3921 if (parent_ptr.isUndef(zcu)) return pt.undefValue(result_ty);
39223922
3923 const base_ptr = try parent_ptr.canonicalizeBasePtr(.One, aggregate_ty, pt);3923 const base_ptr = try parent_ptr.canonicalizeBasePtr(.one, aggregate_ty, pt);
3924 return Value.fromInterned(try pt.intern(.{ .ptr = .{3924 return Value.fromInterned(try pt.intern(.{ .ptr = .{
3925 .ty = result_ty.toIntern(),3925 .ty = result_ty.toIntern(),
3926 .base_addr = .{ .field = .{3926 .base_addr = .{ .field = .{
...@@ -3937,8 +3937,8 @@ pub fn ptrField(parent_ptr: Value, field_idx: u32, pt: Zcu.PerThread) !Value {...@@ -3937,8 +3937,8 @@ pub fn ptrField(parent_ptr: Value, field_idx: u32, pt: Zcu.PerThread) !Value {
3937pub fn ptrElem(orig_parent_ptr: Value, field_idx: u64, pt: Zcu.PerThread) !Value {3937pub fn ptrElem(orig_parent_ptr: Value, field_idx: u64, pt: Zcu.PerThread) !Value {
3938 const zcu = pt.zcu;3938 const zcu = pt.zcu;
3939 const parent_ptr = switch (orig_parent_ptr.typeOf(zcu).ptrSize(zcu)) {3939 const parent_ptr = switch (orig_parent_ptr.typeOf(zcu).ptrSize(zcu)) {
3940 .One, .Many, .C => orig_parent_ptr,3940 .one, .many, .c => orig_parent_ptr,
3941 .Slice => orig_parent_ptr.slicePtr(zcu),3941 .slice => orig_parent_ptr.slicePtr(zcu),
3942 };3942 };
39433943
3944 const parent_ptr_ty = parent_ptr.typeOf(zcu);3944 const parent_ptr_ty = parent_ptr.typeOf(zcu);
...@@ -3959,7 +3959,7 @@ pub fn ptrElem(orig_parent_ptr: Value, field_idx: u64, pt: Zcu.PerThread) !Value...@@ -3959,7 +3959,7 @@ pub fn ptrElem(orig_parent_ptr: Value, field_idx: u64, pt: Zcu.PerThread) !Value
3959 };3959 };
39603960
3961 const strat: PtrStrat = switch (parent_ptr_ty.ptrSize(zcu)) {3961 const strat: PtrStrat = switch (parent_ptr_ty.ptrSize(zcu)) {
3962 .One => switch (elem_ty.zigTypeTag(zcu)) {3962 .one => switch (elem_ty.zigTypeTag(zcu)) {
3963 .vector => .{ .offset = field_idx * @divExact(try elem_ty.childType(zcu).bitSizeSema(pt), 8) },3963 .vector => .{ .offset = field_idx * @divExact(try elem_ty.childType(zcu).bitSizeSema(pt), 8) },
3964 .array => strat: {3964 .array => strat: {
3965 const arr_elem_ty = elem_ty.childType(zcu);3965 const arr_elem_ty = elem_ty.childType(zcu);
...@@ -3971,12 +3971,12 @@ pub fn ptrElem(orig_parent_ptr: Value, field_idx: u64, pt: Zcu.PerThread) !Value...@@ -3971,12 +3971,12 @@ pub fn ptrElem(orig_parent_ptr: Value, field_idx: u64, pt: Zcu.PerThread) !Value
3971 else => unreachable,3971 else => unreachable,
3972 },3972 },
39733973
3974 .Many, .C => if (try elem_ty.comptimeOnlySema(pt))3974 .many, .c => if (try elem_ty.comptimeOnlySema(pt))
3975 .{ .elem_ptr = elem_ty }3975 .{ .elem_ptr = elem_ty }
3976 else3976 else
3977 .{ .offset = field_idx * (try elem_ty.abiSizeInner(.sema, zcu, pt.tid)).scalar },3977 .{ .offset = field_idx * (try elem_ty.abiSizeInner(.sema, zcu, pt.tid)).scalar },
39783978
3979 .Slice => unreachable,3979 .slice => unreachable,
3980 };3980 };
39813981
3982 switch (strat) {3982 switch (strat) {
...@@ -4004,7 +4004,7 @@ pub fn ptrElem(orig_parent_ptr: Value, field_idx: u64, pt: Zcu.PerThread) !Value...@@ -4004,7 +4004,7 @@ pub fn ptrElem(orig_parent_ptr: Value, field_idx: u64, pt: Zcu.PerThread) !Value
4004 },4004 },
4005 else => {},4005 else => {},
4006 }4006 }
4007 const base_ptr = try parent_ptr.canonicalizeBasePtr(.Many, arr_base_ty, pt);4007 const base_ptr = try parent_ptr.canonicalizeBasePtr(.many, arr_base_ty, pt);
4008 return Value.fromInterned(try pt.intern(.{ .ptr = .{4008 return Value.fromInterned(try pt.intern(.{ .ptr = .{
4009 .ty = result_ty.toIntern(),4009 .ty = result_ty.toIntern(),
4010 .base_addr = .{ .arr_elem = .{4010 .base_addr = .{ .arr_elem = .{
...@@ -4234,7 +4234,7 @@ pub fn pointerDerivationAdvanced(ptr_val: Value, arena: Allocator, pt: Zcu.PerTh...@@ -4234,7 +4234,7 @@ pub fn pointerDerivationAdvanced(ptr_val: Value, arena: Allocator, pt: Zcu.PerTh
4234 .child = parent_ptr_info.child,4234 .child = parent_ptr_info.child,
4235 .flags = flags: {4235 .flags = flags: {
4236 var flags = parent_ptr_info.flags;4236 var flags = parent_ptr_info.flags;
4237 flags.size = .One;4237 flags.size = .one;
4238 break :flags flags;4238 break :flags flags;
4239 },4239 },
4240 });4240 });
...@@ -4304,8 +4304,8 @@ pub fn pointerDerivationAdvanced(ptr_val: Value, arena: Allocator, pt: Zcu.PerTh...@@ -4304,8 +4304,8 @@ pub fn pointerDerivationAdvanced(ptr_val: Value, arena: Allocator, pt: Zcu.PerTh
4304 if (!cur_ty.isPtrLikeOptional(zcu)) break :ptr_opt;4304 if (!cur_ty.isPtrLikeOptional(zcu)) break :ptr_opt;
4305 if (need_child.zigTypeTag(zcu) != .pointer) break :ptr_opt;4305 if (need_child.zigTypeTag(zcu) != .pointer) break :ptr_opt;
4306 switch (need_child.ptrSize(zcu)) {4306 switch (need_child.ptrSize(zcu)) {
4307 .One, .Many => {},4307 .one, .many => {},
4308 .Slice, .C => break :ptr_opt,4308 .slice, .c => break :ptr_opt,
4309 }4309 }
4310 const parent = try arena.create(PointerDeriveStep);4310 const parent = try arena.create(PointerDeriveStep);
4311 parent.* = cur_derive;4311 parent.* = cur_derive;
...@@ -4323,7 +4323,7 @@ pub fn pointerDerivationAdvanced(ptr_val: Value, arena: Allocator, pt: Zcu.PerTh...@@ -4323,7 +4323,7 @@ pub fn pointerDerivationAdvanced(ptr_val: Value, arena: Allocator, pt: Zcu.PerTh
4323 const elem_size = elem_ty.abiSize(zcu);4323 const elem_size = elem_ty.abiSize(zcu);
4324 const start_idx = cur_offset / elem_size;4324 const start_idx = cur_offset / elem_size;
4325 const end_idx = (cur_offset + need_bytes + elem_size - 1) / elem_size;4325 const end_idx = (cur_offset + need_bytes + elem_size - 1) / elem_size;
4326 if (end_idx == start_idx + 1 and ptr_ty_info.flags.size == .One) {4326 if (end_idx == start_idx + 1 and ptr_ty_info.flags.size == .one) {
4327 const parent = try arena.create(PointerDeriveStep);4327 const parent = try arena.create(PointerDeriveStep);
4328 parent.* = cur_derive;4328 parent.* = cur_derive;
4329 cur_derive = .{ .elem_ptr = .{4329 cur_derive = .{ .elem_ptr = .{
src/Zcu/PerThread.zig+3-3
...@@ -3068,7 +3068,7 @@ pub fn populateTestFunctions(...@@ -3068,7 +3068,7 @@ pub fn populateTestFunctions(
3068 .child = test_fn_ty.toIntern(),3068 .child = test_fn_ty.toIntern(),
3069 .flags = .{3069 .flags = .{
3070 .is_const = true,3070 .is_const = true,
3071 .size = .Slice,3071 .size = .slice,
3072 },3072 },
3073 });3073 });
3074 const new_init = try pt.intern(.{ .slice = .{3074 const new_init = try pt.intern(.{ .slice = .{
...@@ -3303,7 +3303,7 @@ pub fn optionalType(pt: Zcu.PerThread, child_type: InternPool.Index) Allocator.E...@@ -3303,7 +3303,7 @@ pub fn optionalType(pt: Zcu.PerThread, child_type: InternPool.Index) Allocator.E
3303pub fn ptrType(pt: Zcu.PerThread, info: InternPool.Key.PtrType) Allocator.Error!Type {3303pub fn ptrType(pt: Zcu.PerThread, info: InternPool.Key.PtrType) Allocator.Error!Type {
3304 var canon_info = info;3304 var canon_info = info;
33053305
3306 if (info.flags.size == .C) canon_info.flags.is_allowzero = true;3306 if (info.flags.size == .c) canon_info.flags.is_allowzero = true;
33073307
3308 // Canonicalize non-zero alignment. If it matches the ABI alignment of the pointee3308 // Canonicalize non-zero alignment. If it matches the ABI alignment of the pointee
3309 // type, we change it to 0 here. If this causes an assertion trip because the3309 // type, we change it to 0 here. If this causes an assertion trip because the
...@@ -3360,7 +3360,7 @@ pub fn manyConstPtrType(pt: Zcu.PerThread, child_type: Type) Allocator.Error!Typ...@@ -3360,7 +3360,7 @@ pub fn manyConstPtrType(pt: Zcu.PerThread, child_type: Type) Allocator.Error!Typ
3360 return pt.ptrType(.{3360 return pt.ptrType(.{
3361 .child = child_type.toIntern(),3361 .child = child_type.toIntern(),
3362 .flags = .{3362 .flags = .{
3363 .size = .Many,3363 .size = .many,
3364 .is_const = true,3364 .is_const = true,
3365 },3365 },
3366 });3366 });
src/arch/aarch64/CodeGen.zig+1-1
...@@ -2398,7 +2398,7 @@ fn ptrArithmetic(...@@ -2398,7 +2398,7 @@ fn ptrArithmetic(
23982398
2399 const ptr_ty = lhs_ty;2399 const ptr_ty = lhs_ty;
2400 const elem_ty = switch (ptr_ty.ptrSize(zcu)) {2400 const elem_ty = switch (ptr_ty.ptrSize(zcu)) {
2401 .One => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type2401 .one => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type
2402 else => ptr_ty.childType(zcu),2402 else => ptr_ty.childType(zcu),
2403 };2403 };
2404 const elem_size = elem_ty.abiSize(zcu);2404 const elem_size = elem_ty.abiSize(zcu);
src/arch/arm/CodeGen.zig+1-1
...@@ -3919,7 +3919,7 @@ fn ptrArithmetic(...@@ -3919,7 +3919,7 @@ fn ptrArithmetic(
39193919
3920 const ptr_ty = lhs_ty;3920 const ptr_ty = lhs_ty;
3921 const elem_ty = switch (ptr_ty.ptrSize(zcu)) {3921 const elem_ty = switch (ptr_ty.ptrSize(zcu)) {
3922 .One => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type3922 .one => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type
3923 else => ptr_ty.childType(zcu),3923 else => ptr_ty.childType(zcu),
3924 };3924 };
3925 const elem_size: u32 = @intCast(elem_ty.abiSize(zcu));3925 const elem_size: u32 = @intCast(elem_ty.abiSize(zcu));
src/arch/riscv64/CodeGen.zig+11-11
...@@ -7843,15 +7843,15 @@ fn airMemset(func: *Func, inst: Air.Inst.Index, safety: bool) !void {...@@ -7843,15 +7843,15 @@ fn airMemset(func: *Func, inst: Air.Inst.Index, safety: bool) !void {
7843 if (elem_abi_size == 1) {7843 if (elem_abi_size == 1) {
7844 const ptr: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) {7844 const ptr: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) {
7845 // TODO: this only handles slices stored in the stack7845 // TODO: this only handles slices stored in the stack
7846 .Slice => dst_ptr,7846 .slice => dst_ptr,
7847 .One => dst_ptr,7847 .one => dst_ptr,
7848 .C, .Many => unreachable,7848 .c, .many => unreachable,
7849 };7849 };
7850 const len: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) {7850 const len: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) {
7851 // TODO: this only handles slices stored in the stack7851 // TODO: this only handles slices stored in the stack
7852 .Slice => dst_ptr.address().offset(8).deref(),7852 .slice => dst_ptr.address().offset(8).deref(),
7853 .One => .{ .immediate = dst_ptr_ty.childType(zcu).arrayLen(zcu) },7853 .one => .{ .immediate = dst_ptr_ty.childType(zcu).arrayLen(zcu) },
7854 .C, .Many => unreachable,7854 .c, .many => unreachable,
7855 };7855 };
7856 const len_lock: ?RegisterLock = switch (len) {7856 const len_lock: ?RegisterLock = switch (len) {
7857 .register => |reg| func.register_manager.lockRegAssumeUnused(reg),7857 .register => |reg| func.register_manager.lockRegAssumeUnused(reg),
...@@ -7867,8 +7867,8 @@ fn airMemset(func: *Func, inst: Air.Inst.Index, safety: bool) !void {...@@ -7867,8 +7867,8 @@ fn airMemset(func: *Func, inst: Air.Inst.Index, safety: bool) !void {
7867 // Length zero requires a runtime check - so we handle arrays specially7867 // Length zero requires a runtime check - so we handle arrays specially
7868 // here to elide it.7868 // here to elide it.
7869 switch (dst_ptr_ty.ptrSize(zcu)) {7869 switch (dst_ptr_ty.ptrSize(zcu)) {
7870 .Slice => return func.fail("TODO: airMemset Slices", .{}),7870 .slice => return func.fail("TODO: airMemset Slices", .{}),
7871 .One => {7871 .one => {
7872 const elem_ptr_ty = try pt.singleMutPtrType(elem_ty);7872 const elem_ptr_ty = try pt.singleMutPtrType(elem_ty);
78737873
7874 const len = dst_ptr_ty.childType(zcu).arrayLen(zcu);7874 const len = dst_ptr_ty.childType(zcu).arrayLen(zcu);
...@@ -7889,7 +7889,7 @@ fn airMemset(func: *Func, inst: Air.Inst.Index, safety: bool) !void {...@@ -7889,7 +7889,7 @@ fn airMemset(func: *Func, inst: Air.Inst.Index, safety: bool) !void {
7889 const bytes_to_copy: MCValue = .{ .immediate = elem_abi_size * (len - 1) };7889 const bytes_to_copy: MCValue = .{ .immediate = elem_abi_size * (len - 1) };
7890 try func.genInlineMemcpy(second_elem_ptr_mcv, dst_ptr, bytes_to_copy);7890 try func.genInlineMemcpy(second_elem_ptr_mcv, dst_ptr, bytes_to_copy);
7891 },7891 },
7892 .C, .Many => unreachable,7892 .c, .many => unreachable,
7893 }7893 }
7894 }7894 }
7895 return func.finishAir(inst, .unreach, .{ bin_op.lhs, bin_op.rhs, .none });7895 return func.finishAir(inst, .unreach, .{ bin_op.lhs, bin_op.rhs, .none });
...@@ -7906,7 +7906,7 @@ fn airMemcpy(func: *Func, inst: Air.Inst.Index) !void {...@@ -7906,7 +7906,7 @@ fn airMemcpy(func: *Func, inst: Air.Inst.Index) !void {
7906 const dst_ty = func.typeOf(bin_op.lhs);7906 const dst_ty = func.typeOf(bin_op.lhs);
79077907
7908 const len_mcv: MCValue = switch (dst_ty.ptrSize(zcu)) {7908 const len_mcv: MCValue = switch (dst_ty.ptrSize(zcu)) {
7909 .Slice => len: {7909 .slice => len: {
7910 const len_reg, const len_lock = try func.allocReg(.int);7910 const len_reg, const len_lock = try func.allocReg(.int);
7911 defer func.register_manager.unlockReg(len_lock);7911 defer func.register_manager.unlockReg(len_lock);
79127912
...@@ -7921,7 +7921,7 @@ fn airMemcpy(func: *Func, inst: Air.Inst.Index) !void {...@@ -7921,7 +7921,7 @@ fn airMemcpy(func: *Func, inst: Air.Inst.Index) !void {
7921 );7921 );
7922 break :len .{ .register = len_reg };7922 break :len .{ .register = len_reg };
7923 },7923 },
7924 .One => len: {7924 .one => len: {
7925 const array_ty = dst_ty.childType(zcu);7925 const array_ty = dst_ty.childType(zcu);
7926 break :len .{ .immediate = array_ty.arrayLen(zcu) * array_ty.childType(zcu).abiSize(zcu) };7926 break :len .{ .immediate = array_ty.arrayLen(zcu) * array_ty.childType(zcu).abiSize(zcu) };
7927 },7927 },
src/arch/riscv64/abi.zig+1-1
...@@ -109,7 +109,7 @@ pub fn classifySystem(ty: Type, zcu: *Zcu) [8]SystemClass {...@@ -109,7 +109,7 @@ pub fn classifySystem(ty: Type, zcu: *Zcu) [8]SystemClass {
109 return result;109 return result;
110 },110 },
111 .pointer => switch (ty.ptrSize(zcu)) {111 .pointer => switch (ty.ptrSize(zcu)) {
112 .Slice => {112 .slice => {
113 result[0] = .integer;113 result[0] = .integer;
114 result[1] = .integer;114 result[1] = .integer;
115 return result;115 return result;
src/arch/sparc64/CodeGen.zig+1-1
...@@ -2953,7 +2953,7 @@ fn binOp(...@@ -2953,7 +2953,7 @@ fn binOp(
2953 .pointer => {2953 .pointer => {
2954 const ptr_ty = lhs_ty;2954 const ptr_ty = lhs_ty;
2955 const elem_ty = switch (ptr_ty.ptrSize(zcu)) {2955 const elem_ty = switch (ptr_ty.ptrSize(zcu)) {
2956 .One => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type2956 .one => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type
2957 else => ptr_ty.childType(zcu),2957 else => ptr_ty.childType(zcu),
2958 };2958 };
2959 const elem_size = elem_ty.abiSize(zcu);2959 const elem_size = elem_ty.abiSize(zcu);
src/arch/wasm/CodeGen.zig+8-8
...@@ -4726,7 +4726,7 @@ fn airPtrBinOp(cg: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {...@@ -4726,7 +4726,7 @@ fn airPtrBinOp(cg: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {
4726 const offset = try cg.resolveInst(bin_op.rhs);4726 const offset = try cg.resolveInst(bin_op.rhs);
4727 const ptr_ty = cg.typeOf(bin_op.lhs);4727 const ptr_ty = cg.typeOf(bin_op.lhs);
4728 const pointee_ty = switch (ptr_ty.ptrSize(zcu)) {4728 const pointee_ty = switch (ptr_ty.ptrSize(zcu)) {
4729 .One => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type4729 .one => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type
4730 else => ptr_ty.childType(zcu),4730 else => ptr_ty.childType(zcu),
4731 };4731 };
47324732
...@@ -4756,12 +4756,12 @@ fn airMemset(cg: *CodeGen, inst: Air.Inst.Index, safety: bool) InnerError!void {...@@ -4756,12 +4756,12 @@ fn airMemset(cg: *CodeGen, inst: Air.Inst.Index, safety: bool) InnerError!void {
4756 const ptr_ty = cg.typeOf(bin_op.lhs);4756 const ptr_ty = cg.typeOf(bin_op.lhs);
4757 const value = try cg.resolveInst(bin_op.rhs);4757 const value = try cg.resolveInst(bin_op.rhs);
4758 const len = switch (ptr_ty.ptrSize(zcu)) {4758 const len = switch (ptr_ty.ptrSize(zcu)) {
4759 .Slice => try cg.sliceLen(ptr),4759 .slice => try cg.sliceLen(ptr),
4760 .One => @as(WValue, .{ .imm32 = @as(u32, @intCast(ptr_ty.childType(zcu).arrayLen(zcu))) }),4760 .one => @as(WValue, .{ .imm32 = @as(u32, @intCast(ptr_ty.childType(zcu).arrayLen(zcu))) }),
4761 .C, .Many => unreachable,4761 .c, .many => unreachable,
4762 };4762 };
47634763
4764 const elem_ty = if (ptr_ty.ptrSize(zcu) == .One)4764 const elem_ty = if (ptr_ty.ptrSize(zcu) == .one)
4765 ptr_ty.childType(zcu).childType(zcu)4765 ptr_ty.childType(zcu).childType(zcu)
4766 else4766 else
4767 ptr_ty.childType(zcu);4767 ptr_ty.childType(zcu);
...@@ -5688,7 +5688,7 @@ fn airMemcpy(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -5688,7 +5688,7 @@ fn airMemcpy(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5688 const src = try cg.resolveInst(bin_op.rhs);5688 const src = try cg.resolveInst(bin_op.rhs);
5689 const src_ty = cg.typeOf(bin_op.rhs);5689 const src_ty = cg.typeOf(bin_op.rhs);
5690 const len = switch (dst_ty.ptrSize(zcu)) {5690 const len = switch (dst_ty.ptrSize(zcu)) {
5691 .Slice => blk: {5691 .slice => blk: {
5692 const slice_len = try cg.sliceLen(dst);5692 const slice_len = try cg.sliceLen(dst);
5693 if (ptr_elem_ty.abiSize(zcu) != 1) {5693 if (ptr_elem_ty.abiSize(zcu) != 1) {
5694 try cg.emitWValue(slice_len);5694 try cg.emitWValue(slice_len);
...@@ -5698,10 +5698,10 @@ fn airMemcpy(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -5698,10 +5698,10 @@ fn airMemcpy(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5698 }5698 }
5699 break :blk slice_len;5699 break :blk slice_len;
5700 },5700 },
5701 .One => @as(WValue, .{5701 .one => @as(WValue, .{
5702 .imm32 = @as(u32, @intCast(ptr_elem_ty.arrayLen(zcu) * ptr_elem_ty.childType(zcu).abiSize(zcu))),5702 .imm32 = @as(u32, @intCast(ptr_elem_ty.arrayLen(zcu) * ptr_elem_ty.childType(zcu).abiSize(zcu))),
5703 }),5703 }),
5704 .C, .Many => unreachable,5704 .c, .many => unreachable,
5705 };5705 };
5706 const dst_ptr = try cg.sliceOrArrayPtr(dst, dst_ty);5706 const dst_ptr = try cg.sliceOrArrayPtr(dst, dst_ty);
5707 const src_ptr = try cg.sliceOrArrayPtr(src, src_ty);5707 const src_ptr = try cg.sliceOrArrayPtr(src, src_ty);
src/arch/x86_64/CodeGen.zig+14-14
...@@ -9607,13 +9607,13 @@ fn genMulDivBinOp(...@@ -9607,13 +9607,13 @@ fn genMulDivBinOp(
9607 const manyptr_u32_ty = try pt.ptrType(.{9607 const manyptr_u32_ty = try pt.ptrType(.{
9608 .child = .u32_type,9608 .child = .u32_type,
9609 .flags = .{9609 .flags = .{
9610 .size = .Many,9610 .size = .many,
9611 },9611 },
9612 });9612 });
9613 const manyptr_const_u32_ty = try pt.ptrType(.{9613 const manyptr_const_u32_ty = try pt.ptrType(.{
9614 .child = .u32_type,9614 .child = .u32_type,
9615 .flags = .{9615 .flags = .{
9616 .size = .Many,9616 .size = .many,
9617 .is_const = true,9617 .is_const = true,
9618 },9618 },
9619 });9619 });
...@@ -16614,15 +16614,15 @@ fn airMemset(self: *Self, inst: Air.Inst.Index, safety: bool) !void {...@@ -16614,15 +16614,15 @@ fn airMemset(self: *Self, inst: Air.Inst.Index, safety: bool) !void {
16614 if (elem_abi_size == 1) {16614 if (elem_abi_size == 1) {
16615 const ptr: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) {16615 const ptr: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) {
16616 // TODO: this only handles slices stored in the stack16616 // TODO: this only handles slices stored in the stack
16617 .Slice => dst_ptr,16617 .slice => dst_ptr,
16618 .One => dst_ptr,16618 .one => dst_ptr,
16619 .C, .Many => unreachable,16619 .c, .many => unreachable,
16620 };16620 };
16621 const len: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) {16621 const len: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) {
16622 // TODO: this only handles slices stored in the stack16622 // TODO: this only handles slices stored in the stack
16623 .Slice => dst_ptr.address().offset(8).deref(),16623 .slice => dst_ptr.address().offset(8).deref(),
16624 .One => .{ .immediate = dst_ptr_ty.childType(zcu).arrayLen(zcu) },16624 .one => .{ .immediate = dst_ptr_ty.childType(zcu).arrayLen(zcu) },
16625 .C, .Many => unreachable,16625 .c, .many => unreachable,
16626 };16626 };
16627 const len_lock: ?RegisterLock = switch (len) {16627 const len_lock: ?RegisterLock = switch (len) {
16628 .register => |reg| self.register_manager.lockRegAssumeUnused(reg),16628 .register => |reg| self.register_manager.lockRegAssumeUnused(reg),
...@@ -16638,7 +16638,7 @@ fn airMemset(self: *Self, inst: Air.Inst.Index, safety: bool) !void {...@@ -16638,7 +16638,7 @@ fn airMemset(self: *Self, inst: Air.Inst.Index, safety: bool) !void {
16638 // Length zero requires a runtime check - so we handle arrays specially16638 // Length zero requires a runtime check - so we handle arrays specially
16639 // here to elide it.16639 // here to elide it.
16640 switch (dst_ptr_ty.ptrSize(zcu)) {16640 switch (dst_ptr_ty.ptrSize(zcu)) {
16641 .Slice => {16641 .slice => {
16642 const slice_ptr_ty = dst_ptr_ty.slicePtrFieldType(zcu);16642 const slice_ptr_ty = dst_ptr_ty.slicePtrFieldType(zcu);
1664316643
16644 // TODO: this only handles slices stored in the stack16644 // TODO: this only handles slices stored in the stack
...@@ -16681,7 +16681,7 @@ fn airMemset(self: *Self, inst: Air.Inst.Index, safety: bool) !void {...@@ -16681,7 +16681,7 @@ fn airMemset(self: *Self, inst: Air.Inst.Index, safety: bool) !void {
1668116681
16682 self.performReloc(skip_reloc);16682 self.performReloc(skip_reloc);
16683 },16683 },
16684 .One => {16684 .one => {
16685 const elem_ptr_ty = try pt.singleMutPtrType(elem_ty);16685 const elem_ptr_ty = try pt.singleMutPtrType(elem_ty);
1668616686
16687 const len = dst_ptr_ty.childType(zcu).arrayLen(zcu);16687 const len = dst_ptr_ty.childType(zcu).arrayLen(zcu);
...@@ -16704,7 +16704,7 @@ fn airMemset(self: *Self, inst: Air.Inst.Index, safety: bool) !void {...@@ -16704,7 +16704,7 @@ fn airMemset(self: *Self, inst: Air.Inst.Index, safety: bool) !void {
16704 const bytes_to_copy: MCValue = .{ .immediate = elem_abi_size * (len - 1) };16704 const bytes_to_copy: MCValue = .{ .immediate = elem_abi_size * (len - 1) };
16705 try self.genInlineMemcpy(second_elem_ptr_mcv, dst_ptr, bytes_to_copy);16705 try self.genInlineMemcpy(second_elem_ptr_mcv, dst_ptr, bytes_to_copy);
16706 },16706 },
16707 .C, .Many => unreachable,16707 .c, .many => unreachable,
16708 }16708 }
16709 }16709 }
16710 return self.finishAir(inst, .unreach, .{ bin_op.lhs, bin_op.rhs, .none });16710 return self.finishAir(inst, .unreach, .{ bin_op.lhs, bin_op.rhs, .none });
...@@ -16735,7 +16735,7 @@ fn airMemcpy(self: *Self, inst: Air.Inst.Index) !void {...@@ -16735,7 +16735,7 @@ fn airMemcpy(self: *Self, inst: Air.Inst.Index) !void {
16735 defer if (src_ptr_lock) |lock| self.register_manager.unlockReg(lock);16735 defer if (src_ptr_lock) |lock| self.register_manager.unlockReg(lock);
1673616736
16737 const len: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) {16737 const len: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) {
16738 .Slice => len: {16738 .slice => len: {
16739 const len_reg = try self.register_manager.allocReg(null, abi.RegisterClass.gp);16739 const len_reg = try self.register_manager.allocReg(null, abi.RegisterClass.gp);
16740 const len_lock = self.register_manager.lockRegAssumeUnused(len_reg);16740 const len_lock = self.register_manager.lockRegAssumeUnused(len_reg);
16741 defer self.register_manager.unlockReg(len_lock);16741 defer self.register_manager.unlockReg(len_lock);
...@@ -16748,11 +16748,11 @@ fn airMemcpy(self: *Self, inst: Air.Inst.Index) !void {...@@ -16748,11 +16748,11 @@ fn airMemcpy(self: *Self, inst: Air.Inst.Index) !void {
16748 );16748 );
16749 break :len .{ .register = len_reg };16749 break :len .{ .register = len_reg };
16750 },16750 },
16751 .One => len: {16751 .one => len: {
16752 const array_ty = dst_ptr_ty.childType(zcu);16752 const array_ty = dst_ptr_ty.childType(zcu);
16753 break :len .{ .immediate = array_ty.arrayLen(zcu) * array_ty.childType(zcu).abiSize(zcu) };16753 break :len .{ .immediate = array_ty.arrayLen(zcu) * array_ty.childType(zcu).abiSize(zcu) };
16754 },16754 },
16755 .C, .Many => unreachable,16755 .c, .many => unreachable,
16756 };16756 };
16757 const len_lock: ?RegisterLock = switch (len) {16757 const len_lock: ?RegisterLock = switch (len) {
16758 .register => |reg| self.register_manager.lockRegAssumeUnused(reg),16758 .register => |reg| self.register_manager.lockRegAssumeUnused(reg),
src/arch/x86_64/abi.zig+1-1
...@@ -108,7 +108,7 @@ pub fn classifySystemV(ty: Type, zcu: *Zcu, target: std.Target, ctx: Context) [8...@@ -108,7 +108,7 @@ pub fn classifySystemV(ty: Type, zcu: *Zcu, target: std.Target, ctx: Context) [8
108 var result = [1]Class{.none} ** 8;108 var result = [1]Class{.none} ** 8;
109 switch (ty.zigTypeTag(zcu)) {109 switch (ty.zigTypeTag(zcu)) {
110 .pointer => switch (ty.ptrSize(zcu)) {110 .pointer => switch (ty.ptrSize(zcu)) {
111 .Slice => {111 .slice => {
112 result[0] = .integer;112 result[0] = .integer;
113 result[1] = .integer;113 result[1] = .integer;
114 return result;114 return result;
src/clang.zig+1-1
...@@ -177,7 +177,7 @@ pub const ASTUnit = opaque {...@@ -177,7 +177,7 @@ pub const ASTUnit = opaque {
177 extern fn ZigClangASTUnit_visitLocalTopLevelDecls(177 extern fn ZigClangASTUnit_visitLocalTopLevelDecls(
178 *ASTUnit,178 *ASTUnit,
179 context: ?*anyopaque,179 context: ?*anyopaque,
180 Fn: ?*const fn (?*anyopaque, *const Decl) callconv(.C) bool,180 Fn: ?*const fn (?*anyopaque, *const Decl) callconv(.c) bool,
181 ) bool;181 ) bool;
182182
183 pub const getLocalPreprocessingEntities_begin = ZigClangASTUnit_getLocalPreprocessingEntities_begin;183 pub const getLocalPreprocessingEntities_begin = ZigClangASTUnit_getLocalPreprocessingEntities_begin;
src/codegen.zig+1-1
...@@ -945,7 +945,7 @@ pub fn genTypedValue(...@@ -945,7 +945,7 @@ pub fn genTypedValue(
945 switch (ty.zigTypeTag(zcu)) {945 switch (ty.zigTypeTag(zcu)) {
946 .void => return .{ .mcv = .none },946 .void => return .{ .mcv = .none },
947 .pointer => switch (ty.ptrSize(zcu)) {947 .pointer => switch (ty.ptrSize(zcu)) {
948 .Slice => {},948 .slice => {},
949 else => switch (val.toIntern()) {949 else => switch (val.toIntern()) {
950 .null_value => {950 .null_value => {
951 return .{ .mcv = .{ .immediate = 0 } };951 return .{ .mcv = .{ .immediate = 0 } };
src/codegen/c.zig+19-19
...@@ -1589,14 +1589,14 @@ pub const DeclGen = struct {...@@ -1589,14 +1589,14 @@ pub const DeclGen = struct {
1589 try dg.fmtIntLiteral(try pt.undefValue(ty), location),1589 try dg.fmtIntLiteral(try pt.undefValue(ty), location),
1590 }),1590 }),
1591 .ptr_type => |ptr_type| switch (ptr_type.flags.size) {1591 .ptr_type => |ptr_type| switch (ptr_type.flags.size) {
1592 .One, .Many, .C => {1592 .one, .many, .c => {
1593 try writer.writeAll("((");1593 try writer.writeAll("((");
1594 try dg.renderCType(writer, ctype);1594 try dg.renderCType(writer, ctype);
1595 return writer.print("){x})", .{1595 return writer.print("){x})", .{
1596 try dg.fmtIntLiteral(try pt.undefValue(Type.usize), .Other),1596 try dg.fmtIntLiteral(try pt.undefValue(Type.usize), .Other),
1597 });1597 });
1598 },1598 },
1599 .Slice => {1599 .slice => {
1600 if (!location.isInitializer()) {1600 if (!location.isInitializer()) {
1601 try writer.writeByte('(');1601 try writer.writeByte('(');
1602 try dg.renderCType(writer, ctype);1602 try dg.renderCType(writer, ctype);
...@@ -3570,7 +3570,7 @@ fn airPtrElemPtr(f: *Function, inst: Air.Inst.Index) !CValue {...@@ -3570,7 +3570,7 @@ fn airPtrElemPtr(f: *Function, inst: Air.Inst.Index) !CValue {
3570 try f.renderType(writer, inst_ty);3570 try f.renderType(writer, inst_ty);
3571 try writer.writeByte(')');3571 try writer.writeByte(')');
3572 if (elem_has_bits) try writer.writeByte('&');3572 if (elem_has_bits) try writer.writeByte('&');
3573 if (elem_has_bits and ptr_ty.ptrSize(zcu) == .One) {3573 if (elem_has_bits and ptr_ty.ptrSize(zcu) == .one) {
3574 // It's a pointer to an array, so we need to de-reference.3574 // It's a pointer to an array, so we need to de-reference.
3575 try f.writeCValueDeref(writer, ptr);3575 try f.writeCValueDeref(writer, ptr);
3576 } else try f.writeCValue(writer, ptr, .Other);3576 } else try f.writeCValue(writer, ptr, .Other);
...@@ -5798,8 +5798,8 @@ fn fieldLocation(...@@ -5798,8 +5798,8 @@ fn fieldLocation(
5798 }5798 }
5799 },5799 },
5800 .ptr_type => |ptr_info| switch (ptr_info.flags.size) {5800 .ptr_type => |ptr_info| switch (ptr_info.flags.size) {
5801 .One, .Many, .C => unreachable,5801 .one, .many, .c => unreachable,
5802 .Slice => switch (field_index) {5802 .slice => switch (field_index) {
5803 0 => return .{ .field = .{ .identifier = "ptr" } },5803 0 => return .{ .field = .{ .identifier = "ptr" } },
5804 1 => return .{ .field = .{ .identifier = "len" } },5804 1 => return .{ .field = .{ .identifier = "len" } },
5805 else => unreachable,5805 else => unreachable,
...@@ -6902,7 +6902,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue {...@@ -6902,7 +6902,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue {
69026902
6903 try writer.writeAll("memset(");6903 try writer.writeAll("memset(");
6904 switch (dest_ty.ptrSize(zcu)) {6904 switch (dest_ty.ptrSize(zcu)) {
6905 .Slice => {6905 .slice => {
6906 try f.writeCValueMember(writer, dest_slice, .{ .identifier = "ptr" });6906 try f.writeCValueMember(writer, dest_slice, .{ .identifier = "ptr" });
6907 try writer.writeAll(", 0xaa, ");6907 try writer.writeAll(", 0xaa, ");
6908 try f.writeCValueMember(writer, dest_slice, .{ .identifier = "len" });6908 try f.writeCValueMember(writer, dest_slice, .{ .identifier = "len" });
...@@ -6912,14 +6912,14 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue {...@@ -6912,14 +6912,14 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue {
6912 try writer.writeAll(");\n");6912 try writer.writeAll(");\n");
6913 }6913 }
6914 },6914 },
6915 .One => {6915 .one => {
6916 const array_ty = dest_ty.childType(zcu);6916 const array_ty = dest_ty.childType(zcu);
6917 const len = array_ty.arrayLen(zcu) * elem_abi_size;6917 const len = array_ty.arrayLen(zcu) * elem_abi_size;
69186918
6919 try f.writeCValue(writer, dest_slice, .FunctionArgument);6919 try f.writeCValue(writer, dest_slice, .FunctionArgument);
6920 try writer.print(", 0xaa, {d});\n", .{len});6920 try writer.print(", 0xaa, {d});\n", .{len});
6921 },6921 },
6922 .Many, .C => unreachable,6922 .many, .c => unreachable,
6923 }6923 }
6924 try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs });6924 try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs });
6925 return .none;6925 return .none;
...@@ -6932,7 +6932,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue {...@@ -6932,7 +6932,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue {
6932 const elem_ptr_ty = try pt.ptrType(.{6932 const elem_ptr_ty = try pt.ptrType(.{
6933 .child = elem_ty.toIntern(),6933 .child = elem_ty.toIntern(),
6934 .flags = .{6934 .flags = .{
6935 .size = .C,6935 .size = .c,
6936 },6936 },
6937 });6937 });
69386938
...@@ -6946,14 +6946,14 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue {...@@ -6946,14 +6946,14 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue {
6946 try f.writeCValue(writer, index, .Other);6946 try f.writeCValue(writer, index, .Other);
6947 try writer.writeAll(" != ");6947 try writer.writeAll(" != ");
6948 switch (dest_ty.ptrSize(zcu)) {6948 switch (dest_ty.ptrSize(zcu)) {
6949 .Slice => {6949 .slice => {
6950 try f.writeCValueMember(writer, dest_slice, .{ .identifier = "len" });6950 try f.writeCValueMember(writer, dest_slice, .{ .identifier = "len" });
6951 },6951 },
6952 .One => {6952 .one => {
6953 const array_ty = dest_ty.childType(zcu);6953 const array_ty = dest_ty.childType(zcu);
6954 try writer.print("{d}", .{array_ty.arrayLen(zcu)});6954 try writer.print("{d}", .{array_ty.arrayLen(zcu)});
6955 },6955 },
6956 .Many, .C => unreachable,6956 .many, .c => unreachable,
6957 }6957 }
6958 try writer.writeAll("; ++");6958 try writer.writeAll("; ++");
6959 try f.writeCValue(writer, index, .Other);6959 try f.writeCValue(writer, index, .Other);
...@@ -6981,7 +6981,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue {...@@ -6981,7 +6981,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue {
69816981
6982 try writer.writeAll("memset(");6982 try writer.writeAll("memset(");
6983 switch (dest_ty.ptrSize(zcu)) {6983 switch (dest_ty.ptrSize(zcu)) {
6984 .Slice => {6984 .slice => {
6985 try f.writeCValueMember(writer, dest_slice, .{ .identifier = "ptr" });6985 try f.writeCValueMember(writer, dest_slice, .{ .identifier = "ptr" });
6986 try writer.writeAll(", ");6986 try writer.writeAll(", ");
6987 try f.writeCValue(writer, bitcasted, .FunctionArgument);6987 try f.writeCValue(writer, bitcasted, .FunctionArgument);
...@@ -6989,7 +6989,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue {...@@ -6989,7 +6989,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue {
6989 try f.writeCValueMember(writer, dest_slice, .{ .identifier = "len" });6989 try f.writeCValueMember(writer, dest_slice, .{ .identifier = "len" });
6990 try writer.writeAll(");\n");6990 try writer.writeAll(");\n");
6991 },6991 },
6992 .One => {6992 .one => {
6993 const array_ty = dest_ty.childType(zcu);6993 const array_ty = dest_ty.childType(zcu);
6994 const len = array_ty.arrayLen(zcu) * elem_abi_size;6994 const len = array_ty.arrayLen(zcu) * elem_abi_size;
69956995
...@@ -6998,7 +6998,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue {...@@ -6998,7 +6998,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue {
6998 try f.writeCValue(writer, bitcasted, .FunctionArgument);6998 try f.writeCValue(writer, bitcasted, .FunctionArgument);
6999 try writer.print(", {d});\n", .{len});6999 try writer.print(", {d});\n", .{len});
7000 },7000 },
7001 .Many, .C => unreachable,7001 .many, .c => unreachable,
7002 }7002 }
7003 try f.freeCValue(inst, bitcasted);7003 try f.freeCValue(inst, bitcasted);
7004 try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs });7004 try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs });
...@@ -7015,7 +7015,7 @@ fn airMemcpy(f: *Function, inst: Air.Inst.Index) !CValue {...@@ -7015,7 +7015,7 @@ fn airMemcpy(f: *Function, inst: Air.Inst.Index) !CValue {
7015 const src_ty = f.typeOf(bin_op.rhs);7015 const src_ty = f.typeOf(bin_op.rhs);
7016 const writer = f.object.writer();7016 const writer = f.object.writer();
70177017
7018 if (dest_ty.ptrSize(zcu) != .One) {7018 if (dest_ty.ptrSize(zcu) != .one) {
7019 try writer.writeAll("if (");7019 try writer.writeAll("if (");
7020 try writeArrayLen(f, writer, dest_ptr, dest_ty);7020 try writeArrayLen(f, writer, dest_ptr, dest_ty);
7021 try writer.writeAll(" != 0) ");7021 try writer.writeAll(" != 0) ");
...@@ -7038,11 +7038,11 @@ fn writeArrayLen(f: *Function, writer: ArrayListWriter, dest_ptr: CValue, dest_t...@@ -7038,11 +7038,11 @@ fn writeArrayLen(f: *Function, writer: ArrayListWriter, dest_ptr: CValue, dest_t
7038 const pt = f.object.dg.pt;7038 const pt = f.object.dg.pt;
7039 const zcu = pt.zcu;7039 const zcu = pt.zcu;
7040 switch (dest_ty.ptrSize(zcu)) {7040 switch (dest_ty.ptrSize(zcu)) {
7041 .One => try writer.print("{}", .{7041 .one => try writer.print("{}", .{
7042 try f.fmtIntLiteral(try pt.intValue(Type.usize, dest_ty.childType(zcu).arrayLen(zcu))),7042 try f.fmtIntLiteral(try pt.intValue(Type.usize, dest_ty.childType(zcu).arrayLen(zcu))),
7043 }),7043 }),
7044 .Many, .C => unreachable,7044 .many, .c => unreachable,
7045 .Slice => try f.writeCValueMember(writer, dest_ptr, .{ .identifier = "len" }),7045 .slice => try f.writeCValueMember(writer, dest_ptr, .{ .identifier = "len" }),
7046 }7046 }
7047}7047}
70487048
src/codegen/c/Type.zig+3-3
...@@ -1458,7 +1458,7 @@ pub const Pool = struct {...@@ -1458,7 +1458,7 @@ pub const Pool = struct {
1458 _ => |ip_index| switch (ip.indexToKey(ip_index)) {1458 _ => |ip_index| switch (ip.indexToKey(ip_index)) {
1459 .int_type => |int_info| return pool.fromIntInfo(allocator, int_info, mod, kind),1459 .int_type => |int_info| return pool.fromIntInfo(allocator, int_info, mod, kind),
1460 .ptr_type => |ptr_info| switch (ptr_info.flags.size) {1460 .ptr_type => |ptr_info| switch (ptr_info.flags.size) {
1461 .One, .Many, .C => {1461 .one, .many, .c => {
1462 const elem_ctype = elem_ctype: {1462 const elem_ctype = elem_ctype: {
1463 if (ptr_info.packed_offset.host_size > 0 and1463 if (ptr_info.packed_offset.host_size > 0 and
1464 ptr_info.flags.vector_index == .none)1464 ptr_info.flags.vector_index == .none)
...@@ -1505,7 +1505,7 @@ pub const Pool = struct {...@@ -1505,7 +1505,7 @@ pub const Pool = struct {
1505 .@"volatile" = ptr_info.flags.is_volatile,1505 .@"volatile" = ptr_info.flags.is_volatile,
1506 });1506 });
1507 },1507 },
1508 .Slice => {1508 .slice => {
1509 const target = &mod.resolved_target.result;1509 const target = &mod.resolved_target.result;
1510 var fields = [_]Info.Field{1510 var fields = [_]Info.Field{
1511 .{1511 .{
...@@ -1598,7 +1598,7 @@ pub const Pool = struct {...@@ -1598,7 +1598,7 @@ pub const Pool = struct {
1598 switch (payload_type) {1598 switch (payload_type) {
1599 .anyerror_type => return payload_ctype,1599 .anyerror_type => return payload_ctype,
1600 else => switch (ip.indexToKey(payload_type)) {1600 else => switch (ip.indexToKey(payload_type)) {
1601 .ptr_type => |payload_ptr_info| if (payload_ptr_info.flags.size != .C and1601 .ptr_type => |payload_ptr_info| if (payload_ptr_info.flags.size != .c and
1602 !payload_ptr_info.flags.is_allowzero) return payload_ctype,1602 !payload_ptr_info.flags.is_allowzero) return payload_ctype,
1603 .error_set_type, .inferred_error_set_type => return payload_ctype,1603 .error_set_type, .inferred_error_set_type => return payload_ctype,
1604 else => {},1604 else => {},
src/codegen/llvm.zig+17-17
...@@ -2109,7 +2109,7 @@ pub const Object = struct {...@@ -2109,7 +2109,7 @@ pub const Object = struct {
2109 ptr_info.flags.is_allowzero or2109 ptr_info.flags.is_allowzero or
2110 ptr_info.flags.is_const or2110 ptr_info.flags.is_const or
2111 ptr_info.flags.is_volatile or2111 ptr_info.flags.is_volatile or
2112 ptr_info.flags.size == .Many or ptr_info.flags.size == .C or2112 ptr_info.flags.size == .many or ptr_info.flags.size == .c or
2113 !Type.fromInterned(ptr_info.child).hasRuntimeBitsIgnoreComptime(zcu))2113 !Type.fromInterned(ptr_info.child).hasRuntimeBitsIgnoreComptime(zcu))
2114 {2114 {
2115 const bland_ptr_ty = try pt.ptrType(.{2115 const bland_ptr_ty = try pt.ptrType(.{
...@@ -2120,8 +2120,8 @@ pub const Object = struct {...@@ -2120,8 +2120,8 @@ pub const Object = struct {
2120 .flags = .{2120 .flags = .{
2121 .alignment = ptr_info.flags.alignment,2121 .alignment = ptr_info.flags.alignment,
2122 .size = switch (ptr_info.flags.size) {2122 .size = switch (ptr_info.flags.size) {
2123 .Many, .C, .One => .One,2123 .many, .c, .one => .one,
2124 .Slice => .Slice,2124 .slice => .slice,
2125 },2125 },
2126 },2126 },
2127 });2127 });
...@@ -3382,8 +3382,8 @@ pub const Object = struct {...@@ -3382,8 +3382,8 @@ pub const Object = struct {
3382 toLlvmAddressSpace(ptr_type.flags.address_space, target),3382 toLlvmAddressSpace(ptr_type.flags.address_space, target),
3383 );3383 );
3384 break :type switch (ptr_type.flags.size) {3384 break :type switch (ptr_type.flags.size) {
3385 .One, .Many, .C => ptr_ty,3385 .one, .many, .c => ptr_ty,
3386 .Slice => try o.builder.structType(.normal, &.{3386 .slice => try o.builder.structType(.normal, &.{
3387 ptr_ty,3387 ptr_ty,
3388 try o.lowerType(Type.usize),3388 try o.lowerType(Type.usize),
3389 }),3389 }),
...@@ -6988,7 +6988,7 @@ pub const FuncGen = struct {...@@ -6988,7 +6988,7 @@ pub const FuncGen = struct {
6988 const zcu = pt.zcu;6988 const zcu = pt.zcu;
6989 const llvm_usize = try o.lowerType(Type.usize);6989 const llvm_usize = try o.lowerType(Type.usize);
6990 switch (ty.ptrSize(zcu)) {6990 switch (ty.ptrSize(zcu)) {
6991 .Slice => {6991 .slice => {
6992 const len = try fg.wip.extractValue(ptr, &.{1}, "");6992 const len = try fg.wip.extractValue(ptr, &.{1}, "");
6993 const elem_ty = ty.childType(zcu);6993 const elem_ty = ty.childType(zcu);
6994 const abi_size = elem_ty.abiSize(zcu);6994 const abi_size = elem_ty.abiSize(zcu);
...@@ -6996,13 +6996,13 @@ pub const FuncGen = struct {...@@ -6996,13 +6996,13 @@ pub const FuncGen = struct {
6996 const abi_size_llvm_val = try o.builder.intValue(llvm_usize, abi_size);6996 const abi_size_llvm_val = try o.builder.intValue(llvm_usize, abi_size);
6997 return fg.wip.bin(.@"mul nuw", len, abi_size_llvm_val, "");6997 return fg.wip.bin(.@"mul nuw", len, abi_size_llvm_val, "");
6998 },6998 },
6999 .One => {6999 .one => {
7000 const array_ty = ty.childType(zcu);7000 const array_ty = ty.childType(zcu);
7001 const elem_ty = array_ty.childType(zcu);7001 const elem_ty = array_ty.childType(zcu);
7002 const abi_size = elem_ty.abiSize(zcu);7002 const abi_size = elem_ty.abiSize(zcu);
7003 return o.builder.intValue(llvm_usize, array_ty.arrayLen(zcu) * abi_size);7003 return o.builder.intValue(llvm_usize, array_ty.arrayLen(zcu) * abi_size);
7004 },7004 },
7005 .Many, .C => unreachable,7005 .many, .c => unreachable,
7006 }7006 }
7007 }7007 }
70087008
...@@ -8670,11 +8670,11 @@ pub const FuncGen = struct {...@@ -8670,11 +8670,11 @@ pub const FuncGen = struct {
8670 const llvm_elem_ty = try o.lowerPtrElemTy(ptr_ty.childType(zcu));8670 const llvm_elem_ty = try o.lowerPtrElemTy(ptr_ty.childType(zcu));
8671 switch (ptr_ty.ptrSize(zcu)) {8671 switch (ptr_ty.ptrSize(zcu)) {
8672 // It's a pointer to an array, so according to LLVM we need an extra GEP index.8672 // It's a pointer to an array, so according to LLVM we need an extra GEP index.
8673 .One => return self.wip.gep(.inbounds, llvm_elem_ty, ptr, &.{8673 .one => return self.wip.gep(.inbounds, llvm_elem_ty, ptr, &.{
8674 try o.builder.intValue(try o.lowerType(Type.usize), 0), offset,8674 try o.builder.intValue(try o.lowerType(Type.usize), 0), offset,
8675 }, ""),8675 }, ""),
8676 .C, .Many => return self.wip.gep(.inbounds, llvm_elem_ty, ptr, &.{offset}, ""),8676 .c, .many => return self.wip.gep(.inbounds, llvm_elem_ty, ptr, &.{offset}, ""),
8677 .Slice => {8677 .slice => {
8678 const base = try self.wip.extractValue(ptr, &.{0}, "");8678 const base = try self.wip.extractValue(ptr, &.{0}, "");
8679 return self.wip.gep(.inbounds, llvm_elem_ty, base, &.{offset}, "");8679 return self.wip.gep(.inbounds, llvm_elem_ty, base, &.{offset}, "");
8680 },8680 },
...@@ -8693,11 +8693,11 @@ pub const FuncGen = struct {...@@ -8693,11 +8693,11 @@ pub const FuncGen = struct {
8693 const llvm_elem_ty = try o.lowerPtrElemTy(ptr_ty.childType(zcu));8693 const llvm_elem_ty = try o.lowerPtrElemTy(ptr_ty.childType(zcu));
8694 switch (ptr_ty.ptrSize(zcu)) {8694 switch (ptr_ty.ptrSize(zcu)) {
8695 // It's a pointer to an array, so according to LLVM we need an extra GEP index.8695 // It's a pointer to an array, so according to LLVM we need an extra GEP index.
8696 .One => return self.wip.gep(.inbounds, llvm_elem_ty, ptr, &.{8696 .one => return self.wip.gep(.inbounds, llvm_elem_ty, ptr, &.{
8697 try o.builder.intValue(try o.lowerType(Type.usize), 0), negative_offset,8697 try o.builder.intValue(try o.lowerType(Type.usize), 0), negative_offset,
8698 }, ""),8698 }, ""),
8699 .C, .Many => return self.wip.gep(.inbounds, llvm_elem_ty, ptr, &.{negative_offset}, ""),8699 .c, .many => return self.wip.gep(.inbounds, llvm_elem_ty, ptr, &.{negative_offset}, ""),
8700 .Slice => {8700 .slice => {
8701 const base = try self.wip.extractValue(ptr, &.{0}, "");8701 const base = try self.wip.extractValue(ptr, &.{0}, "");
8702 return self.wip.gep(.inbounds, llvm_elem_ty, base, &.{negative_offset}, "");8702 return self.wip.gep(.inbounds, llvm_elem_ty, base, &.{negative_offset}, "");
8703 },8703 },
...@@ -10034,9 +10034,9 @@ pub const FuncGen = struct {...@@ -10034,9 +10034,9 @@ pub const FuncGen = struct {
1003410034
10035 const llvm_usize_ty = try o.lowerType(Type.usize);10035 const llvm_usize_ty = try o.lowerType(Type.usize);
10036 const len = switch (ptr_ty.ptrSize(zcu)) {10036 const len = switch (ptr_ty.ptrSize(zcu)) {
10037 .Slice => try self.wip.extractValue(dest_slice, &.{1}, ""),10037 .slice => try self.wip.extractValue(dest_slice, &.{1}, ""),
10038 .One => try o.builder.intValue(llvm_usize_ty, ptr_ty.childType(zcu).arrayLen(zcu)),10038 .one => try o.builder.intValue(llvm_usize_ty, ptr_ty.childType(zcu).arrayLen(zcu)),
10039 .Many, .C => unreachable,10039 .many, .c => unreachable,
10040 };10040 };
10041 const elem_llvm_ty = try o.lowerType(elem_ty);10041 const elem_llvm_ty = try o.lowerType(elem_ty);
10042 const end_ptr = try self.wip.gep(.inbounds, elem_llvm_ty, dest_ptr, &.{len}, "");10042 const end_ptr = try self.wip.gep(.inbounds, elem_llvm_ty, dest_ptr, &.{len}, "");
src/codegen/spirv.zig+8-8
...@@ -1705,13 +1705,13 @@ const NavGen = struct {...@@ -1705,13 +1705,13 @@ const NavGen = struct {
1705 const storage_class = self.spvStorageClass(ptr_info.flags.address_space);1705 const storage_class = self.spvStorageClass(ptr_info.flags.address_space);
1706 const ptr_ty_id = try self.ptrType(child_ty, storage_class);1706 const ptr_ty_id = try self.ptrType(child_ty, storage_class);
17071707
1708 if (target.os.tag == .vulkan and ptr_info.flags.size == .Many) {1708 if (target.os.tag == .vulkan and ptr_info.flags.size == .many) {
1709 try self.spv.decorate(ptr_ty_id, .{ .ArrayStride = .{1709 try self.spv.decorate(ptr_ty_id, .{ .ArrayStride = .{
1710 .array_stride = @intCast(child_ty.abiSize(zcu)),1710 .array_stride = @intCast(child_ty.abiSize(zcu)),
1711 } });1711 } });
1712 }1712 }
17131713
1714 if (ptr_info.flags.size != .Slice) {1714 if (ptr_info.flags.size != .slice) {
1715 return ptr_ty_id;1715 return ptr_ty_id;
1716 }1716 }
17171717
...@@ -4399,15 +4399,15 @@ const NavGen = struct {...@@ -4399,15 +4399,15 @@ const NavGen = struct {
4399 const result_ty_id = try self.resolveType(result_ty, .direct);4399 const result_ty_id = try self.resolveType(result_ty, .direct);
44004400
4401 switch (ptr_ty.ptrSize(zcu)) {4401 switch (ptr_ty.ptrSize(zcu)) {
4402 .One => {4402 .one => {
4403 // Pointer to array4403 // Pointer to array
4404 // TODO: Is this correct?4404 // TODO: Is this correct?
4405 return try self.accessChainId(result_ty_id, ptr_id, &.{offset_id});4405 return try self.accessChainId(result_ty_id, ptr_id, &.{offset_id});
4406 },4406 },
4407 .C, .Many => {4407 .c, .many => {
4408 return try self.ptrAccessChain(result_ty_id, ptr_id, offset_id, &.{});4408 return try self.ptrAccessChain(result_ty_id, ptr_id, offset_id, &.{});
4409 },4409 },
4410 .Slice => {4410 .slice => {
4411 // TODO: This is probably incorrect. A slice should be returned here, though this is what llvm does.4411 // TODO: This is probably incorrect. A slice should be returned here, though this is what llvm does.
4412 const slice_ptr_id = try self.extractField(result_ty, ptr_id, 0);4412 const slice_ptr_id = try self.extractField(result_ty, ptr_id, 0);
4413 return try self.ptrAccessChain(result_ty_id, slice_ptr_id, offset_id, &.{});4413 return try self.ptrAccessChain(result_ty_id, slice_ptr_id, offset_id, &.{});
...@@ -4989,15 +4989,15 @@ const NavGen = struct {...@@ -4989,15 +4989,15 @@ const NavGen = struct {
4989 const pt = self.pt;4989 const pt = self.pt;
4990 const zcu = pt.zcu;4990 const zcu = pt.zcu;
4991 switch (ty.ptrSize(zcu)) {4991 switch (ty.ptrSize(zcu)) {
4992 .Slice => return self.extractField(Type.usize, operand_id, 1),4992 .slice => return self.extractField(Type.usize, operand_id, 1),
4993 .One => {4993 .one => {
4994 const array_ty = ty.childType(zcu);4994 const array_ty = ty.childType(zcu);
4995 const elem_ty = array_ty.childType(zcu);4995 const elem_ty = array_ty.childType(zcu);
4996 const abi_size = elem_ty.abiSize(zcu);4996 const abi_size = elem_ty.abiSize(zcu);
4997 const size = array_ty.arrayLenIncludingSentinel(zcu) * abi_size;4997 const size = array_ty.arrayLenIncludingSentinel(zcu) * abi_size;
4998 return try self.constInt(Type.usize, size, .direct);4998 return try self.constInt(Type.usize, size, .direct);
4999 },4999 },
5000 .Many, .C => unreachable,5000 .many, .c => unreachable,
5001 }5001 }
5002 }5002 }
50035003
src/codegen/spirv/Section.zig+2-2
...@@ -159,7 +159,7 @@ pub fn writeOperand(section: *Section, comptime Operand: type, operand: Operand)...@@ -159,7 +159,7 @@ pub fn writeOperand(section: *Section, comptime Operand: type, operand: Operand)
159 section.writeOperand(info.child, child);159 section.writeOperand(info.child, child);
160 },160 },
161 .pointer => |info| {161 .pointer => |info| {
162 std.debug.assert(info.size == .Slice); // Should be no other pointer types in the spec.162 std.debug.assert(info.size == .slice); // Should be no other pointer types in the spec.
163 for (operand) |item| {163 for (operand) |item| {
164 section.writeOperand(info.child, item);164 section.writeOperand(info.child, item);
165 }165 }
...@@ -292,7 +292,7 @@ fn operandSize(comptime Operand: type, operand: Operand) usize {...@@ -292,7 +292,7 @@ fn operandSize(comptime Operand: type, operand: Operand) usize {
292 .@"enum" => 1,292 .@"enum" => 1,
293 .optional => |info| if (operand) |child| operandSize(info.child, child) else 0,293 .optional => |info| if (operand) |child| operandSize(info.child, child) else 0,
294 .pointer => |info| blk: {294 .pointer => |info| blk: {
295 std.debug.assert(info.size == .Slice); // Should be no other pointer types in the spec.295 std.debug.assert(info.size == .slice); // Should be no other pointer types in the spec.
296 var total: usize = 0;296 var total: usize = 0;
297 for (operand) |item| {297 for (operand) |item| {
298 total += operandSize(info.child, item);298 total += operandSize(info.child, item);
src/crash_report.zig+1-1
...@@ -190,7 +190,7 @@ pub fn attachSegfaultHandler() void {...@@ -190,7 +190,7 @@ pub fn attachSegfaultHandler() void {
190 debug.updateSegfaultHandler(&act);190 debug.updateSegfaultHandler(&act);
191}191}
192192
193fn handleSegfaultPosix(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.C) noreturn {193fn handleSegfaultPosix(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.c) noreturn {
194 // TODO: use alarm() here to prevent infinite loops194 // TODO: use alarm() here to prevent infinite loops
195 PanicSwitch.preDispatch();195 PanicSwitch.preDispatch();
196196
src/link/Dwarf.zig+2-2
...@@ -3182,7 +3182,7 @@ fn updateLazyType(...@@ -3182,7 +3182,7 @@ fn updateLazyType(
3182 try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?);3182 try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?);
3183 },3183 },
3184 .ptr_type => |ptr_type| switch (ptr_type.flags.size) {3184 .ptr_type => |ptr_type| switch (ptr_type.flags.size) {
3185 .One, .Many, .C => {3185 .one, .many, .c => {
3186 const ptr_child_type: Type = .fromInterned(ptr_type.child);3186 const ptr_child_type: Type = .fromInterned(ptr_type.child);
3187 try wip_nav.abbrevCode(if (ptr_type.sentinel == .none) .ptr_type else .ptr_sentinel_type);3187 try wip_nav.abbrevCode(if (ptr_type.sentinel == .none) .ptr_type else .ptr_sentinel_type);
3188 try wip_nav.strp(name);3188 try wip_nav.strp(name);
...@@ -3210,7 +3210,7 @@ fn updateLazyType(...@@ -3210,7 +3210,7 @@ fn updateLazyType(
3210 try wip_nav.refType(ptr_child_type);3210 try wip_nav.refType(ptr_child_type);
3211 }3211 }
3212 },3212 },
3213 .Slice => {3213 .slice => {
3214 try wip_nav.abbrevCode(.generated_struct_type);3214 try wip_nav.abbrevCode(.generated_struct_type);
3215 try wip_nav.strp(name);3215 try wip_nav.strp(name);
3216 try uleb128(diw, ty.abiSize(zcu));3216 try uleb128(diw, ty.abiSize(zcu));
src/link/tapi/yaml.zig+4-4
...@@ -248,7 +248,7 @@ pub const Value = union(enum) {...@@ -248,7 +248,7 @@ pub const Value = union(enum) {
248 .array => return encode(arena, &input),248 .array => return encode(arena, &input),
249249
250 .pointer => |info| switch (info.size) {250 .pointer => |info| switch (info.size) {
251 .One => switch (@typeInfo(info.child)) {251 .one => switch (@typeInfo(info.child)) {
252 .array => |child_info| {252 .array => |child_info| {
253 const Slice = []const child_info.child;253 const Slice = []const child_info.child;
254 return encode(arena, @as(Slice, input));254 return encode(arena, @as(Slice, input));
...@@ -257,7 +257,7 @@ pub const Value = union(enum) {...@@ -257,7 +257,7 @@ pub const Value = union(enum) {
257 @compileError("Unhandled type: {s}" ++ @typeName(info.child));257 @compileError("Unhandled type: {s}" ++ @typeName(info.child));
258 },258 },
259 },259 },
260 .Slice => {260 .slice => {
261 if (info.child == u8) {261 if (info.child == u8) {
262 return Value{ .string = try arena.dupe(u8, input) };262 return Value{ .string = try arena.dupe(u8, input) };
263 }263 }
...@@ -357,7 +357,7 @@ pub const Yaml = struct {...@@ -357,7 +357,7 @@ pub const Yaml = struct {
357 },357 },
358 .pointer => |info| {358 .pointer => |info| {
359 switch (info.size) {359 switch (info.size) {
360 .Slice => {360 .slice => {
361 var parsed = try self.arena.allocator().alloc(info.child, self.docs.items.len);361 var parsed = try self.arena.allocator().alloc(info.child, self.docs.items.len);
362 for (self.docs.items, 0..) |doc, i| {362 for (self.docs.items, 0..) |doc, i| {
363 parsed[i] = try self.parseValue(info.child, doc);363 parsed[i] = try self.parseValue(info.child, doc);
...@@ -446,7 +446,7 @@ pub const Yaml = struct {...@@ -446,7 +446,7 @@ pub const Yaml = struct {
446 const arena = self.arena.allocator();446 const arena = self.arena.allocator();
447447
448 switch (ptr_info.size) {448 switch (ptr_info.size) {
449 .Slice => {449 .slice => {
450 if (ptr_info.child == u8) {450 if (ptr_info.child == u8) {
451 return value.asString();451 return value.asString();
452 }452 }
src/mutable_value.zig+1-1
...@@ -256,7 +256,7 @@ pub const MutableValue = union(enum) {...@@ -256,7 +256,7 @@ pub const MutableValue = union(enum) {
256 },256 },
257 .pointer => {257 .pointer => {
258 const ptr_ty = ip.indexToKey(ty_ip).ptr_type;258 const ptr_ty = ip.indexToKey(ty_ip).ptr_type;
259 if (ptr_ty.flags.size != .Slice) return;259 if (ptr_ty.flags.size != .slice) return;
260 const ptr = try arena.create(MutableValue);260 const ptr = try arena.create(MutableValue);
261 const len = try arena.create(MutableValue);261 const len = try arena.create(MutableValue);
262 ptr.* = .{ .interned = try pt.intern(.{ .undef = ip.slicePtrType(ty_ip) }) };262 ptr.* = .{ .interned = try pt.intern(.{ .undef = ip.slicePtrType(ty_ip) }) };
src/translate_c.zig+2-2
...@@ -231,13 +231,13 @@ fn prepopulateGlobalNameTable(ast_unit: *clang.ASTUnit, c: *Context) !void {...@@ -231,13 +231,13 @@ fn prepopulateGlobalNameTable(ast_unit: *clang.ASTUnit, c: *Context) !void {
231 }231 }
232}232}
233233
234fn declVisitorNamesOnlyC(context: ?*anyopaque, decl: *const clang.Decl) callconv(.C) bool {234fn declVisitorNamesOnlyC(context: ?*anyopaque, decl: *const clang.Decl) callconv(.c) bool {
235 const c: *Context = @ptrCast(@alignCast(context));235 const c: *Context = @ptrCast(@alignCast(context));
236 declVisitorNamesOnly(c, decl) catch return false;236 declVisitorNamesOnly(c, decl) catch return false;
237 return true;237 return true;
238}238}
239239
240fn declVisitorC(context: ?*anyopaque, decl: *const clang.Decl) callconv(.C) bool {240fn declVisitorC(context: ?*anyopaque, decl: *const clang.Decl) callconv(.c) bool {
241 const c: *Context = @ptrCast(@alignCast(context));241 const c: *Context = @ptrCast(@alignCast(context));
242 declVisitor(c, decl) catch return false;242 declVisitor(c, decl) catch return false;
243 return true;243 return true;
test/behavior/align.zig+2-2
...@@ -410,11 +410,11 @@ test "alignment of function with c calling convention" {...@@ -410,11 +410,11 @@ test "alignment of function with c calling convention" {
410 var runtime_nothing = &nothing;410 var runtime_nothing = &nothing;
411 _ = &runtime_nothing;411 _ = &runtime_nothing;
412 const casted1: *align(a) const u8 = @ptrCast(runtime_nothing);412 const casted1: *align(a) const u8 = @ptrCast(runtime_nothing);
413 const casted2: *const fn () callconv(.C) void = @ptrCast(casted1);413 const casted2: *const fn () callconv(.c) void = @ptrCast(casted1);
414 casted2();414 casted2();
415}415}
416416
417fn nothing() callconv(.C) void {}417fn nothing() callconv(.c) void {}
418418
419const DefaultAligned = struct {419const DefaultAligned = struct {
420 nevermind: u32,420 nevermind: u32,
test/behavior/cast.zig+5-5
...@@ -1118,7 +1118,7 @@ test "compile time int to ptr of function" {...@@ -1118,7 +1118,7 @@ test "compile time int to ptr of function" {
1118// On some architectures function pointers must be aligned.1118// On some architectures function pointers must be aligned.
1119const hardcoded_fn_addr = maxInt(usize) & ~@as(usize, 0xf);1119const hardcoded_fn_addr = maxInt(usize) & ~@as(usize, 0xf);
1120pub const FUNCTION_CONSTANT = @as(PFN_void, @ptrFromInt(hardcoded_fn_addr));1120pub const FUNCTION_CONSTANT = @as(PFN_void, @ptrFromInt(hardcoded_fn_addr));
1121pub const PFN_void = *const fn (*anyopaque) callconv(.C) void;1121pub const PFN_void = *const fn (*anyopaque) callconv(.c) void;
11221122
1123fn foobar(func: PFN_void) !void {1123fn foobar(func: PFN_void) !void {
1124 try std.testing.expect(@intFromPtr(func) == hardcoded_fn_addr);1124 try std.testing.expect(@intFromPtr(func) == hardcoded_fn_addr);
...@@ -1281,11 +1281,11 @@ test "implicit cast *[0]T to E![]const u8" {...@@ -1281,11 +1281,11 @@ test "implicit cast *[0]T to E![]const u8" {
12811281
1282var global_array: [4]u8 = undefined;1282var global_array: [4]u8 = undefined;
1283test "cast from array reference to fn: comptime fn ptr" {1283test "cast from array reference to fn: comptime fn ptr" {
1284 const f = @as(*align(1) const fn () callconv(.C) void, @ptrCast(&global_array));1284 const f = @as(*align(1) const fn () callconv(.c) void, @ptrCast(&global_array));
1285 try expect(@intFromPtr(f) == @intFromPtr(&global_array));1285 try expect(@intFromPtr(f) == @intFromPtr(&global_array));
1286}1286}
1287test "cast from array reference to fn: runtime fn ptr" {1287test "cast from array reference to fn: runtime fn ptr" {
1288 var f = @as(*align(1) const fn () callconv(.C) void, @ptrCast(&global_array));1288 var f = @as(*align(1) const fn () callconv(.c) void, @ptrCast(&global_array));
1289 _ = &f;1289 _ = &f;
1290 try expect(@intFromPtr(f) == @intFromPtr(&global_array));1290 try expect(@intFromPtr(f) == @intFromPtr(&global_array));
1291}1291}
...@@ -1309,12 +1309,12 @@ test "*const [N]null u8 to ?[]const u8" {...@@ -1309,12 +1309,12 @@ test "*const [N]null u8 to ?[]const u8" {
13091309
1310test "cast between [*c]T and ?[*:0]T on fn parameter" {1310test "cast between [*c]T and ?[*:0]T on fn parameter" {
1311 const S = struct {1311 const S = struct {
1312 const Handler = ?fn ([*c]const u8) callconv(.C) void;1312 const Handler = ?fn ([*c]const u8) callconv(.c) void;
1313 fn addCallback(comptime handler: Handler) void {1313 fn addCallback(comptime handler: Handler) void {
1314 _ = handler;1314 _ = handler;
1315 }1315 }
13161316
1317 fn myCallback(cstr: ?[*:0]const u8) callconv(.C) void {1317 fn myCallback(cstr: ?[*:0]const u8) callconv(.c) void {
1318 _ = cstr;1318 _ = cstr;
1319 }1319 }
13201320
test/behavior/export_builtin.zig+1-1
...@@ -26,7 +26,7 @@ test "exporting with internal linkage" {...@@ -26,7 +26,7 @@ test "exporting with internal linkage" {
26 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;26 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
2727
28 const S = struct {28 const S = struct {
29 fn foo() callconv(.C) void {}29 fn foo() callconv(.c) void {}
30 comptime {30 comptime {
31 @export(&foo, .{ .name = "exporting_with_internal_linkage_foo", .linkage = .internal });31 @export(&foo, .{ .name = "exporting_with_internal_linkage_foo", .linkage = .internal });
32 }32 }
test/behavior/export_keyword.zig+1-1
...@@ -44,7 +44,7 @@ test "export function alias" {...@@ -44,7 +44,7 @@ test "export function alias" {
44 if (builtin.zig_backend == .stage2_x86_64 and builtin.target.ofmt != .elf and builtin.target.ofmt != .macho) return error.SkipZigTest;44 if (builtin.zig_backend == .stage2_x86_64 and builtin.target.ofmt != .elf and builtin.target.ofmt != .macho) return error.SkipZigTest;
4545
46 _ = struct {46 _ = struct {
47 fn foo_internal() callconv(.C) u32 {47 fn foo_internal() callconv(.c) u32 {
48 return 123;48 return 123;
49 }49 }
50 export const foo_exported = foo_internal;50 export const foo_exported = foo_internal;
test/behavior/extern.zig+3-3
...@@ -20,7 +20,7 @@ test "function extern symbol" {...@@ -20,7 +20,7 @@ test "function extern symbol" {
20 if (builtin.zig_backend == .stage2_x86_64 and builtin.target.ofmt != .elf and builtin.target.ofmt != .macho) return error.SkipZigTest;20 if (builtin.zig_backend == .stage2_x86_64 and builtin.target.ofmt != .elf and builtin.target.ofmt != .macho) return error.SkipZigTest;
21 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;21 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
2222
23 const a = @extern(*const fn () callconv(.C) i32, .{ .name = "a_mystery_function" });23 const a = @extern(*const fn () callconv(.c) i32, .{ .name = "a_mystery_function" });
24 try expect(a() == 4567);24 try expect(a() == 4567);
25}25}
2626
...@@ -35,7 +35,7 @@ test "function extern symbol matches extern decl" {...@@ -35,7 +35,7 @@ test "function extern symbol matches extern decl" {
3535
36 const S = struct {36 const S = struct {
37 extern fn another_mystery_function() u32;37 extern fn another_mystery_function() u32;
38 const same_thing = @extern(*const fn () callconv(.C) u32, .{ .name = "another_mystery_function" });38 const same_thing = @extern(*const fn () callconv(.c) u32, .{ .name = "another_mystery_function" });
39 };39 };
40 try expect(S.another_mystery_function() == 12345);40 try expect(S.another_mystery_function() == 12345);
41 try expect(S.same_thing() == 12345);41 try expect(S.same_thing() == 12345);
...@@ -55,5 +55,5 @@ test "coerce extern function types" {...@@ -55,5 +55,5 @@ test "coerce extern function types" {
55 };55 };
56 _ = S;56 _ = S;
5757
58 _ = @as(fn () callconv(.C) ?*u32, c_extern_function);58 _ = @as(fn () callconv(.c) ?*u32, c_extern_function);
59}59}
test/behavior/fn.zig+5-5
...@@ -153,9 +153,9 @@ test "extern struct with stdcallcc fn pointer" {...@@ -153,9 +153,9 @@ test "extern struct with stdcallcc fn pointer" {
153 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;153 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
154154
155 const S = extern struct {155 const S = extern struct {
156 ptr: *const fn () callconv(if (builtin.target.cpu.arch == .x86) .Stdcall else .C) i32,156 ptr: *const fn () callconv(if (builtin.target.cpu.arch == .x86) .Stdcall else .c) i32,
157157
158 fn foo() callconv(if (builtin.target.cpu.arch == .x86) .Stdcall else .C) i32 {158 fn foo() callconv(if (builtin.target.cpu.arch == .x86) .Stdcall else .c) i32 {
159 return 1234;159 return 1234;
160 }160 }
161 };161 };
...@@ -169,7 +169,7 @@ const nComplexCallconv = 100;...@@ -169,7 +169,7 @@ const nComplexCallconv = 100;
169fn fComplexCallconvRet(x: u32) callconv(blk: {169fn fComplexCallconvRet(x: u32) callconv(blk: {
170 const s: struct { n: u32 } = .{ .n = nComplexCallconv };170 const s: struct { n: u32 } = .{ .n = nComplexCallconv };
171 break :blk switch (s.n) {171 break :blk switch (s.n) {
172 0 => .C,172 0 => .c,
173 1 => .Inline,173 1 => .Inline,
174 else => .Unspecified,174 else => .Unspecified,
175 };175 };
...@@ -435,13 +435,13 @@ test "implicit cast function to function ptr" {...@@ -435,13 +435,13 @@ test "implicit cast function to function ptr" {
435 return 123;435 return 123;
436 }436 }
437 };437 };
438 var fnPtr1: *const fn () callconv(.C) c_int = S1.someFunctionThatReturnsAValue;438 var fnPtr1: *const fn () callconv(.c) c_int = S1.someFunctionThatReturnsAValue;
439 _ = &fnPtr1;439 _ = &fnPtr1;
440 try expect(fnPtr1() == 123);440 try expect(fnPtr1() == 123);
441 const S2 = struct {441 const S2 = struct {
442 extern fn someFunctionThatReturnsAValue() c_int;442 extern fn someFunctionThatReturnsAValue() c_int;
443 };443 };
444 var fnPtr2: *const fn () callconv(.C) c_int = S2.someFunctionThatReturnsAValue;444 var fnPtr2: *const fn () callconv(.c) c_int = S2.someFunctionThatReturnsAValue;
445 _ = &fnPtr2;445 _ = &fnPtr2;
446 try expect(fnPtr2() == 123);446 try expect(fnPtr2() == 123);
447}447}
test/behavior/generics.zig+6-6
...@@ -324,7 +324,7 @@ test "generic function instantiation non-duplicates" {...@@ -324,7 +324,7 @@ test "generic function instantiation non-duplicates" {
324 for (source, 0..) |s, i| dest[i] = s;324 for (source, 0..) |s, i| dest[i] = s;
325 }325 }
326326
327 fn foo() callconv(.C) void {}327 fn foo() callconv(.c) void {}
328 };328 };
329 var buffer: [100]u8 = undefined;329 var buffer: [100]u8 = undefined;
330 S.copy(u8, &buffer, "hello");330 S.copy(u8, &buffer, "hello");
...@@ -471,13 +471,13 @@ test "coerced function body has inequal value with its uncoerced body" {...@@ -471,13 +471,13 @@ test "coerced function body has inequal value with its uncoerced body" {
471 try expect(S.A.do() == 1234);471 try expect(S.A.do() == 1234);
472}472}
473473
474test "generic function returns value from callconv(.C) function" {474test "generic function returns value from callconv(.c) function" {
475 const S = struct {475 const S = struct {
476 fn getU8() callconv(.C) u8 {476 fn getU8() callconv(.c) u8 {
477 return 123;477 return 123;
478 }478 }
479479
480 fn getGeneric(comptime T: type, supplier: fn () callconv(.C) T) T {480 fn getGeneric(comptime T: type, supplier: fn () callconv(.c) T) T {
481 return supplier();481 return supplier();
482 }482 }
483 };483 };
...@@ -521,11 +521,11 @@ test "function argument tuple used as struct field" {...@@ -521,11 +521,11 @@ test "function argument tuple used as struct field" {
521 try expect(c.t[0] == null);521 try expect(c.t[0] == null);
522}522}
523523
524test "comptime callconv(.C) function ptr uses comptime type argument" {524test "comptime callconv(.c) function ptr uses comptime type argument" {
525 const S = struct {525 const S = struct {
526 fn A(526 fn A(
527 comptime T: type,527 comptime T: type,
528 comptime destroycb: ?*const fn (?*T) callconv(.C) void,528 comptime destroycb: ?*const fn (?*T) callconv(.c) void,
529 ) !void {529 ) !void {
530 try expect(destroycb == null);530 try expect(destroycb == null);
531 }531 }
test/behavior/import_c_keywords.zig+1-1
...@@ -80,7 +80,7 @@ test "import c keywords" {...@@ -80,7 +80,7 @@ test "import c keywords" {
80 try std.testing.expect(ptr_id == &some_non_c_keyword_constant);80 try std.testing.expect(ptr_id == &some_non_c_keyword_constant);
8181
82 if (builtin.target.ofmt != .coff and builtin.target.os.tag != .windows) {82 if (builtin.target.ofmt != .coff and builtin.target.os.tag != .windows) {
83 var ptr_fn: *const fn () callconv(.C) Id = &double;83 var ptr_fn: *const fn () callconv(.c) Id = &double;
84 try std.testing.expect(ptr_fn == &float);84 try std.testing.expect(ptr_fn == &float);
85 ptr_fn = &an_alias_of_float;85 ptr_fn = &an_alias_of_float;
86 try std.testing.expect(ptr_fn == &float);86 try std.testing.expect(ptr_fn == &float);
test/behavior/packed-struct.zig+3-3
...@@ -891,7 +891,7 @@ test "runtime init of unnamed packed struct type" {...@@ -891,7 +891,7 @@ test "runtime init of unnamed packed struct type" {
891 }{ .x = z }).m();891 }{ .x = z }).m();
892}892}
893893
894test "packed struct passed to callconv(.C) function" {894test "packed struct passed to callconv(.c) function" {
895 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;895 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
896 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;896 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
897 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO897 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
...@@ -906,7 +906,7 @@ test "packed struct passed to callconv(.C) function" {...@@ -906,7 +906,7 @@ test "packed struct passed to callconv(.C) function" {
906 d: u46 = 0,906 d: u46 = 0,
907 };907 };
908908
909 fn foo(p: Packed, a1: u64, a2: u64, a3: u64, a4: u64, a5: u64) callconv(.C) bool {909 fn foo(p: Packed, a1: u64, a2: u64, a3: u64, a4: u64, a5: u64) callconv(.c) bool {
910 return p.a == 12345 and p.b == true and p.c == true and p.d == 0 and a1 == 5 and a2 == 4 and a3 == 3 and a4 == 2 and a5 == 1;910 return p.a == 12345 and p.b == true and p.c == true and p.d == 0 and a1 == 5 and a2 == 4 and a3 == 3 and a4 == 2 and a5 == 1;
911 }911 }
912 };912 };
...@@ -1270,7 +1270,7 @@ test "2-byte packed struct argument in C calling convention" {...@@ -1270,7 +1270,7 @@ test "2-byte packed struct argument in C calling convention" {
1270 x: u15 = 0,1270 x: u15 = 0,
1271 y: u1 = 0,1271 y: u1 = 0,
12721272
1273 fn foo(s: @This()) callconv(.C) i32 {1273 fn foo(s: @This()) callconv(.c) i32 {
1274 return s.x;1274 return s.x;
1275 }1275 }
1276 fn bar(s: @This()) !void {1276 fn bar(s: @This()) !void {
test/behavior/struct.zig+1-1
...@@ -803,7 +803,7 @@ test "fn with C calling convention returns struct by value" {...@@ -803,7 +803,7 @@ test "fn with C calling convention returns struct by value" {
803 handle: i32,803 handle: i32,
804 };804 };
805805
806 fn makeBar(t: i32) callconv(.C) ExternBar {806 fn makeBar(t: i32) callconv(.c) ExternBar {
807 return ExternBar{807 return ExternBar{
808 .handle = t,808 .handle = t,
809 };809 };
test/behavior/type.zig+3-3
...@@ -141,7 +141,7 @@ test "Type.Array" {...@@ -141,7 +141,7 @@ test "Type.Array" {
141test "@Type create slice with null sentinel" {141test "@Type create slice with null sentinel" {
142 const Slice = @Type(.{142 const Slice = @Type(.{
143 .pointer = .{143 .pointer = .{
144 .size = .Slice,144 .size = .slice,
145 .is_const = true,145 .is_const = true,
146 .is_volatile = false,146 .is_volatile = false,
147 .is_allowzero = false,147 .is_allowzero = false,
...@@ -548,11 +548,11 @@ test "Type.Fn" {...@@ -548,11 +548,11 @@ test "Type.Fn" {
548548
549 const some_opaque = opaque {};549 const some_opaque = opaque {};
550 const some_ptr = *some_opaque;550 const some_ptr = *some_opaque;
551 const T = fn (c_int, some_ptr) callconv(.C) void;551 const T = fn (c_int, some_ptr) callconv(.c) void;
552552
553 {553 {
554 const fn_info = std.builtin.Type{ .@"fn" = .{554 const fn_info = std.builtin.Type{ .@"fn" = .{
555 .calling_convention = .C,555 .calling_convention = .c,
556 .is_generic = false,556 .is_generic = false,
557 .is_var_args = false,557 .is_var_args = false,
558 .return_type = void,558 .return_type = void,
test/behavior/type_info.zig+9-9
...@@ -44,7 +44,7 @@ test "type info: C pointer type info" {...@@ -44,7 +44,7 @@ test "type info: C pointer type info" {
44fn testCPtr() !void {44fn testCPtr() !void {
45 const ptr_info = @typeInfo([*c]align(4) const i8);45 const ptr_info = @typeInfo([*c]align(4) const i8);
46 try expect(ptr_info == .pointer);46 try expect(ptr_info == .pointer);
47 try expect(ptr_info.pointer.size == .C);47 try expect(ptr_info.pointer.size == .c);
48 try expect(ptr_info.pointer.is_const);48 try expect(ptr_info.pointer.is_const);
49 try expect(!ptr_info.pointer.is_volatile);49 try expect(!ptr_info.pointer.is_volatile);
50 try expect(ptr_info.pointer.alignment == 4);50 try expect(ptr_info.pointer.alignment == 4);
...@@ -54,8 +54,8 @@ fn testCPtr() !void {...@@ -54,8 +54,8 @@ fn testCPtr() !void {
54test "type info: value is correctly copied" {54test "type info: value is correctly copied" {
55 comptime {55 comptime {
56 var ptrInfo = @typeInfo([]u32);56 var ptrInfo = @typeInfo([]u32);
57 ptrInfo.pointer.size = .One;57 ptrInfo.pointer.size = .one;
58 try expect(@typeInfo([]u32).pointer.size == .Slice);58 try expect(@typeInfo([]u32).pointer.size == .slice);
59 }59 }
60}60}
6161
...@@ -79,7 +79,7 @@ test "type info: pointer type info" {...@@ -79,7 +79,7 @@ test "type info: pointer type info" {
79fn testPointer() !void {79fn testPointer() !void {
80 const u32_ptr_info = @typeInfo(*u32);80 const u32_ptr_info = @typeInfo(*u32);
81 try expect(u32_ptr_info == .pointer);81 try expect(u32_ptr_info == .pointer);
82 try expect(u32_ptr_info.pointer.size == .One);82 try expect(u32_ptr_info.pointer.size == .one);
83 try expect(u32_ptr_info.pointer.is_const == false);83 try expect(u32_ptr_info.pointer.is_const == false);
84 try expect(u32_ptr_info.pointer.is_volatile == false);84 try expect(u32_ptr_info.pointer.is_volatile == false);
85 try expect(u32_ptr_info.pointer.alignment == @alignOf(u32));85 try expect(u32_ptr_info.pointer.alignment == @alignOf(u32));
...@@ -95,7 +95,7 @@ test "type info: unknown length pointer type info" {...@@ -95,7 +95,7 @@ test "type info: unknown length pointer type info" {
95fn testUnknownLenPtr() !void {95fn testUnknownLenPtr() !void {
96 const u32_ptr_info = @typeInfo([*]const volatile f64);96 const u32_ptr_info = @typeInfo([*]const volatile f64);
97 try expect(u32_ptr_info == .pointer);97 try expect(u32_ptr_info == .pointer);
98 try expect(u32_ptr_info.pointer.size == .Many);98 try expect(u32_ptr_info.pointer.size == .many);
99 try expect(u32_ptr_info.pointer.is_const == true);99 try expect(u32_ptr_info.pointer.is_const == true);
100 try expect(u32_ptr_info.pointer.is_volatile == true);100 try expect(u32_ptr_info.pointer.is_volatile == true);
101 try expect(u32_ptr_info.pointer.sentinel == null);101 try expect(u32_ptr_info.pointer.sentinel == null);
...@@ -111,7 +111,7 @@ test "type info: null terminated pointer type info" {...@@ -111,7 +111,7 @@ test "type info: null terminated pointer type info" {
111fn testNullTerminatedPtr() !void {111fn testNullTerminatedPtr() !void {
112 const ptr_info = @typeInfo([*:0]u8);112 const ptr_info = @typeInfo([*:0]u8);
113 try expect(ptr_info == .pointer);113 try expect(ptr_info == .pointer);
114 try expect(ptr_info.pointer.size == .Many);114 try expect(ptr_info.pointer.size == .many);
115 try expect(ptr_info.pointer.is_const == false);115 try expect(ptr_info.pointer.is_const == false);
116 try expect(ptr_info.pointer.is_volatile == false);116 try expect(ptr_info.pointer.is_volatile == false);
117 try expect(@as(*const u8, @ptrCast(ptr_info.pointer.sentinel.?)).* == 0);117 try expect(@as(*const u8, @ptrCast(ptr_info.pointer.sentinel.?)).* == 0);
...@@ -127,7 +127,7 @@ test "type info: slice type info" {...@@ -127,7 +127,7 @@ test "type info: slice type info" {
127fn testSlice() !void {127fn testSlice() !void {
128 const u32_slice_info = @typeInfo([]u32);128 const u32_slice_info = @typeInfo([]u32);
129 try expect(u32_slice_info == .pointer);129 try expect(u32_slice_info == .pointer);
130 try expect(u32_slice_info.pointer.size == .Slice);130 try expect(u32_slice_info.pointer.size == .slice);
131 try expect(u32_slice_info.pointer.is_const == false);131 try expect(u32_slice_info.pointer.is_const == false);
132 try expect(u32_slice_info.pointer.is_volatile == false);132 try expect(u32_slice_info.pointer.is_volatile == false);
133 try expect(u32_slice_info.pointer.alignment == 4);133 try expect(u32_slice_info.pointer.alignment == 4);
...@@ -374,7 +374,7 @@ fn testFunction() !void {...@@ -374,7 +374,7 @@ fn testFunction() !void {
374 try expect(foo_fn_info.@"fn".is_var_args);374 try expect(foo_fn_info.@"fn".is_var_args);
375 try expect(foo_fn_info.@"fn".return_type.? == usize);375 try expect(foo_fn_info.@"fn".return_type.? == usize);
376 const foo_ptr_fn_info = @typeInfo(@TypeOf(&typeInfoFoo));376 const foo_ptr_fn_info = @typeInfo(@TypeOf(&typeInfoFoo));
377 try expect(foo_ptr_fn_info.pointer.size == .One);377 try expect(foo_ptr_fn_info.pointer.size == .one);
378 try expect(foo_ptr_fn_info.pointer.is_const);378 try expect(foo_ptr_fn_info.pointer.is_const);
379 try expect(!foo_ptr_fn_info.pointer.is_volatile);379 try expect(!foo_ptr_fn_info.pointer.is_volatile);
380 try expect(foo_ptr_fn_info.pointer.address_space == .generic);380 try expect(foo_ptr_fn_info.pointer.address_space == .generic);
...@@ -401,7 +401,7 @@ fn testFunction() !void {...@@ -401,7 +401,7 @@ fn testFunction() !void {
401 try expect(aligned_foo_fn_info.@"fn".is_var_args);401 try expect(aligned_foo_fn_info.@"fn".is_var_args);
402 try expect(aligned_foo_fn_info.@"fn".return_type.? == usize);402 try expect(aligned_foo_fn_info.@"fn".return_type.? == usize);
403 const aligned_foo_ptr_fn_info = @typeInfo(@TypeOf(&typeInfoFooAligned));403 const aligned_foo_ptr_fn_info = @typeInfo(@TypeOf(&typeInfoFooAligned));
404 try expect(aligned_foo_ptr_fn_info.pointer.size == .One);404 try expect(aligned_foo_ptr_fn_info.pointer.size == .one);
405 try expect(aligned_foo_ptr_fn_info.pointer.is_const);405 try expect(aligned_foo_ptr_fn_info.pointer.is_const);
406 try expect(!aligned_foo_ptr_fn_info.pointer.is_volatile);406 try expect(!aligned_foo_ptr_fn_info.pointer.is_volatile);
407 try expect(aligned_foo_ptr_fn_info.pointer.alignment == 4);407 try expect(aligned_foo_ptr_fn_info.pointer.alignment == 4);
test/behavior/union.zig+1-1
...@@ -1229,7 +1229,7 @@ test "return an extern union from C calling convention" {...@@ -1229,7 +1229,7 @@ test "return an extern union from C calling convention" {
1229 s: S,1229 s: S,
1230 };1230 };
12311231
1232 fn bar(arg_u: U) callconv(.C) U {1232 fn bar(arg_u: U) callconv(.c) U {
1233 var u = arg_u;1233 var u = arg_u;
1234 _ = &u;1234 _ = &u;
1235 return u;1235 return u;
test/behavior/var_args.zig+8-8
...@@ -108,19 +108,19 @@ test "simple variadic function" {...@@ -108,19 +108,19 @@ test "simple variadic function" {
108 if (builtin.cpu.arch == .s390x and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21350108 if (builtin.cpu.arch == .s390x and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21350
109109
110 const S = struct {110 const S = struct {
111 fn simple(...) callconv(.C) c_int {111 fn simple(...) callconv(.c) c_int {
112 var ap = @cVaStart();112 var ap = @cVaStart();
113 defer @cVaEnd(&ap);113 defer @cVaEnd(&ap);
114 return @cVaArg(&ap, c_int);114 return @cVaArg(&ap, c_int);
115 }115 }
116116
117 fn compatible(_: c_int, ...) callconv(.C) c_int {117 fn compatible(_: c_int, ...) callconv(.c) c_int {
118 var ap = @cVaStart();118 var ap = @cVaStart();
119 defer @cVaEnd(&ap);119 defer @cVaEnd(&ap);
120 return @cVaArg(&ap, c_int);120 return @cVaArg(&ap, c_int);
121 }121 }
122122
123 fn add(count: c_int, ...) callconv(.C) c_int {123 fn add(count: c_int, ...) callconv(.c) c_int {
124 var ap = @cVaStart();124 var ap = @cVaStart();
125 defer @cVaEnd(&ap);125 defer @cVaEnd(&ap);
126 var i: usize = 0;126 var i: usize = 0;
...@@ -169,7 +169,7 @@ test "coerce reference to var arg" {...@@ -169,7 +169,7 @@ test "coerce reference to var arg" {
169 if (builtin.cpu.arch == .s390x and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21350169 if (builtin.cpu.arch == .s390x and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21350
170170
171 const S = struct {171 const S = struct {
172 fn addPtr(count: c_int, ...) callconv(.C) c_int {172 fn addPtr(count: c_int, ...) callconv(.c) c_int {
173 var ap = @cVaStart();173 var ap = @cVaStart();
174 defer @cVaEnd(&ap);174 defer @cVaEnd(&ap);
175 var i: usize = 0;175 var i: usize = 0;
...@@ -202,7 +202,7 @@ test "variadic functions" {...@@ -202,7 +202,7 @@ test "variadic functions" {
202 if (builtin.cpu.arch == .s390x and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21350202 if (builtin.cpu.arch == .s390x and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21350
203203
204 const S = struct {204 const S = struct {
205 fn printf(list_ptr: *std.ArrayList(u8), format: [*:0]const u8, ...) callconv(.C) void {205 fn printf(list_ptr: *std.ArrayList(u8), format: [*:0]const u8, ...) callconv(.c) void {
206 var ap = @cVaStart();206 var ap = @cVaStart();
207 defer @cVaEnd(&ap);207 defer @cVaEnd(&ap);
208 vprintf(list_ptr, format, &ap);208 vprintf(list_ptr, format, &ap);
...@@ -212,7 +212,7 @@ test "variadic functions" {...@@ -212,7 +212,7 @@ test "variadic functions" {
212 list: *std.ArrayList(u8),212 list: *std.ArrayList(u8),
213 format: [*:0]const u8,213 format: [*:0]const u8,
214 ap: *std.builtin.VaList,214 ap: *std.builtin.VaList,
215 ) callconv(.C) void {215 ) callconv(.c) void {
216 for (std.mem.span(format)) |c| switch (c) {216 for (std.mem.span(format)) |c| switch (c) {
217 's' => {217 's' => {
218 const arg = @cVaArg(ap, [*:0]const u8);218 const arg = @cVaArg(ap, [*:0]const u8);
...@@ -247,7 +247,7 @@ test "copy VaList" {...@@ -247,7 +247,7 @@ test "copy VaList" {
247 if (builtin.cpu.arch == .s390x and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21350247 if (builtin.cpu.arch == .s390x and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21350
248248
249 const S = struct {249 const S = struct {
250 fn add(count: c_int, ...) callconv(.C) c_int {250 fn add(count: c_int, ...) callconv(.c) c_int {
251 var ap = @cVaStart();251 var ap = @cVaStart();
252 defer @cVaEnd(&ap);252 defer @cVaEnd(&ap);
253 var copy = @cVaCopy(&ap);253 var copy = @cVaCopy(&ap);
...@@ -284,7 +284,7 @@ test "unused VaList arg" {...@@ -284,7 +284,7 @@ test "unused VaList arg" {
284 if (builtin.cpu.arch == .s390x and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21350284 if (builtin.cpu.arch == .s390x and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21350
285285
286 const S = struct {286 const S = struct {
287 fn thirdArg(dummy: c_int, ...) callconv(.C) c_int {287 fn thirdArg(dummy: c_int, ...) callconv(.c) c_int {
288 _ = dummy;288 _ = dummy;
289289
290 var ap = @cVaStart();290 var ap = @cVaStart();
test/cases/compile_errors/generic_instantiation_failure_in_generic_function_return_type.zig+1-1
...@@ -21,7 +21,7 @@ pub fn isPtrTo(comptime id: std.builtin.TypeId) TraitFn {...@@ -21,7 +21,7 @@ pub fn isPtrTo(comptime id: std.builtin.TypeId) TraitFn {
2121
22pub fn isSingleItemPtr(comptime T: type) bool {22pub fn isSingleItemPtr(comptime T: type) bool {
23 if (comptime is(.pointer)(T)) {23 if (comptime is(.pointer)(T)) {
24 return @typeInfo(T).pointer.size == .One;24 return @typeInfo(T).pointer.size == .one;
25 }25 }
26 return false;26 return false;
27}27}
test/cases/compile_errors/invalid_pointer_with_reify_type.zig+1-3
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1export fn entry() void {1export fn entry() void {
2 _ = @Type(.{ .pointer = .{2 _ = @Type(.{ .pointer = .{
3 .size = .One,3 .size = .one,
4 .is_const = false,4 .is_const = false,
5 .is_volatile = false,5 .is_volatile = false,
6 .alignment = 1,6 .alignment = 1,
...@@ -12,7 +12,5 @@ export fn entry() void {...@@ -12,7 +12,5 @@ export fn entry() void {
12}12}
1313
14// error14// error
15// backend=stage2
16// target=native
17//15//
18// :2:9: error: sentinels are only allowed on slices and unknown-length pointers16// :2:9: error: sentinels are only allowed on slices and unknown-length pointers
test/cases/compile_errors/non_scalar_sentinel.zig+2-2
...@@ -16,7 +16,7 @@ comptime {...@@ -16,7 +16,7 @@ comptime {
16}16}
17comptime {17comptime {
18 _ = @Type(.{ .pointer = .{18 _ = @Type(.{ .pointer = .{
19 .size = .Many,19 .size = .slice,
20 .is_const = false,20 .is_const = false,
21 .is_volatile = false,21 .is_volatile = false,
22 .alignment = @alignOf(S),22 .alignment = @alignOf(S),
...@@ -28,7 +28,7 @@ comptime {...@@ -28,7 +28,7 @@ comptime {
28}28}
29comptime {29comptime {
30 _ = @Type(.{ .pointer = .{30 _ = @Type(.{ .pointer = .{
31 .size = .Many,31 .size = .many,
32 .is_const = false,32 .is_const = false,
33 .is_volatile = false,33 .is_volatile = false,
34 .alignment = @alignOf(S),34 .alignment = @alignOf(S),
test/cases/compile_errors/reify_type_with_invalid_field_alignment.zig+1-3
...@@ -29,7 +29,7 @@ comptime {...@@ -29,7 +29,7 @@ comptime {
29comptime {29comptime {
30 _ = @Type(.{30 _ = @Type(.{
31 .pointer = .{31 .pointer = .{
32 .size = .Many,32 .size = .many,
33 .is_const = true,33 .is_const = true,
34 .is_volatile = false,34 .is_volatile = false,
35 .alignment = 7,35 .alignment = 7,
...@@ -42,8 +42,6 @@ comptime {...@@ -42,8 +42,6 @@ comptime {
42}42}
4343
44// error44// error
45// backend=stage2
46// target=native
47//45//
48// :2:9: error: alignment value '3' is not a power of two or zero46// :2:9: error: alignment value '3' is not a power of two or zero
49// :14:9: error: alignment value '5' is not a power of two or zero47// :14:9: error: alignment value '5' is not a power of two or zero