authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-01-16 22:20:02+00:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2025-01-16 22:20:02+00:00
log4d8c24c6c52fe4adf4f9215278108734b635393d
tree64fc0998ec2ba6273d2661ef7e34ccaf93d74492
parent133abdeda2994886c3476a3faf53f8a911513b32
parent9804cc8bc6fe83b2a0cd5b61b8d2fc5d458cb221
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #22505 from mlugg/easier-modify-builtin

std.builtin.Type renames, and make it easier to modify std.builtin

92 files changed, 1178 insertions(+), 947 deletions(-)

bootstrap.c+1
......@@ -141,6 +141,7 @@ int main(int argc, char **argv) {
141141 "pub const skip_non_native = false;\n"
142142 "pub const force_gpa = false;\n"
143143 "pub const dev = .core;\n"
144 "pub const value_interpret_mode = .direct;\n"
144145 , zig_version);
145146 if (written < 100)
146147 panic("unable to write to config.zig file");
build.zig+20
......@@ -9,6 +9,7 @@ const fs = std.fs;
99const InstallDirectoryOptions = std.Build.InstallDirectoryOptions;
1010const assert = std.debug.assert;
1111const DevEnv = @import("src/dev.zig").Env;
12const ValueInterpretMode = enum { direct, by_name };
1213
1314const zig_version: std.SemanticVersion = .{ .major = 0, .minor = 14, .patch = 0 };
1415const stack_size = 46 * 1024 * 1024;
......@@ -177,6 +178,7 @@ pub fn build(b: *std.Build) !void {
177178 const strip = b.option(bool, "strip", "Omit debug information");
178179 const valgrind = b.option(bool, "valgrind", "Enable valgrind integration");
179180 const pie = b.option(bool, "pie", "Produce a Position Independent Executable");
181 const value_interpret_mode = b.option(ValueInterpretMode, "value-interpret-mode", "How the compiler translates between 'std.builtin' types and its internal datastructures") orelse .direct;
180182 const value_tracing = b.option(bool, "value-tracing", "Enable extra state tracking to help troubleshoot bugs in the compiler (using the std.debug.Trace API)") orelse false;
181183
182184 const mem_leak_frames: u32 = b.option(u32, "mem-leak-frames", "How many stack frames to print when a memory leak occurs. Tests get 2x this amount.") orelse blk: {
......@@ -234,6 +236,7 @@ pub fn build(b: *std.Build) !void {
234236 exe_options.addOption(bool, "llvm_has_xtensa", llvm_has_xtensa);
235237 exe_options.addOption(bool, "force_gpa", force_gpa);
236238 exe_options.addOption(DevEnv, "dev", b.option(DevEnv, "dev", "Build a compiler with a reduced feature set for development of specific features") orelse if (only_c) .bootstrap else .full);
239 exe_options.addOption(ValueInterpretMode, "value_interpret_mode", value_interpret_mode);
237240
238241 if (link_libc) {
239242 exe.root_module.link_libc = true;
......@@ -620,6 +623,23 @@ fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void {
620623 exe_options.addOption(bool, "value_tracing", false);
621624 exe_options.addOption(DevEnv, "dev", .bootstrap);
622625
626 // zig1 chooses to interpret values by name. The tradeoff is as follows:
627 //
628 // * We lose a small amount of performance. This is essentially irrelevant for zig1.
629 //
630 // * We lose the ability to perform trivial renames on certain `std.builtin` types without
631 // zig1.wasm updates. For instance, we cannot rename an enum from PascalCase fields to
632 // snake_case fields without an update.
633 //
634 // * We gain the ability to add and remove fields to and from `std.builtin` types without
635 // zig1.wasm updates. For instance, we can add a new tag to `CallingConvention` without
636 // an update.
637 //
638 // Because field renames only happen when we apply a breaking change to the language (which
639 // is becoming progressively rarer), but tags may be added to or removed from target-dependent
640 // types over time in response to new targets coming into use, we gain more than we lose here.
641 exe_options.addOption(ValueInterpretMode, "value_interpret_mode", .by_name);
642
623643 const run_opt = b.addSystemCommand(&.{
624644 "wasm-opt",
625645 "-Oz",
lib/std/Build/Step/ConfigHeader.zig+2-2
......@@ -144,13 +144,13 @@ fn putValue(config_header: *ConfigHeader, field_name: []const u8, comptime T: ty
144144 .pointer => |ptr| {
145145 switch (@typeInfo(ptr.child)) {
146146 .array => |array| {
147 if (ptr.size == .One and array.child == u8) {
147 if (ptr.size == .one and array.child == u8) {
148148 try config_header.values.put(field_name, .{ .string = v });
149149 return;
150150 }
151151 },
152152 .int => {
153 if (ptr.size == .Slice and ptr.child == u8) {
153 if (ptr.size == .slice and ptr.child == u8) {
154154 try config_header.values.put(field_name, .{ .string = v });
155155 return;
156156 }
lib/std/Build/Step/Options.zig+2-4
......@@ -172,7 +172,7 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent
172172 return;
173173 },
174174 .pointer => |p| {
175 if (p.size != .Slice) {
175 if (p.size != .slice) {
176176 @compileError("Non-slice pointers are not yet supported in build options");
177177 }
178178
......@@ -318,9 +318,7 @@ fn printStruct(options: *Options, out: anytype, comptime T: type, comptime val:
318318 try out.print(" {p_}: {s}", .{ std.zig.fmtId(field.name), type_name });
319319 }
320320
321 if (field.default_value != null) {
322 const default_value = @as(*field.type, @ptrCast(@alignCast(@constCast(field.default_value.?)))).*;
323
321 if (field.defaultValue()) |default_value| {
324322 try out.writeAll(" = ");
325323 switch (@typeInfo(@TypeOf(default_value))) {
326324 .@"enum" => try out.print(".{s},\n", .{@tagName(default_value)}),
lib/std/Progress.zig+1-1
......@@ -1366,7 +1366,7 @@ fn maybeUpdateSize(resize_flag: bool) void {
13661366 }
13671367}
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 {
13701370 _ = info;
13711371 _ = ctx_ptr;
13721372 assert(sig == posix.SIG.WINCH);
lib/std/Random.zig+1-1
......@@ -35,7 +35,7 @@ fillFn: *const fn (ptr: *anyopaque, buf: []u8) void,
3535pub fn init(pointer: anytype, comptime fillFn: fn (ptr: @TypeOf(pointer), buf: []u8) void) Random {
3636 const Ptr = @TypeOf(pointer);
3737 assert(@typeInfo(Ptr) == .pointer); // Must be a pointer
38 assert(@typeInfo(Ptr).pointer.size == .One); // Must be a single-item pointer
38 assert(@typeInfo(Ptr).pointer.size == .one); // Must be a single-item pointer
3939 assert(@typeInfo(@typeInfo(Ptr).pointer.child) == .@"struct"); // Must point to a struct
4040 const gen = struct {
4141 fn fill(ptr: *anyopaque, buf: []u8) void {
lib/std/builtin.zig+36-9
......@@ -607,16 +607,24 @@ pub const Type = union(enum) {
607607
608608 /// The type of the sentinel is the element type of the pointer, which is
609609 /// the value of the `child` field in this struct. However there is no way
610 /// to refer to that type here, so we use pointer to `anyopaque`.
611 sentinel: ?*const anyopaque,
610 /// to refer to that type here, so we use `*const anyopaque`.
611 /// See also: `sentinel`
612 sentinel_ptr: ?*const anyopaque,
613
614 /// Loads the pointer type's sentinel value from `sentinel_ptr`.
615 /// Returns `null` if the pointer type has no sentinel.
616 pub inline fn sentinel(comptime ptr: Pointer) ?ptr.child {
617 const sp: *const ptr.child = @ptrCast(@alignCast(ptr.sentinel_ptr orelse return null));
618 return sp.*;
619 }
612620
613621 /// This data structure is used by the Zig language code generation and
614622 /// therefore must be kept in sync with the compiler implementation.
615623 pub const Size = enum(u2) {
616 One,
617 Many,
618 Slice,
619 C,
624 one,
625 many,
626 slice,
627 c,
620628 };
621629 };
622630
......@@ -628,8 +636,16 @@ pub const Type = union(enum) {
628636
629637 /// The type of the sentinel is the element type of the array, which is
630638 /// the value of the `child` field in this struct. However there is no way
631 /// to refer to that type here, so we use pointer to `anyopaque`.
632 sentinel: ?*const anyopaque,
639 /// to refer to that type here, so we use `*const anyopaque`.
640 /// See also: `sentinel`.
641 sentinel_ptr: ?*const anyopaque,
642
643 /// Loads the array type's sentinel value from `sentinel_ptr`.
644 /// Returns `null` if the array type has no sentinel.
645 pub inline fn sentinel(comptime arr: Array) ?arr.child {
646 const sp: *const arr.child = @ptrCast(@alignCast(arr.sentinel_ptr orelse return null));
647 return sp.*;
648 }
633649 };
634650
635651 /// This data structure is used by the Zig language code generation and
......@@ -645,9 +661,20 @@ pub const Type = union(enum) {
645661 pub const StructField = struct {
646662 name: [:0]const u8,
647663 type: type,
648 default_value: ?*const anyopaque,
664 /// The type of the default value is the type of this struct field, which
665 /// is the value of the `type` field in this struct. However there is no
666 /// way to refer to that type here, so we use `*const anyopaque`.
667 /// See also: `defaultValue`.
668 default_value_ptr: ?*const anyopaque,
649669 is_comptime: bool,
650670 alignment: comptime_int,
671
672 /// Loads the field's default value from `default_value_ptr`.
673 /// Returns `null` if the field has no default value.
674 pub inline fn defaultValue(comptime sf: StructField) ?sf.type {
675 const dp: *const sf.type = @ptrCast(@alignCast(sf.default_value_ptr orelse return null));
676 return dp.*;
677 }
651678 };
652679
653680 /// This data structure is used by the Zig language code generation and
lib/std/c.zig+31-31
......@@ -2733,8 +2733,8 @@ pub const Sigaction = switch (native_os) {
27332733 => if (builtin.target.isMusl())
27342734 linux.Sigaction
27352735 else if (builtin.target.ptrBitWidth() == 64) extern struct {
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;
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;
27382738
27392739 flags: c_uint,
27402740 handler: extern union {
......@@ -2742,10 +2742,10 @@ pub const Sigaction = switch (native_os) {
27422742 sigaction: ?sigaction_fn,
27432743 },
27442744 mask: sigset_t,
2745 restorer: ?*const fn () callconv(.C) void = null,
2745 restorer: ?*const fn () callconv(.c) void = null,
27462746 } else extern struct {
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;
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;
27492749
27502750 flags: c_uint,
27512751 handler: extern union {
......@@ -2753,12 +2753,12 @@ pub const Sigaction = switch (native_os) {
27532753 sigaction: ?sigaction_fn,
27542754 },
27552755 mask: sigset_t,
2756 restorer: ?*const fn () callconv(.C) void = null,
2756 restorer: ?*const fn () callconv(.c) void = null,
27572757 __resv: [1]c_int = .{0},
27582758 },
27592759 .s390x => if (builtin.abi == .gnu) extern struct {
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;
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;
27622762
27632763 handler: extern union {
27642764 handler: ?handler_fn,
......@@ -2766,15 +2766,15 @@ pub const Sigaction = switch (native_os) {
27662766 },
27672767 __glibc_reserved0: c_int = 0,
27682768 flags: c_uint,
2769 restorer: ?*const fn () callconv(.C) void = null,
2769 restorer: ?*const fn () callconv(.c) void = null,
27702770 mask: sigset_t,
27712771 } else linux.Sigaction,
27722772 else => linux.Sigaction,
27732773 },
27742774 .emscripten => emscripten.Sigaction,
27752775 .netbsd, .macos, .ios, .tvos, .watchos, .visionos => extern struct {
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;
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;
27782778
27792779 handler: extern union {
27802780 handler: ?handler_fn,
......@@ -2784,8 +2784,8 @@ pub const Sigaction = switch (native_os) {
27842784 flags: c_uint,
27852785 },
27862786 .dragonfly, .freebsd => extern struct {
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;
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;
27892789
27902790 /// signal handler
27912791 handler: extern union {
......@@ -2798,8 +2798,8 @@ pub const Sigaction = switch (native_os) {
27982798 mask: sigset_t,
27992799 },
28002800 .solaris, .illumos => extern struct {
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;
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;
28032803
28042804 /// signal options
28052805 flags: c_uint,
......@@ -2812,8 +2812,8 @@ pub const Sigaction = switch (native_os) {
28122812 mask: sigset_t,
28132813 },
28142814 .haiku => extern struct {
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;
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;
28172817
28182818 /// signal handler
28192819 handler: extern union {
......@@ -2831,8 +2831,8 @@ pub const Sigaction = switch (native_os) {
28312831 userdata: *allowzero anyopaque = undefined,
28322832 },
28332833 .openbsd => extern struct {
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;
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;
28362836
28372837 /// signal handler
28382838 handler: extern union {
......@@ -6410,7 +6410,7 @@ pub const EAI = switch (native_os) {
64106410 else => void,
64116411};
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
64156415pub const Stat = switch (native_os) {
64166416 .linux => switch (native_arch) {
......@@ -9396,7 +9396,7 @@ pub extern "c" fn futimens(fd: fd_t, times: *const [2]timespec) c_int;
93969396pub extern "c" fn pthread_create(
93979397 noalias newthread: *pthread_t,
93989398 noalias attr: ?*const pthread_attr_t,
9399 start_routine: *const fn (?*anyopaque) callconv(.C) ?*anyopaque,
9399 start_routine: *const fn (?*anyopaque) callconv(.c) ?*anyopaque,
94009400 noalias arg: ?*anyopaque,
94019401) E;
94029402pub extern "c" fn pthread_attr_init(attr: *pthread_attr_t) E;
......@@ -9408,13 +9408,13 @@ pub extern "c" fn pthread_self() pthread_t;
94089408pub extern "c" fn pthread_join(thread: pthread_t, arg_return: ?*?*anyopaque) E;
94099409pub extern "c" fn pthread_detach(thread: pthread_t) E;
94109410pub extern "c" fn pthread_atfork(
9411 prepare: ?*const fn () callconv(.C) void,
9412 parent: ?*const fn () callconv(.C) void,
9413 child: ?*const fn () callconv(.C) void,
9411 prepare: ?*const fn () callconv(.c) void,
9412 parent: ?*const fn () callconv(.c) void,
9413 child: ?*const fn () callconv(.c) void,
94149414) c_int;
94159415pub extern "c" fn pthread_key_create(
94169416 key: *pthread_key_t,
9417 destructor: ?*const fn (value: *anyopaque) callconv(.C) void,
9417 destructor: ?*const fn (value: *anyopaque) callconv(.c) void,
94189418) E;
94199419pub extern "c" fn pthread_key_delete(key: pthread_key_t) E;
94209420pub 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;
95309530pub extern "c" fn pthread_cond_broadcast(cond: *pthread_cond_t) E;
95319531pub 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;
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;
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;
9538pub extern "c" fn pthread_rwlock_unlock(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;
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;
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;
95399539
95409540pub const pthread_t = *opaque {};
95419541pub 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) {
379379};
380380
381381extern "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 {
383383 return mach_task_self_;
384384}
385385
......@@ -873,7 +873,7 @@ pub const DISPATCH_TIME_FOREVER = ~@as(dispatch_time_t, 0);
873873pub extern "c" fn dispatch_time(when: dispatch_time_t, delta: i64) dispatch_time_t;
874874
875875const dispatch_once_t = usize;
876const dispatch_function_t = fn (?*anyopaque) callconv(.C) void;
876const dispatch_function_t = fn (?*anyopaque) callconv(.c) void;
877877pub extern fn dispatch_once_f(
878878 predicate: *dispatch_once_t,
879879 context: ?*anyopaque,
lib/std/c/dragonfly.zig+1-1
......@@ -156,7 +156,7 @@ pub const E = enum(u16) {
156156
157157pub 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
161161pub const cmsghdr = extern struct {
162162 len: socklen_t,
lib/std/crypto/phc_encoding.zig+1-1
......@@ -164,7 +164,7 @@ pub fn deserialize(comptime HashResult: type, str: []const u8) Error!HashResult
164164 // with default values
165165 var expected_fields: usize = 0;
166166 inline for (comptime meta.fields(HashResult)) |p| {
167 if (@typeInfo(p.type) != .optional and p.default_value == null) {
167 if (@typeInfo(p.type) != .optional and p.default_value_ptr == null) {
168168 expected_fields += 1;
169169 }
170170 }
lib/std/crypto/tlcsprng.zig+1-1
......@@ -133,7 +133,7 @@ fn setupPthreadAtforkAndFill(buffer: []u8) void {
133133 return initAndFill(buffer);
134134}
135135
136fn childAtForkHandler() callconv(.C) void {
136fn childAtForkHandler() callconv(.c) void {
137137 // The atfork handler is global, this function may be called after
138138 // fork()-ing threads that never initialized the CSPRNG context.
139139 if (wipe_mem.len == 0) return;
lib/std/debug.zig+1-1
......@@ -1269,7 +1269,7 @@ fn resetSegfaultHandler() void {
12691269 updateSegfaultHandler(&act);
12701270}
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 {
12731273 // Reset to the default handler so that if a segfault happens in this handler it will crash
12741274 // the process. Also when this handler returns, the original instruction will be repeated
12751275 // and the resulting segfault will crash the process rather than continually dump stack traces.
lib/std/enums.zig+1-1
......@@ -19,7 +19,7 @@ pub fn EnumFieldStruct(comptime E: type, comptime Data: type, comptime field_def
1919 struct_field.* = .{
2020 .name = enum_field.name ++ "",
2121 .type = Data,
22 .default_value = if (field_default) |d| @as(?*const anyopaque, @ptrCast(&d)) else null,
22 .default_value_ptr = if (field_default) |d| @as(?*const anyopaque, @ptrCast(&d)) else null,
2323 .is_comptime = false,
2424 .alignment = if (@sizeOf(Data) > 0) @alignOf(Data) else 0,
2525 };
lib/std/fmt.zig+8-8
......@@ -434,7 +434,7 @@ pub fn formatAddress(value: anytype, options: FormatOptions, writer: anytype) @T
434434 switch (@typeInfo(T)) {
435435 .pointer => |info| {
436436 try writer.writeAll(@typeName(info.child) ++ "@");
437 if (info.size == .Slice)
437 if (info.size == .slice)
438438 try formatInt(@intFromPtr(value.ptr), 16, .lower, FormatOptions{}, writer)
439439 else
440440 try formatInt(@intFromPtr(value), 16, .lower, FormatOptions{}, writer);
......@@ -460,12 +460,12 @@ pub fn defaultSpec(comptime T: type) [:0]const u8 {
460460 switch (@typeInfo(T)) {
461461 .array, .vector => return ANY,
462462 .pointer => |ptr_info| switch (ptr_info.size) {
463 .One => switch (@typeInfo(ptr_info.child)) {
463 .one => switch (@typeInfo(ptr_info.child)) {
464464 .array => return ANY,
465465 else => {},
466466 },
467 .Many, .C => return "*",
468 .Slice => return ANY,
467 .many, .c => return "*",
468 .slice => return ANY,
469469 },
470470 .optional => |info| return "?" ++ defaultSpec(info.child),
471471 .error_union => |info| return "!" ++ defaultSpec(info.payload),
......@@ -624,16 +624,16 @@ pub fn formatType(
624624 try writer.writeAll(" }");
625625 },
626626 .pointer => |ptr_info| switch (ptr_info.size) {
627 .One => switch (@typeInfo(ptr_info.child)) {
627 .one => switch (@typeInfo(ptr_info.child)) {
628628 .array, .@"enum", .@"union", .@"struct" => {
629629 return formatType(value.*, actual_fmt, options, writer, max_depth);
630630 },
631631 else => return format(writer, "{s}@{x}", .{ @typeName(ptr_info.child), @intFromPtr(value) }),
632632 },
633 .Many, .C => {
633 .many, .c => {
634634 if (actual_fmt.len == 0)
635635 @compileError("cannot format pointer without a specifier (i.e. {s} or {*})");
636 if (ptr_info.sentinel) |_| {
636 if (ptr_info.sentinel() != null) {
637637 return formatType(mem.span(value), actual_fmt, options, writer, max_depth);
638638 }
639639 if (actual_fmt[0] == 's' and ptr_info.child == u8) {
......@@ -641,7 +641,7 @@ pub fn formatType(
641641 }
642642 invalidFmtError(fmt, value);
643643 },
644 .Slice => {
644 .slice => {
645645 if (actual_fmt.len == 0)
646646 @compileError("cannot format slice without a specifier (i.e. {s} or {any})");
647647 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)
2323 const info = @typeInfo(@TypeOf(key));
2424
2525 switch (info.pointer.size) {
26 .One => switch (strat) {
26 .one => switch (strat) {
2727 .Shallow => hash(hasher, @intFromPtr(key), .Shallow),
2828 .Deep => hash(hasher, key.*, .Shallow),
2929 .DeepRecursive => hash(hasher, key.*, .DeepRecursive),
3030 },
3131
32 .Slice => {
32 .slice => {
3333 switch (strat) {
3434 .Shallow => {
3535 hashPointer(hasher, key.ptr, .Shallow);
......@@ -40,8 +40,8 @@ pub fn hashPointer(hasher: anytype, key: anytype, comptime strat: HashStrategy)
4040 hash(hasher, key.len, .Shallow);
4141 },
4242
43 .Many,
44 .C,
43 .many,
44 .c,
4545 => switch (strat) {
4646 .Shallow => hash(hasher, @intFromPtr(key), .Shallow),
4747 else => @compileError(
......@@ -167,7 +167,7 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {
167167
168168inline fn typeContainsSlice(comptime K: type) bool {
169169 return switch (@typeInfo(K)) {
170 .pointer => |info| info.size == .Slice,
170 .pointer => |info| info.size == .slice,
171171
172172 inline .@"struct", .@"union" => |info| {
173173 inline for (info.fields) |field| {
lib/std/io.zig+1-1
......@@ -805,7 +805,7 @@ pub fn PollFiles(comptime StreamEnum: type) type {
805805 struct_field.* = .{
806806 .name = enum_field.name ++ "",
807807 .type = fs.File,
808 .default_value = null,
808 .default_value_ptr = null,
809809 .is_comptime = false,
810810 .alignment = @alignOf(fs.File),
811811 };
lib/std/io/fixed_buffer_stream.zig+3-3
......@@ -118,14 +118,14 @@ fn Slice(comptime T: type) type {
118118 .pointer => |ptr_info| {
119119 var new_ptr_info = ptr_info;
120120 switch (ptr_info.size) {
121 .Slice => {},
122 .One => switch (@typeInfo(ptr_info.child)) {
121 .slice => {},
122 .one => switch (@typeInfo(ptr_info.child)) {
123123 .array => |info| new_ptr_info.child = info.child,
124124 else => @compileError("invalid type given to fixedBufferStream"),
125125 },
126126 else => @compileError("invalid type given to fixedBufferStream"),
127127 }
128 new_ptr_info.size = .Slice;
128 new_ptr_info.size = .slice;
129129 return @Type(.{ .pointer = new_ptr_info });
130130 },
131131 else => @compileError("invalid type given to fixedBufferStream"),
lib/std/json/static.zig+13-15
......@@ -451,12 +451,12 @@ pub fn innerParse(
451451
452452 .pointer => |ptrInfo| {
453453 switch (ptrInfo.size) {
454 .One => {
454 .one => {
455455 const r: *ptrInfo.child = try allocator.create(ptrInfo.child);
456456 r.* = try innerParse(ptrInfo.child, allocator, source, options);
457457 return r;
458458 },
459 .Slice => {
459 .slice => {
460460 switch (try source.peekNextTokenType()) {
461461 .array_begin => {
462462 _ = try source.next();
......@@ -476,9 +476,8 @@ pub fn innerParse(
476476 arraylist.appendAssumeCapacity(try innerParse(ptrInfo.child, allocator, source, options));
477477 }
478478
479 if (ptrInfo.sentinel) |some| {
480 const sentinel_value = @as(*align(1) const ptrInfo.child, @ptrCast(some)).*;
481 return try arraylist.toOwnedSliceSentinel(sentinel_value);
479 if (ptrInfo.sentinel()) |s| {
480 return try arraylist.toOwnedSliceSentinel(s);
482481 }
483482
484483 return try arraylist.toOwnedSlice();
......@@ -487,11 +486,11 @@ pub fn innerParse(
487486 if (ptrInfo.child != u8) return error.UnexpectedToken;
488487
489488 // Dynamic length string.
490 if (ptrInfo.sentinel) |sentinel_ptr| {
489 if (ptrInfo.sentinel()) |s| {
491490 // Use our own array list so we can append the sentinel.
492491 var value_list = ArrayList(u8).init(allocator);
493492 _ = try source.allocNextIntoArrayList(&value_list, .alloc_always);
494 return try value_list.toOwnedSliceSentinel(@as(*const u8, @ptrCast(sentinel_ptr)).*);
493 return try value_list.toOwnedSliceSentinel(s);
495494 }
496495 if (ptrInfo.is_const) {
497496 switch (try source.nextAllocMax(allocator, options.allocate.?, options.max_value_len.?)) {
......@@ -706,16 +705,16 @@ pub fn innerParseFromValue(
706705
707706 .pointer => |ptrInfo| {
708707 switch (ptrInfo.size) {
709 .One => {
708 .one => {
710709 const r: *ptrInfo.child = try allocator.create(ptrInfo.child);
711710 r.* = try innerParseFromValue(ptrInfo.child, allocator, source, options);
712711 return r;
713712 },
714 .Slice => {
713 .slice => {
715714 switch (source) {
716715 .array => |array| {
717 const r = if (ptrInfo.sentinel) |sentinel_ptr|
718 try allocator.allocSentinel(ptrInfo.child, array.items.len, @as(*align(1) const ptrInfo.child, @ptrCast(sentinel_ptr)).*)
716 const r = if (ptrInfo.sentinel()) |sentinel|
717 try allocator.allocSentinel(ptrInfo.child, array.items.len, sentinel)
719718 else
720719 try allocator.alloc(ptrInfo.child, array.items.len);
721720
......@@ -729,8 +728,8 @@ pub fn innerParseFromValue(
729728 if (ptrInfo.child != u8) return error.UnexpectedToken;
730729 // Dynamic length string.
731730
732 const r = if (ptrInfo.sentinel) |sentinel_ptr|
733 try allocator.allocSentinel(ptrInfo.child, s.len, @as(*align(1) const ptrInfo.child, @ptrCast(sentinel_ptr)).*)
731 const r = if (ptrInfo.sentinel()) |sentinel|
732 try allocator.allocSentinel(ptrInfo.child, s.len, sentinel)
734733 else
735734 try allocator.alloc(ptrInfo.child, s.len);
736735 @memcpy(r[0..], s);
......@@ -787,8 +786,7 @@ fn sliceToEnum(comptime T: type, slice: []const u8) !T {
787786fn fillDefaultStructValues(comptime T: type, r: *T, fields_seen: *[@typeInfo(T).@"struct".fields.len]bool) !void {
788787 inline for (@typeInfo(T).@"struct".fields, 0..) |field, i| {
789788 if (!fields_seen[i]) {
790 if (field.default_value) |default_ptr| {
791 const default = @as(*align(1) const field.type, @ptrCast(default_ptr)).*;
789 if (field.defaultValue()) |default| {
792790 @field(r, field.name) = default;
793791 } else {
794792 return error.MissingField;
lib/std/json/stringify.zig+4-4
......@@ -631,7 +631,7 @@ pub fn WriteStream(
631631 },
632632 .error_set => return self.stringValue(@errorName(value)),
633633 .pointer => |ptr_info| switch (ptr_info.size) {
634 .One => switch (@typeInfo(ptr_info.child)) {
634 .one => switch (@typeInfo(ptr_info.child)) {
635635 .array => {
636636 // Coerce `*[N]T` to `[]const T`.
637637 const Slice = []const std.meta.Elem(ptr_info.child);
......@@ -641,10 +641,10 @@ pub fn WriteStream(
641641 return self.write(value.*);
642642 },
643643 },
644 .Many, .Slice => {
645 if (ptr_info.size == .Many and ptr_info.sentinel == null)
644 .many, .slice => {
645 if (ptr_info.size == .many and ptr_info.sentinel() == null)
646646 @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
649649 if (ptr_info.child == u8) {
650650 // This is a []const u8, or some similar Zig string.
lib/std/mem.zig+60-73
......@@ -262,9 +262,9 @@ pub fn zeroes(comptime T: type) T {
262262 },
263263 .pointer => |ptr_info| {
264264 switch (ptr_info.size) {
265 .Slice => {
266 if (ptr_info.sentinel) |sentinel| {
267 if (ptr_info.child == u8 and @as(*const u8, @ptrCast(sentinel)).* == 0) {
265 .slice => {
266 if (ptr_info.sentinel()) |sentinel| {
267 if (ptr_info.child == u8 and sentinel == 0) {
268268 return ""; // A special case for the most common use-case: null-terminated strings.
269269 }
270270 @compileError("Can't set a sentinel slice to zero. This would require allocating memory.");
......@@ -272,21 +272,17 @@ pub fn zeroes(comptime T: type) T {
272272 return &[_]ptr_info.child{};
273273 }
274274 },
275 .C => {
275 .c => {
276276 return null;
277277 },
278 .One, .Many => {
278 .one, .many => {
279279 if (ptr_info.is_allowzero) return @ptrFromInt(0);
280280 @compileError("Only nullable and allowzero pointers can be set to zero.");
281281 },
282282 }
283283 },
284284 .array => |info| {
285 if (info.sentinel) |sentinel_ptr| {
286 const sentinel = @as(*align(1) const info.child, @ptrCast(sentinel_ptr)).*;
287 return [_:sentinel]info.child{zeroes(info.child)} ** info.len;
288 }
289 return [_]info.child{zeroes(info.child)} ** info.len;
285 return @splat(zeroes(info.child));
290286 },
291287 .vector => |info| {
292288 return @splat(zeroes(info.child));
......@@ -456,9 +452,8 @@ pub fn zeroInit(comptime T: type, init: anytype) T {
456452 @field(value, field.name) = @field(init, field.name);
457453 },
458454 }
459 } else if (field.default_value) |default_value_ptr| {
460 const default_value = @as(*align(1) const field.type, @ptrCast(default_value_ptr)).*;
461 @field(value, field.name) = default_value;
455 } else if (field.defaultValue()) |val| {
456 @field(value, field.name) = val;
462457 } else {
463458 switch (@typeInfo(field.type)) {
464459 .@"struct" => {
......@@ -781,14 +776,14 @@ fn Span(comptime T: type) type {
781776 .pointer => |ptr_info| {
782777 var new_ptr_info = ptr_info;
783778 switch (ptr_info.size) {
784 .C => {
785 new_ptr_info.sentinel = &@as(ptr_info.child, 0);
779 .c => {
780 new_ptr_info.sentinel_ptr = &@as(ptr_info.child, 0);
786781 new_ptr_info.is_allowzero = false;
787782 },
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)),
783 .many => if (ptr_info.sentinel() == null) @compileError("invalid type given to std.mem.span: " ++ @typeName(T)),
784 .one, .slice => @compileError("invalid type given to std.mem.span: " ++ @typeName(T)),
790785 }
791 new_ptr_info.size = .Slice;
786 new_ptr_info.size = .slice;
792787 return @Type(.{ .pointer = new_ptr_info });
793788 },
794789 else => {},
......@@ -822,8 +817,7 @@ pub fn span(ptr: anytype) Span(@TypeOf(ptr)) {
822817 const Result = Span(@TypeOf(ptr));
823818 const l = len(ptr);
824819 const ptr_info = @typeInfo(Result).pointer;
825 if (ptr_info.sentinel) |s_ptr| {
826 const s = @as(*align(1) const ptr_info.child, @ptrCast(s_ptr)).*;
820 if (ptr_info.sentinel()) |s| {
827821 return ptr[0..l :s];
828822 } else {
829823 return ptr[0..l];
......@@ -845,40 +839,38 @@ fn SliceTo(comptime T: type, comptime end: std.meta.Elem(T)) type {
845839 },
846840 .pointer => |ptr_info| {
847841 var new_ptr_info = ptr_info;
848 new_ptr_info.size = .Slice;
842 new_ptr_info.size = .slice;
849843 switch (ptr_info.size) {
850 .One => switch (@typeInfo(ptr_info.child)) {
844 .one => switch (@typeInfo(ptr_info.child)) {
851845 .array => |array_info| {
852846 new_ptr_info.child = array_info.child;
853847 // The return type must only be sentinel terminated if we are guaranteed
854848 // to find the value searched for, which is only the case if it matches
855849 // the sentinel of the type passed.
856 if (array_info.sentinel) |sentinel_ptr| {
857 const sentinel = @as(*align(1) const array_info.child, @ptrCast(sentinel_ptr)).*;
858 if (end == sentinel) {
859 new_ptr_info.sentinel = &end;
850 if (array_info.sentinel()) |s| {
851 if (end == s) {
852 new_ptr_info.sentinel_ptr = &end;
860853 } else {
861 new_ptr_info.sentinel = null;
854 new_ptr_info.sentinel_ptr = null;
862855 }
863856 }
864857 },
865858 else => {},
866859 },
867 .Many, .Slice => {
860 .many, .slice => {
868861 // The return type must only be sentinel terminated if we are guaranteed
869862 // to find the value searched for, which is only the case if it matches
870863 // the sentinel of the type passed.
871 if (ptr_info.sentinel) |sentinel_ptr| {
872 const sentinel = @as(*align(1) const ptr_info.child, @ptrCast(sentinel_ptr)).*;
873 if (end == sentinel) {
874 new_ptr_info.sentinel = &end;
864 if (ptr_info.sentinel()) |s| {
865 if (end == s) {
866 new_ptr_info.sentinel_ptr = &end;
875867 } else {
876 new_ptr_info.sentinel = null;
868 new_ptr_info.sentinel_ptr = null;
877869 }
878870 }
879871 },
880 .C => {
881 new_ptr_info.sentinel = &end;
872 .c => {
873 new_ptr_info.sentinel_ptr = &end;
882874 // C pointers are always allowzero, but we don't want the return type to be.
883875 assert(new_ptr_info.is_allowzero);
884876 new_ptr_info.is_allowzero = false;
......@@ -906,8 +898,7 @@ pub fn sliceTo(ptr: anytype, comptime end: std.meta.Elem(@TypeOf(ptr))) SliceTo(
906898 const Result = SliceTo(@TypeOf(ptr), end);
907899 const length = lenSliceTo(ptr, end);
908900 const ptr_info = @typeInfo(Result).pointer;
909 if (ptr_info.sentinel) |s_ptr| {
910 const s = @as(*align(1) const ptr_info.child, @ptrCast(s_ptr)).*;
901 if (ptr_info.sentinel()) |s| {
911902 return ptr[0..length :s];
912903 } else {
913904 return ptr[0..length];
......@@ -957,11 +948,10 @@ test sliceTo {
957948fn lenSliceTo(ptr: anytype, comptime end: std.meta.Elem(@TypeOf(ptr))) usize {
958949 switch (@typeInfo(@TypeOf(ptr))) {
959950 .pointer => |ptr_info| switch (ptr_info.size) {
960 .One => switch (@typeInfo(ptr_info.child)) {
951 .one => switch (@typeInfo(ptr_info.child)) {
961952 .array => |array_info| {
962 if (array_info.sentinel) |sentinel_ptr| {
963 const sentinel = @as(*align(1) const array_info.child, @ptrCast(sentinel_ptr)).*;
964 if (sentinel == end) {
953 if (array_info.sentinel()) |s| {
954 if (s == end) {
965955 return indexOfSentinel(array_info.child, end, ptr);
966956 }
967957 }
......@@ -969,27 +959,25 @@ fn lenSliceTo(ptr: anytype, comptime end: std.meta.Elem(@TypeOf(ptr))) usize {
969959 },
970960 else => {},
971961 },
972 .Many => if (ptr_info.sentinel) |sentinel_ptr| {
973 const sentinel = @as(*align(1) const ptr_info.child, @ptrCast(sentinel_ptr)).*;
974 if (sentinel == end) {
962 .many => if (ptr_info.sentinel()) |s| {
963 if (s == end) {
975964 return indexOfSentinel(ptr_info.child, end, ptr);
976965 }
977966 // We're looking for something other than the sentinel,
978967 // but iterating past the sentinel would be a bug so we need
979968 // to check for both.
980969 var i: usize = 0;
981 while (ptr[i] != end and ptr[i] != sentinel) i += 1;
970 while (ptr[i] != end and ptr[i] != s) i += 1;
982971 return i;
983972 },
984 .C => {
973 .c => {
985974 assert(ptr != null);
986975 return indexOfSentinel(ptr_info.child, end, ptr);
987976 },
988 .Slice => {
989 if (ptr_info.sentinel) |sentinel_ptr| {
990 const sentinel = @as(*align(1) const ptr_info.child, @ptrCast(sentinel_ptr)).*;
991 if (sentinel == end) {
992 return indexOfSentinel(ptr_info.child, sentinel, ptr);
977 .slice => {
978 if (ptr_info.sentinel()) |s| {
979 if (s == end) {
980 return indexOfSentinel(ptr_info.child, s, ptr);
993981 }
994982 }
995983 return indexOfScalar(ptr_info.child, ptr, end) orelse ptr.len;
......@@ -1039,13 +1027,12 @@ test lenSliceTo {
10391027pub fn len(value: anytype) usize {
10401028 switch (@typeInfo(@TypeOf(value))) {
10411029 .pointer => |info| switch (info.size) {
1042 .Many => {
1043 const sentinel_ptr = info.sentinel orelse
1030 .many => {
1031 const sentinel = info.sentinel() orelse
10441032 @compileError("invalid type given to std.mem.len: " ++ @typeName(@TypeOf(value)));
1045 const sentinel = @as(*align(1) const info.child, @ptrCast(sentinel_ptr)).*;
10461033 return indexOfSentinel(info.child, sentinel, value);
10471034 },
1048 .C => {
1035 .c => {
10491036 assert(value != null);
10501037 return indexOfSentinel(info.child, 0, value);
10511038 },
......@@ -3582,19 +3569,19 @@ fn ReverseIterator(comptime T: type) type {
35823569 const Pointer = blk: {
35833570 switch (@typeInfo(T)) {
35843571 .pointer => |ptr_info| switch (ptr_info.size) {
3585 .One => switch (@typeInfo(ptr_info.child)) {
3572 .one => switch (@typeInfo(ptr_info.child)) {
35863573 .array => |array_info| {
35873574 var new_ptr_info = ptr_info;
3588 new_ptr_info.size = .Many;
3575 new_ptr_info.size = .many;
35893576 new_ptr_info.child = array_info.child;
3590 new_ptr_info.sentinel = array_info.sentinel;
3577 new_ptr_info.sentinel_ptr = array_info.sentinel_ptr;
35913578 break :blk @Type(.{ .pointer = new_ptr_info });
35923579 },
35933580 else => {},
35943581 },
3595 .Slice => {
3582 .slice => {
35963583 var new_ptr_info = ptr_info;
3597 new_ptr_info.size = .Many;
3584 new_ptr_info.size = .many;
35983585 break :blk @Type(.{ .pointer = new_ptr_info });
35993586 },
36003587 else => {},
......@@ -3606,9 +3593,9 @@ fn ReverseIterator(comptime T: type) type {
36063593 const Element = std.meta.Elem(Pointer);
36073594 const ElementPointer = @Type(.{ .pointer = ptr: {
36083595 var ptr = @typeInfo(Pointer).pointer;
3609 ptr.size = .One;
3596 ptr.size = .one;
36103597 ptr.child = Element;
3611 ptr.sentinel = null;
3598 ptr.sentinel_ptr = null;
36123599 break :ptr ptr;
36133600 } });
36143601 return struct {
......@@ -3912,7 +3899,7 @@ pub fn alignPointerOffset(ptr: anytype, align_to: usize) ?usize {
39123899
39133900 const T = @TypeOf(ptr);
39143901 const info = @typeInfo(T);
3915 if (info != .pointer or info.pointer.size != .Many)
3902 if (info != .pointer or info.pointer.size != .many)
39163903 @compileError("expected many item pointer, got " ++ @typeName(T));
39173904
39183905 // Do nothing if the pointer is already well-aligned.
......@@ -3979,16 +3966,16 @@ fn CopyPtrAttrs(
39793966 .alignment = info.alignment,
39803967 .address_space = info.address_space,
39813968 .child = child,
3982 .sentinel = null,
3969 .sentinel_ptr = null,
39833970 },
39843971 });
39853972}
39863973
39873974fn AsBytesReturnType(comptime P: type) type {
39883975 const pointer = @typeInfo(P).pointer;
3989 assert(pointer.size == .One);
3976 assert(pointer.size == .one);
39903977 const size = @sizeOf(pointer.child);
3991 return CopyPtrAttrs(P, .One, [size]u8);
3978 return CopyPtrAttrs(P, .one, [size]u8);
39923979}
39933980
39943981/// Given a pointer to a single item, returns a slice of the underlying bytes, preserving pointer attributes.
......@@ -4071,7 +4058,7 @@ test toBytes {
40714058}
40724059
40734060fn BytesAsValueReturnType(comptime T: type, comptime B: type) type {
4074 return CopyPtrAttrs(B, .One, T);
4061 return CopyPtrAttrs(B, .one, T);
40754062}
40764063
40774064/// Given a pointer to an array of bytes, returns a pointer to a value of the specified type
......@@ -4150,7 +4137,7 @@ test bytesToValue {
41504137}
41514138
41524139fn BytesAsSliceReturnType(comptime T: type, comptime bytesType: type) type {
4153 return CopyPtrAttrs(bytesType, .Slice, T);
4140 return CopyPtrAttrs(bytesType, .slice, T);
41544141}
41554142
41564143/// Given a slice of bytes, returns a slice of the specified type
......@@ -4162,7 +4149,7 @@ pub fn bytesAsSlice(comptime T: type, bytes: anytype) BytesAsSliceReturnType(T,
41624149 return &[0]T{};
41634150 }
41644151
4165 const cast_target = CopyPtrAttrs(@TypeOf(bytes), .Many, T);
4152 const cast_target = CopyPtrAttrs(@TypeOf(bytes), .many, T);
41664153
41674154 return @as(cast_target, @ptrCast(bytes))[0..@divExact(bytes.len, @sizeOf(T))];
41684155}
......@@ -4237,7 +4224,7 @@ test "bytesAsSlice preserves pointer attributes" {
42374224}
42384225
42394226fn SliceAsBytesReturnType(comptime Slice: type) type {
4240 return CopyPtrAttrs(Slice, .Slice, u8);
4227 return CopyPtrAttrs(Slice, .slice, u8);
42414228}
42424229
42434230/// Given a slice, returns a slice of the underlying bytes, preserving pointer attributes.
......@@ -4251,7 +4238,7 @@ pub fn sliceAsBytes(slice: anytype) SliceAsBytesReturnType(@TypeOf(slice)) {
42514238 // it may be equal to zero and fail a null check
42524239 if (slice.len == 0 and std.meta.sentinel(Slice) == null) return &[0]u8{};
42534240
4254 const cast_target = CopyPtrAttrs(Slice, .Many, u8);
4241 const cast_target = CopyPtrAttrs(Slice, .many, u8);
42554242
42564243 return @as(cast_target, @ptrCast(slice))[0 .. slice.len * @sizeOf(std.meta.Elem(Slice))];
42574244}
......@@ -4540,14 +4527,14 @@ fn AlignedSlice(comptime AttributeSource: type, comptime new_alignment: usize) t
45404527 const info = @typeInfo(AttributeSource).pointer;
45414528 return @Type(.{
45424529 .pointer = .{
4543 .size = .Slice,
4530 .size = .slice,
45444531 .is_const = info.is_const,
45454532 .is_volatile = info.is_volatile,
45464533 .is_allowzero = info.is_allowzero,
45474534 .alignment = new_alignment,
45484535 .address_space = info.address_space,
45494536 .child = info.child,
4550 .sentinel = null,
4537 .sentinel_ptr = null,
45514538 },
45524539 });
45534540}
lib/std/mem/Allocator.zig+2-2
......@@ -110,7 +110,7 @@ pub fn create(self: Allocator, comptime T: type) Error!*T {
110110/// have the same address and alignment property.
111111pub fn destroy(self: Allocator, ptr: anytype) void {
112112 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");
114114 const T = info.child;
115115 if (@sizeOf(T) == 0) return;
116116 const non_const_ptr = @as([*]u8, @ptrCast(@constCast(ptr)));
......@@ -307,7 +307,7 @@ pub fn reallocAdvanced(
307307pub fn free(self: Allocator, memory: anytype) void {
308308 const Slice = @typeInfo(@TypeOf(memory)).pointer;
309309 const bytes = mem.sliceAsBytes(memory);
310 const bytes_len = bytes.len + if (Slice.sentinel != null) @sizeOf(Slice.child) else 0;
310 const bytes_len = bytes.len + if (Slice.sentinel() != null) @sizeOf(Slice.child) else 0;
311311 if (bytes_len == 0) return;
312312 const non_const_ptr = @constCast(bytes.ptr);
313313 // TODO: https://github.com/ziglang/zig/issues/4298
lib/std/meta.zig+22-31
......@@ -103,12 +103,12 @@ pub fn Elem(comptime T: type) type {
103103 .array => |info| return info.child,
104104 .vector => |info| return info.child,
105105 .pointer => |info| switch (info.size) {
106 .One => switch (@typeInfo(info.child)) {
106 .one => switch (@typeInfo(info.child)) {
107107 .array => |array_info| return array_info.child,
108108 .vector => |vector_info| return vector_info.child,
109109 else => {},
110110 },
111 .Many, .C, .Slice => return info.child,
111 .many, .c, .slice => return info.child,
112112 },
113113 .optional => |info| return Elem(info.child),
114114 else => {},
......@@ -132,21 +132,12 @@ test Elem {
132132/// Result is always comptime-known.
133133pub inline fn sentinel(comptime T: type) ?Elem(T) {
134134 switch (@typeInfo(T)) {
135 .array => |info| {
136 const sentinel_ptr = info.sentinel orelse return null;
137 return @as(*const info.child, @ptrCast(sentinel_ptr)).*;
138 },
135 .array => |info| return info.sentinel(),
139136 .pointer => |info| {
140137 switch (info.size) {
141 .Many, .Slice => {
142 const sentinel_ptr = info.sentinel orelse return null;
143 return @as(*align(1) const info.child, @ptrCast(sentinel_ptr)).*;
144 },
145 .One => switch (@typeInfo(info.child)) {
146 .array => |array_info| {
147 const sentinel_ptr = array_info.sentinel orelse return null;
148 return @as(*align(1) const array_info.child, @ptrCast(sentinel_ptr)).*;
149 },
138 .many, .slice => return info.sentinel(),
139 .one => switch (@typeInfo(info.child)) {
140 .array => |array_info| return array_info.sentinel(),
150141 else => {},
151142 },
152143 else => {},
......@@ -178,7 +169,7 @@ fn testSentinel() !void {
178169pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type {
179170 switch (@typeInfo(T)) {
180171 .pointer => |info| switch (info.size) {
181 .One => switch (@typeInfo(info.child)) {
172 .one => switch (@typeInfo(info.child)) {
182173 .array => |array_info| return @Type(.{
183174 .pointer = .{
184175 .size = info.size,
......@@ -190,16 +181,16 @@ pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type {
190181 .array = .{
191182 .len = array_info.len,
192183 .child = array_info.child,
193 .sentinel = @as(?*const anyopaque, @ptrCast(&sentinel_val)),
184 .sentinel_ptr = @as(?*const anyopaque, @ptrCast(&sentinel_val)),
194185 },
195186 }),
196187 .is_allowzero = info.is_allowzero,
197 .sentinel = info.sentinel,
188 .sentinel_ptr = info.sentinel_ptr,
198189 },
199190 }),
200191 else => {},
201192 },
202 .Many, .Slice => return @Type(.{
193 .many, .slice => return @Type(.{
203194 .pointer = .{
204195 .size = info.size,
205196 .is_const = info.is_const,
......@@ -208,14 +199,14 @@ pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type {
208199 .address_space = info.address_space,
209200 .child = info.child,
210201 .is_allowzero = info.is_allowzero,
211 .sentinel = @as(?*const anyopaque, @ptrCast(&sentinel_val)),
202 .sentinel_ptr = @as(?*const anyopaque, @ptrCast(&sentinel_val)),
212203 },
213204 }),
214205 else => {},
215206 },
216207 .optional => |info| switch (@typeInfo(info.child)) {
217208 .pointer => |ptr_info| switch (ptr_info.size) {
218 .Many => return @Type(.{
209 .many => return @Type(.{
219210 .optional = .{
220211 .child = @Type(.{
221212 .pointer = .{
......@@ -226,7 +217,7 @@ pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type {
226217 .address_space = ptr_info.address_space,
227218 .child = ptr_info.child,
228219 .is_allowzero = ptr_info.is_allowzero,
229 .sentinel = @as(?*const anyopaque, @ptrCast(&sentinel_val)),
220 .sentinel_ptr = @as(?*const anyopaque, @ptrCast(&sentinel_val)),
230221 },
231222 }),
232223 },
......@@ -786,8 +777,8 @@ pub fn eql(a: anytype, b: @TypeOf(a)) bool {
786777 },
787778 .pointer => |info| {
788779 return switch (info.size) {
789 .One, .Many, .C => a == b,
790 .Slice => a.ptr == b.ptr and a.len == b.len,
780 .one, .many, .c => a == b,
781 .slice => a.ptr == b.ptr and a.len == b.len,
791782 };
792783 },
793784 .optional => {
......@@ -1018,7 +1009,7 @@ fn CreateUniqueTuple(comptime N: comptime_int, comptime types: [N]type) type {
10181009 tuple_fields[i] = .{
10191010 .name = std.fmt.bufPrintZ(&num_buf, "{d}", .{i}) catch unreachable,
10201011 .type = T,
1021 .default_value = null,
1012 .default_value_ptr = null,
10221013 .is_comptime = false,
10231014 .alignment = 0,
10241015 };
......@@ -1090,7 +1081,7 @@ test "Tuple deduplication" {
10901081test "ArgsTuple forwarding" {
10911082 const T1 = std.meta.Tuple(&.{ u32, f32, i8 });
10921083 const T2 = std.meta.ArgsTuple(fn (u32, f32, i8) void);
1093 const T3 = std.meta.ArgsTuple(fn (u32, f32, i8) callconv(.C) noreturn);
1084 const T3 = std.meta.ArgsTuple(fn (u32, f32, i8) callconv(.c) noreturn);
10941085
10951086 if (T1 != T2) {
10961087 @compileError("std.meta.ArgsTuple produces different types than std.meta.Tuple");
......@@ -1144,8 +1135,8 @@ test hasFn {
11441135pub inline fn hasMethod(comptime T: type, comptime name: []const u8) bool {
11451136 return switch (@typeInfo(T)) {
11461137 .pointer => |P| switch (P.size) {
1147 .One => hasFn(P.child, name),
1148 .Many, .Slice, .C => false,
1138 .one => hasFn(P.child, name),
1139 .many, .slice, .c => false,
11491140 },
11501141 else => hasFn(T, name),
11511142 };
......@@ -1200,12 +1191,12 @@ pub inline fn hasUniqueRepresentation(comptime T: type) bool {
12001191
12011192 .int => |info| @sizeOf(T) * 8 == info.bits,
12021193
1203 .pointer => |info| info.size != .Slice,
1194 .pointer => |info| info.size != .slice,
12041195
12051196 .optional => |info| switch (@typeInfo(info.child)) {
12061197 .pointer => |ptr| !ptr.is_allowzero and switch (ptr.size) {
1207 .Slice, .C => false,
1208 .One, .Many => true,
1198 .slice, .c => false,
1199 .one, .many => true,
12091200 },
12101201 else => false,
12111202 },
lib/std/meta/trailer_flags.zig+1-1
......@@ -25,7 +25,7 @@ pub fn TrailerFlags(comptime Fields: type) type {
2525 fields[i] = Type.StructField{
2626 .name = struct_field.name,
2727 .type = ?struct_field.type,
28 .default_value = &@as(?struct_field.type, null),
28 .default_value_ptr = &@as(?struct_field.type, null),
2929 .is_comptime = false,
3030 .alignment = @alignOf(?struct_field.type),
3131 };
lib/std/multi_array_list.zig+1-1
......@@ -571,7 +571,7 @@ pub fn MultiArrayList(comptime T: type) type {
571571 for (&entry_fields, sizes.fields) |*entry_field, i| entry_field.* = .{
572572 .name = fields[i].name ++ "_ptr",
573573 .type = *fields[i].type,
574 .default_value = null,
574 .default_value_ptr = null,
575575 .is_comptime = fields[i].is_comptime,
576576 .alignment = fields[i].alignment,
577577 };
lib/std/os/emscripten.zig+22-22
......@@ -12,7 +12,7 @@ const c = std.c;
1212pub const FILE = c.FILE;
1313
1414var __stack_chk_guard: usize = 0;
15fn __stack_chk_fail() callconv(.C) void {
15fn __stack_chk_fail() callconv(.c) void {
1616 std.debug.print("stack smashing detected: terminated\n", .{});
1717 emscripten_force_exit(127);
1818}
......@@ -547,8 +547,8 @@ pub const SIG = struct {
547547};
548548
549549pub const Sigaction = extern struct {
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;
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;
552552
553553 handler: extern union {
554554 handler: ?handler_fn,
......@@ -556,7 +556,7 @@ pub const Sigaction = extern struct {
556556 },
557557 mask: sigset_t,
558558 flags: c_uint,
559 restorer: ?*const fn () callconv(.C) void = null,
559 restorer: ?*const fn () callconv(.c) void = null,
560560};
561561
562562pub const sigset_t = [1024 / 32]u32;
......@@ -909,23 +909,23 @@ pub const LOG = struct {
909909 pub const INFO = 512;
910910};
911911
912pub const em_callback_func = ?*const fn () 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;
912pub const em_callback_func = ?*const fn () 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;
915915
916916pub 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;
919919pub 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;
922pub const em_async_wget2_onstatus_func = ?*const fn (c_uint, ?*anyopaque, c_int) 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;
923923
924924pub 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;
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;
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;
928pub const em_async_wget2_data_onprogress_func = ?*const fn (c_uint, ?*anyopaque, c_int, c_int) callconv(.c) void;
929929
930930pub 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;
931931pub extern "c" fn emscripten_async_wget2_abort(handle: c_int) void;
......@@ -944,8 +944,8 @@ pub extern "c" fn emscripten_pause_main_loop() void;
944944pub extern "c" fn emscripten_resume_main_loop() void;
945945pub extern "c" fn emscripten_cancel_main_loop() void;
946946
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;
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;
949949
950950pub extern "c" fn emscripten_set_socket_error_callback(userData: ?*anyopaque, callback: em_socket_error_callback) void;
951951pub 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;
968968pub extern "c" fn emscripten_get_canvas_size(width: *c_int, height: *c_int, isFullscreen: *c_int) void;
969969pub extern "c" fn emscripten_get_now() f64;
970970pub 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;
972972pub 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;
973973pub 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;
974974pub 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;
976976pub 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;
977977pub 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;
978978pub 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: [*:
983983pub extern "c" fn emscripten_idb_read_from_blob(blob: c_int, start: c_int, num: c_int, buffer: ?*anyopaque) void;
984984pub extern "c" fn emscripten_idb_free_blob(blob: c_int) void;
985985pub 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;
987987pub 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;
988988pub extern "c" fn emscripten_lazy_load_code() void;
989989pub const worker_handle = c_int;
990990pub extern "c" fn emscripten_create_worker(url: [*:0]const u8) worker_handle;
991991pub 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;
993993pub 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;
994994pub extern "c" fn emscripten_worker_respond(data: [*]u8, size: c_int) void;
995995pub 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:
10031003pub extern "c" fn emscripten_log(flags: c_int, format: [*:0]const u8, ...) void;
10041004pub extern "c" fn emscripten_get_callstack(flags: c_int, out: ?[*]u8, maxbytes: c_int) c_int;
10051005pub 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;
10071007pub extern "c" fn emscripten_scan_registers(func: em_scan_func) void;
10081008pub 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;
10101010pub 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;
10111011pub extern "c" fn emscripten_dlopen_promise(filename: [*:0]const u8, flags: c_int) em_promise_t;
10121012pub extern "c" fn emscripten_throw_number(number: f64) void;
......@@ -1024,7 +1024,7 @@ pub const struct__em_promise = opaque {};
10241024pub const em_promise_t = ?*struct__em_promise;
10251025pub const enum_em_promise_result_t = c_uint;
10261026pub 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
10291029pub extern "c" fn emscripten_promise_create() em_promise_t;
10301030pub 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;
6767pub const syscall_fork = syscall_bits.syscall_fork;
6868
6969pub fn clone(
70 func: *const fn (arg: usize) callconv(.C) u8,
70 func: *const fn (arg: usize) callconv(.c) u8,
7171 stack: usize,
7272 flags: u32,
7373 arg: usize,
......@@ -77,14 +77,14 @@ pub fn clone(
7777) usize {
7878 // Can't directly call a naked function; cast to C calling convention first.
7979 return @as(*const fn (
80 *const fn (arg: usize) callconv(.C) u8,
80 *const fn (arg: usize) callconv(.c) u8,
8181 usize,
8282 u32,
8383 usize,
8484 ?*i32,
8585 usize,
8686 ?*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);
8888}
8989
9090pub const ARCH = arch_bits.ARCH;
......@@ -494,7 +494,7 @@ pub const getauxval = if (extern_getauxval) struct {
494494 extern fn getauxval(index: usize) usize;
495495}.getauxval else getauxvalImpl;
496496
497fn getauxvalImpl(index: usize) callconv(.C) usize {
497fn getauxvalImpl(index: usize) callconv(.c) usize {
498498 const auxv = elf_aux_maybe orelse return 0;
499499 var i: usize = 0;
500500 while (auxv[i].a_type != std.elf.AT_NULL) : (i += 1) {
......@@ -1485,7 +1485,7 @@ pub fn flock(fd: fd_t, operation: i32) usize {
14851485}
14861486
14871487// 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;
14891489var vdso_clock_gettime: ?VdsoClockGettime = &init_vdso_clock_gettime;
14901490
14911491pub 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 {
15021502 return syscall2(.clock_gettime, @intFromEnum(clk_id), @intFromPtr(tp));
15031503}
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 {
15061506 const ptr: ?VdsoClockGettime = @ptrFromInt(vdso.lookup(VDSO.CGT_VER, VDSO.CGT_SYM));
15071507 // Note that we may not have a VDSO at all, update the stub address anyway
15081508 // 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
50705070pub const app_mask: sigset_t = [2]u32{ 0xfffffffc, 0x7fffffff } ++ [_]u32{0xffffffff} ** 30;
50715071
50725072const k_sigaction_funcs = struct {
5073 const handler = ?*align(1) const fn (i32) callconv(.C) void;
5074 const restorer = *const fn () callconv(.C) void;
5073 const handler = ?*align(1) const fn (i32) callconv(.c) void;
5074 const restorer = *const fn () callconv(.c) void;
50755075};
50765076
50775077pub const k_sigaction = switch (native_arch) {
......@@ -5097,8 +5097,8 @@ pub const k_sigaction = switch (native_arch) {
50975097
50985098/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
50995099pub const Sigaction = extern struct {
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;
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;
51025102
51035103 handler: extern union {
51045104 handler: ?handler_fn,
......@@ -5106,7 +5106,7 @@ pub const Sigaction = extern struct {
51065106 },
51075107 mask: sigset_t,
51085108 flags: c_uint,
5109 restorer: ?*const fn () callconv(.C) void = null,
5109 restorer: ?*const fn () callconv(.c) void = null,
51105110};
51115111
51125112const sigset_len = @typeInfo(sigset_t).array.len;
lib/std/os/linux/sparc64.zig+1-1
......@@ -233,7 +233,7 @@ pub const restore = restore_rt;
233233
234234// Need to use C ABI here instead of naked
235235// to prevent an infinite loop when calling rt_sigreturn.
236pub fn restore_rt() callconv(.C) void {
236pub fn restore_rt() callconv(.c) void {
237237 return asm volatile ("t 0x6d"
238238 :
239239 : [number] "{g1}" (@intFromEnum(SYS.rt_sigreturn)),
lib/std/os/plan9.zig+2-2
......@@ -186,8 +186,8 @@ pub const empty_sigset = 0;
186186pub const siginfo_t = c_long;
187187// TODO plan9 doesn't have sigaction_fn. Sigaction is not a union, but we include it here to be compatible.
188188pub const Sigaction = extern struct {
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;
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;
191191
192192 handler: extern union {
193193 handler: ?handler_fn,
lib/std/os/uefi/tables/boot_services.zig+2-2
......@@ -149,11 +149,11 @@ pub const BootServices = extern struct {
149149
150150 /// Installs one or more protocol interfaces into the boot services environment
151151 // 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
154154 /// Removes one or more protocol interfaces into the boot services environment
155155 // 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
158158 /// Computes and returns a 32-bit CRC for a data buffer.
159159 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(
55525552
55535553 if (builtin.link_libc) {
55545554 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 {
55565556 const context_ptr: *const Context = @ptrCast(@alignCast(data));
55575557 callback(info, size, context_ptr.*) catch |err| return @intFromError(err);
55585558 return 0;
lib/std/posix/test.zig+1-1
......@@ -849,7 +849,7 @@ test "sigaction" {
849849 const S = struct {
850850 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 {
853853 _ = ctx_ptr;
854854 // Check that we received the correct signal.
855855 switch (native_os) {
lib/std/testing.zig+5-5
......@@ -100,13 +100,13 @@ fn expectEqualInner(comptime T: type, expected: T, actual: T) !void {
100100
101101 .pointer => |pointer| {
102102 switch (pointer.size) {
103 .One, .Many, .C => {
103 .one, .many, .c => {
104104 if (actual != expected) {
105105 print("expected {*}, found {*}\n", .{ expected, actual });
106106 return error.TestExpectedEqual;
107107 }
108108 },
109 .Slice => {
109 .slice => {
110110 if (actual.ptr != expected.ptr) {
111111 print("expected slice ptr {*}, found {*}\n", .{ expected.ptr, actual.ptr });
112112 return error.TestExpectedEqual;
......@@ -726,13 +726,13 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe
726726 .pointer => |pointer| {
727727 switch (pointer.size) {
728728 // We have no idea what is behind those pointers, so the best we can do is `==` check.
729 .C, .Many => {
729 .c, .many => {
730730 if (actual != expected) {
731731 print("expected {*}, found {*}\n", .{ expected, actual });
732732 return error.TestExpectedEqual;
733733 }
734734 },
735 .One => {
735 .one => {
736736 // Length of those pointers are runtime value, so the best we can do is `==` check.
737737 switch (@typeInfo(pointer.child)) {
738738 .@"fn", .@"opaque" => {
......@@ -744,7 +744,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe
744744 else => try expectEqualDeep(expected.*, actual.*),
745745 }
746746 },
747 .Slice => {
747 .slice => {
748748 if (expected.len != actual.len) {
749749 print("Slice len not the same, expected {d}, found {d}\n", .{ expected.len, actual.len });
750750 return error.TestExpectedEqual;
lib/std/zig/Ast.zig+5-6
......@@ -2157,14 +2157,13 @@ fn fullFnProtoComponents(tree: Ast, info: full.FnProto.Components) full.FnProto
21572157
21582158fn fullPtrTypeComponents(tree: Ast, info: full.PtrType.Components) full.PtrType {
21592159 const token_tags = tree.tokens.items(.tag);
2160 const Size = std.builtin.Type.Pointer.Size;
2161 const size: Size = switch (token_tags[info.main_token]) {
2160 const size: std.builtin.Type.Pointer.Size = switch (token_tags[info.main_token]) {
21622161 .asterisk,
21632162 .asterisk_asterisk,
2164 => .One,
2163 => .one,
21652164 .l_bracket => switch (token_tags[info.main_token + 1]) {
2166 .asterisk => if (token_tags[info.main_token + 2] == .identifier) Size.C else Size.Many,
2167 else => Size.Slice,
2165 .asterisk => if (token_tags[info.main_token + 2] == .identifier) .c else .many,
2166 else => .slice,
21682167 },
21692168 else => unreachable,
21702169 };
......@@ -2180,7 +2179,7 @@ fn fullPtrTypeComponents(tree: Ast, info: full.PtrType.Components) full.PtrType
21802179 // positives. Therefore, start after a sentinel if there is one and
21812180 // skip over any align node and bit range nodes.
21822181 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,
21842183 else => info.main_token,
21852184 };
21862185 const end = tree.firstToken(info.child_type);
lib/std/zig/AstGen.zig+2-2
......@@ -3917,7 +3917,7 @@ fn ptrType(
39173917 node: Ast.Node.Index,
39183918 ptr_info: Ast.full.PtrType,
39193919) 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) {
39213921 return gz.astgen.failTok(ptr_info.allowzero_token.?, "C pointers always allow address zero", .{});
39223922 }
39233923
......@@ -3946,7 +3946,7 @@ fn ptrType(
39463946 .{ .rl = .{ .ty = elem_type } },
39473947 ptr_info.ast.sentinel,
39483948 switch (ptr_info.size) {
3949 .Slice => .slice_sentinel,
3949 .slice => .slice_sentinel,
39503950 else => .pointer_sentinel,
39513951 },
39523952 );
lib/std/zig/c_translation.zig+5-8
......@@ -170,7 +170,7 @@ pub fn sizeof(target: anytype) usize {
170170 }
171171 },
172172 .pointer => |ptr| {
173 if (ptr.size == .Slice) {
173 if (ptr.size == .slice) {
174174 @compileError("Cannot use C sizeof on slice type " ++ @typeName(T));
175175 }
176176 // for strings, sizeof("a") returns 2.
......@@ -178,12 +178,9 @@ pub fn sizeof(target: anytype) usize {
178178 // in the .array case above, but strings remain literals
179179 // and are therefore always pointers, so they need to be
180180 // 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) {
182182 const array_info = @typeInfo(ptr.child).array;
183 if ((array_info.child == u8 or array_info.child == u16) and
184 array_info.sentinel != null and
185 @as(*align(1) const array_info.child, @ptrCast(array_info.sentinel.?)).* == 0)
186 {
183 if ((array_info.child == u8 or array_info.child == u16) and array_info.sentinel() == 0) {
187184 // length of the string plus one for the null terminator.
188185 return (array_info.len + 1) * @sizeOf(array_info.child);
189186 }
......@@ -341,14 +338,14 @@ pub fn FlexibleArrayType(comptime SelfType: type, comptime ElementType: type) ty
341338 switch (@typeInfo(SelfType)) {
342339 .pointer => |ptr| {
343340 return @Type(.{ .pointer = .{
344 .size = .C,
341 .size = .c,
345342 .is_const = ptr.is_const,
346343 .is_volatile = ptr.is_volatile,
347344 .alignment = @alignOf(ElementType),
348345 .address_space = .generic,
349346 .child = ElementType,
350347 .is_allowzero = true,
351 .sentinel = null,
348 .sentinel_ptr = null,
352349 } });
353350 },
354351 else => |info| @compileError("Invalid self type \"" ++ @tagName(info) ++ "\" for flexible array getter: " ++ @typeName(SelfType)),
lib/std/zig/parser_test.zig+4-4
......@@ -552,7 +552,7 @@ test "zig fmt: trailing comma in fn parameter list" {
552552 \\pub fn f(
553553 \\ a: i32,
554554 \\ b: i32,
555 \\) callconv(.C) i32 {}
555 \\) callconv(.c) i32 {}
556556 \\pub fn f(
557557 \\ a: i32,
558558 \\ b: i32,
......@@ -560,15 +560,15 @@ test "zig fmt: trailing comma in fn parameter list" {
560560 \\pub fn f(
561561 \\ a: i32,
562562 \\ b: i32,
563 \\) align(8) callconv(.C) i32 {}
563 \\) align(8) callconv(.c) i32 {}
564564 \\pub fn f(
565565 \\ a: i32,
566566 \\ b: i32,
567 \\) align(8) linksection(".text") callconv(.C) i32 {}
567 \\) align(8) linksection(".text") callconv(.c) i32 {}
568568 \\pub fn f(
569569 \\ a: i32,
570570 \\ b: i32,
571 \\) linksection(".text") callconv(.C) i32 {}
571 \\) linksection(".text") callconv(.c) i32 {}
572572 \\
573573 );
574574}
lib/std/zig/render.zig+4-4
......@@ -938,7 +938,7 @@ fn renderArrayType(
938938fn renderPtrType(r: *Render, ptr_type: Ast.full.PtrType, space: Space) Error!void {
939939 const tree = r.tree;
940940 switch (ptr_type.size) {
941 .One => {
941 .one => {
942942 // Since ** tokens exist and the same token is shared by two
943943 // nested pointer types, we check to see if we are the parent
944944 // 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
951951 }
952952 try renderToken(r, ptr_type.ast.main_token, .none); // asterisk
953953 },
954 .Many => {
954 .many => {
955955 if (ptr_type.ast.sentinel == 0) {
956956 try renderToken(r, ptr_type.ast.main_token, .none); // lbracket
957957 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
964964 try renderToken(r, tree.lastToken(ptr_type.ast.sentinel) + 1, .none); // rbracket
965965 }
966966 },
967 .C => {
967 .c => {
968968 try renderToken(r, ptr_type.ast.main_token, .none); // lbracket
969969 try renderToken(r, ptr_type.ast.main_token + 1, .none); // asterisk
970970 try renderToken(r, ptr_type.ast.main_token + 2, .none); // c
971971 try renderToken(r, ptr_type.ast.main_token + 3, .none); // rbracket
972972 },
973 .Slice => {
973 .slice => {
974974 if (ptr_type.ast.sentinel == 0) {
975975 try renderToken(r, ptr_type.ast.main_token, .none); // lbracket
976976 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 {
475475
476476/// This is a workaround for the C backend until zig has the ability to put
477477/// 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
480480fn cpuid(leaf_id: u32, subid: u32) CpuidLeaf {
481481 // valid for both x86 and x86_64
......@@ -502,7 +502,7 @@ fn cpuid(leaf_id: u32, subid: u32) CpuidLeaf {
502502
503503/// This is a workaround for the C backend until zig has the ability to put
504504/// C code in inline assembly.
505extern fn zig_x86_get_xcr0() callconv(.C) u32;
505extern fn zig_x86_get_xcr0() callconv(.c) u32;
506506
507507// Read control register 0 (XCR0). Used to detect features such as AVX.
508508fn getXCR0() u32 {
src/InternPool.zig+34-34
......@@ -1134,7 +1134,7 @@ const Local = struct {
11341134 for (&new_fields, elem_fields) |*new_field, elem_field| new_field.* = .{
11351135 .name = elem_field.name,
11361136 .type = *[len]elem_field.type,
1137 .default_value = null,
1137 .default_value_ptr = null,
11381138 .is_comptime = false,
11391139 .alignment = 0,
11401140 };
......@@ -1162,9 +1162,9 @@ const Local = struct {
11621162 .address_space = .generic,
11631163 .child = elem_field.type,
11641164 .is_allowzero = false,
1165 .sentinel = null,
1165 .sentinel_ptr = null,
11661166 } }),
1167 .default_value = null,
1167 .default_value_ptr = null,
11681168 .is_comptime = false,
11691169 .alignment = 0,
11701170 };
......@@ -1176,17 +1176,17 @@ const Local = struct {
11761176 } });
11771177 }
11781178
1179 pub fn addOne(mutable: Mutable) Allocator.Error!PtrElem(.{ .size = .One }) {
1179 pub fn addOne(mutable: Mutable) Allocator.Error!PtrElem(.{ .size = .one }) {
11801180 try mutable.ensureUnusedCapacity(1);
11811181 return mutable.addOneAssumeCapacity();
11821182 }
11831183
1184 pub fn addOneAssumeCapacity(mutable: Mutable) PtrElem(.{ .size = .One }) {
1184 pub fn addOneAssumeCapacity(mutable: Mutable) PtrElem(.{ .size = .one }) {
11851185 const index = mutable.mutate.len;
11861186 assert(index < mutable.list.header().capacity);
11871187 mutable.mutate.len = index + 1;
11881188 const mutable_view = mutable.view().slice();
1189 var ptr: PtrElem(.{ .size = .One }) = undefined;
1189 var ptr: PtrElem(.{ .size = .one }) = undefined;
11901190 inline for (fields) |field| {
11911191 @field(ptr, @tagName(field)) = &mutable_view.items(field)[index];
11921192 }
......@@ -1206,7 +1206,7 @@ const Local = struct {
12061206
12071207 pub fn appendSliceAssumeCapacity(
12081208 mutable: Mutable,
1209 slice: PtrElem(.{ .size = .Slice, .is_const = true }),
1209 slice: PtrElem(.{ .size = .slice, .is_const = true }),
12101210 ) void {
12111211 if (fields.len == 0) return;
12121212 const start = mutable.mutate.len;
......@@ -1253,17 +1253,17 @@ const Local = struct {
12531253 return ptr_array;
12541254 }
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 }) {
12571257 try mutable.ensureUnusedCapacity(len);
12581258 return mutable.addManyAsSliceAssumeCapacity(len);
12591259 }
12601260
1261 pub fn addManyAsSliceAssumeCapacity(mutable: Mutable, len: usize) PtrElem(.{ .size = .Slice }) {
1261 pub fn addManyAsSliceAssumeCapacity(mutable: Mutable, len: usize) PtrElem(.{ .size = .slice }) {
12621262 const start = mutable.mutate.len;
12631263 assert(len <= mutable.list.header().capacity - start);
12641264 mutable.mutate.len = @intCast(start + len);
12651265 const mutable_view = mutable.view().slice();
1266 var slice: PtrElem(.{ .size = .Slice }) = undefined;
1266 var slice: PtrElem(.{ .size = .slice }) = undefined;
12671267 inline for (fields) |field| {
12681268 @field(slice, @tagName(field)) = mutable_view.items(field)[start..][0..len];
12691269 }
......@@ -2060,7 +2060,7 @@ pub const Key = union(enum) {
20602060 };
20612061
20622062 pub const Flags = packed struct(u32) {
2063 size: Size = .One,
2063 size: Size = .one,
20642064 /// `none` indicates the ABI alignment of the pointee_type. In this
20652065 /// case, this field *must* be set to `none`, otherwise the
20662066 /// `InternPool` equality and hashing functions will return incorrect
......@@ -4891,7 +4891,7 @@ pub const Index = enum(u32) {
48914891 checkField(name ++ ".?", info.child);
48924892 },
48934893 .pointer => |info| {
4894 assert(info.size == .Slice);
4894 assert(info.size == .slice);
48954895 checkConfig(name ++ ".len");
48964896 checkField(name ++ "[0]", info.child);
48974897 },
......@@ -5016,7 +5016,7 @@ pub const static_keys = [_]Key{
50165016 .{ .ptr_type = .{
50175017 .child = .u8_type,
50185018 .flags = .{
5019 .size = .Many,
5019 .size = .many,
50205020 },
50215021 } },
50225022
......@@ -5024,7 +5024,7 @@ pub const static_keys = [_]Key{
50245024 .{ .ptr_type = .{
50255025 .child = .u8_type,
50265026 .flags = .{
5027 .size = .Many,
5027 .size = .many,
50285028 .is_const = true,
50295029 },
50305030 } },
......@@ -5034,7 +5034,7 @@ pub const static_keys = [_]Key{
50345034 .child = .u8_type,
50355035 .sentinel = .zero_u8,
50365036 .flags = .{
5037 .size = .Many,
5037 .size = .many,
50385038 .is_const = true,
50395039 },
50405040 } },
......@@ -5043,7 +5043,7 @@ pub const static_keys = [_]Key{
50435043 .{ .ptr_type = .{
50445044 .child = .comptime_int_type,
50455045 .flags = .{
5046 .size = .One,
5046 .size = .one,
50475047 .is_const = true,
50485048 },
50495049 } },
......@@ -5052,7 +5052,7 @@ pub const static_keys = [_]Key{
50525052 .{ .ptr_type = .{
50535053 .child = .u8_type,
50545054 .flags = .{
5055 .size = .Slice,
5055 .size = .slice,
50565056 .is_const = true,
50575057 },
50585058 } },
......@@ -5062,7 +5062,7 @@ pub const static_keys = [_]Key{
50625062 .child = .u8_type,
50635063 .sentinel = .zero_u8,
50645064 .flags = .{
5065 .size = .Slice,
5065 .size = .slice,
50665066 .is_const = true,
50675067 },
50685068 } },
......@@ -6749,7 +6749,7 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key {
67496749 const many_ptr_item = many_ptr_unwrapped.getItem(ip);
67506750 assert(many_ptr_item.tag == .type_pointer);
67516751 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;
67536753 return .{ .ptr_type = ptr_info };
67546754 },
67556755
......@@ -7572,10 +7572,10 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All
75727572 assert(ptr_type.child != .none);
75737573 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) {
75767576 gop.cancel();
75777577 var new_key = key;
7578 new_key.ptr_type.flags.size = .Many;
7578 new_key.ptr_type.flags.size = .many;
75797579 const ptr_type_index = try ip.get(gpa, tid, new_key);
75807580 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
75887588 }
75897589
75907590 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
75937593 items.appendAssumeCapacity(.{
75947594 .tag = .type_pointer,
......@@ -7731,8 +7731,8 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All
77317731 },
77327732
77337733 .slice => |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);
7734 assert(ip.indexToKey(slice.ty).ptr_type.flags.size == .slice);
7735 assert(ip.indexToKey(ip.typeOf(slice.ptr)).ptr_type.flags.size == .many);
77367736 items.appendAssumeCapacity(.{
77377737 .tag = .ptr_slice,
77387738 .data = try addExtra(extra, PtrSlice{
......@@ -7745,7 +7745,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All
77457745
77467746 .ptr => |ptr| {
77477747 const ptr_type = ip.indexToKey(ptr.ty).ptr_type;
7748 assert(ptr_type.flags.size != .Slice);
7748 assert(ptr_type.flags.size != .slice);
77497749 items.appendAssumeCapacity(switch (ptr.base_addr) {
77507750 .nav => |nav| .{
77517751 .tag = .ptr_nav,
......@@ -7804,9 +7804,9 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All
78047804 .arr_elem, .field => |base_index| {
78057805 const base_ptr_type = ip.indexToKey(ip.typeOf(base_index.base)).ptr_type;
78067806 switch (ptr.base_addr) {
7807 .arr_elem => assert(base_ptr_type.flags.size == .Many),
7807 .arr_elem => assert(base_ptr_type.flags.size == .many),
78087808 .field => {
7809 assert(base_ptr_type.flags.size == .One);
7809 assert(base_ptr_type.flags.size == .one);
78107810 switch (ip.indexToKey(base_ptr_type.child)) {
78117811 .tuple_type => |tuple_type| {
78127812 assert(ptr.base_addr == .field);
......@@ -7823,7 +7823,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All
78237823 },
78247824 .ptr_type => |slice_type| {
78257825 assert(ptr.base_addr == .field);
7826 assert(slice_type.flags.size == .Slice);
7826 assert(slice_type.flags.size == .slice);
78277827 assert(base_index.index < 2);
78287828 },
78297829 else => unreachable,
......@@ -10314,12 +10314,12 @@ pub fn getCoerced(
1031410314 } });
1031510315
1031610316 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 = .{
1031810318 .ty = new_ty,
1031910319 .base_addr = .int,
1032010320 .byte_offset = 0,
1032110321 } }),
10322 .Slice => return ip.get(gpa, tid, .{ .slice = .{
10322 .slice => return ip.get(gpa, tid, .{ .slice = .{
1032310323 .ty = new_ty,
1032410324 .ptr = try ip.get(gpa, tid, .{ .ptr = .{
1032510325 .ty = ip.slicePtrType(new_ty),
......@@ -10408,7 +10408,7 @@ pub fn getCoerced(
1040810408 },
1040910409 else => {},
1041010410 },
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)
1041210412 return ip.get(gpa, tid, .{ .slice = .{
1041310413 .ty = new_ty,
1041410414 .ptr = try ip.getCoerced(gpa, tid, slice.ptr, ip.slicePtrType(new_ty)),
......@@ -10416,7 +10416,7 @@ pub fn getCoerced(
1041610416 } })
1041710417 else if (ip.isIntegerType(new_ty))
1041810418 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)
1042010420 return ip.get(gpa, tid, .{ .ptr = .{
1042110421 .ty = new_ty,
1042210422 .base_addr = ptr.base_addr,
......@@ -10433,12 +10433,12 @@ pub fn getCoerced(
1043310433 .opt => |opt| switch (ip.indexToKey(new_ty)) {
1043410434 .ptr_type => |ptr_type| return switch (opt.val) {
1043510435 .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 = .{
1043710437 .ty = new_ty,
1043810438 .base_addr = .int,
1043910439 .byte_offset = 0,
1044010440 } }),
10441 .Slice => try ip.get(gpa, tid, .{ .slice = .{
10441 .slice => try ip.get(gpa, tid, .{ .slice = .{
1044210442 .ty = new_ty,
1044310443 .ptr = try ip.get(gpa, tid, .{ .ptr = .{
1044410444 .ty = ip.slicePtrType(new_ty),
src/Sema.zig+196-207
......@@ -2479,7 +2479,7 @@ fn typeSupportsFieldAccess(zcu: *const Zcu, ty: Type, field_name: InternPool.Nul
24792479 .array => return field_name.eqlSlice("len", ip),
24802480 .pointer => {
24812481 const ptr_info = ty.ptrInfo(zcu);
2482 if (ptr_info.flags.size == .Slice) {
2482 if (ptr_info.flags.size == .slice) {
24832483 return field_name.eqlSlice("ptr", ip) or field_name.eqlSlice("len", ip);
24842484 } else if (Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .array) {
24852485 return field_name.eqlSlice("len", ip);
......@@ -2713,8 +2713,18 @@ fn analyzeValueAsCallconv(
27132713 src: LazySrcLoc,
27142714 unresolved_val: Value,
27152715) !std.builtin.CallingConvention {
2716 return interpretBuiltinType(sema, block, src, unresolved_val, std.builtin.CallingConvention);
2717}
2718
2719fn interpretBuiltinType(
2720 sema: *Sema,
2721 block: *Block,
2722 src: LazySrcLoc,
2723 unresolved_val: Value,
2724 comptime T: type,
2725) !T {
27162726 const resolved_val = try sema.resolveLazyValue(unresolved_val);
2717 return resolved_val.interpret(std.builtin.CallingConvention, sema.pt) catch |err| switch (err) {
2727 return resolved_val.interpret(T, sema.pt) catch |err| switch (err) {
27182728 error.OutOfMemory => |e| return e,
27192729 error.UndefinedValue => return sema.failWithUseOfUndef(block, src),
27202730 error.TypeMismatch => @panic("std.builtin is corrupt"),
......@@ -3653,7 +3663,7 @@ fn indexablePtrLenOrNone(
36533663 const zcu = pt.zcu;
36543664 const operand_ty = sema.typeOf(operand);
36553665 try checkMemOperand(sema, block, src, operand_ty);
3656 if (operand_ty.ptrSize(zcu) == .Many) return .none;
3666 if (operand_ty.ptrSize(zcu) == .many) return .none;
36573667 const field_name = try zcu.intern_pool.getOrPutString(sema.gpa, pt.tid, "len", .no_embedded_nulls);
36583668 return sema.fieldVal(block, src, operand, field_name, src);
36593669}
......@@ -4544,7 +4554,7 @@ fn zirCoercePtrElemTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE
45444554 assert(ptr_ty.zigTypeTag(zcu) == .pointer); // validated by a previous instruction
45454555 const elem_ty = ptr_ty.childType(zcu);
45464556 switch (ptr_ty.ptrSize(zcu)) {
4547 .One => {
4557 .one => {
45484558 const uncoerced_ty = sema.typeOf(uncoerced_val);
45494559 if (elem_ty.zigTypeTag(zcu) == .array and elem_ty.childType(zcu).toIntern() == uncoerced_ty.toIntern()) {
45504560 // We're trying to initialize a *[1]T with a reference to a T - don't perform any coercion.
......@@ -4557,7 +4567,7 @@ fn zirCoercePtrElemTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE
45574567 return sema.coerce(block, elem_ty, uncoerced_val, src);
45584568 }
45594569 },
4560 .Slice, .Many => {
4570 .slice, .many => {
45614571 // Our goal is to coerce `uncoerced_val` to an array of `elem_ty`.
45624572 const val_ty = sema.typeOf(uncoerced_val);
45634573 switch (val_ty.zigTypeTag(zcu)) {
......@@ -4573,7 +4583,7 @@ fn zirCoercePtrElemTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE
45734583 });
45744584 return sema.coerce(block, want_ty, uncoerced_val, src);
45754585 },
4576 .C => {
4586 .c => {
45774587 // There's nothing meaningful to do here, because we don't know if this is meant to be a
45784588 // single-pointer or a many-pointer.
45794589 return uncoerced_val;
......@@ -4685,7 +4695,7 @@ fn zirValidateArrayInitRefTy(
46854695 assert(ptr_ty.zigTypeTag(zcu) == .pointer); // validated by a previous instruction
46864696 switch (zcu.intern_pool.indexToKey(ptr_ty.toIntern())) {
46874697 .ptr_type => |ptr_type| switch (ptr_type.flags.size) {
4688 .Slice, .Many => {
4698 .slice, .many => {
46894699 // Use array of correct length
46904700 const arr_ty = try pt.arrayType(.{
46914701 .len = extra.elem_count,
......@@ -5502,9 +5512,9 @@ fn zirValidateDeref(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr
55025512 if (operand_ty.zigTypeTag(zcu) != .pointer) {
55035513 return sema.fail(block, src, "cannot dereference non-pointer type '{}'", .{operand_ty.fmt(pt)});
55045514 } else switch (operand_ty.ptrSize(zcu)) {
5505 .One, .C => {},
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)}),
5515 .one, .c => {},
5516 .many => return sema.fail(block, src, "index syntax required for unknown-length pointer type '{}'", .{operand_ty.fmt(pt)}),
5517 .slice => return sema.fail(block, src, "index syntax required for slice type '{}'", .{operand_ty.fmt(pt)}),
55085518 }
55095519
55105520 if ((try sema.typeHasOnePossibleValue(operand_ty.childType(zcu))) != null) {
......@@ -6521,7 +6531,7 @@ fn zirExport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void
65216531 return sema.fail(block, ptr_src, "expected pointer type, found '{}'", .{ptr_ty.fmt(pt)});
65226532 }
65236533 const ptr_ty_info = ptr_ty.ptrInfo(zcu);
6524 if (ptr_ty_info.flags.size == .Slice) {
6534 if (ptr_ty_info.flags.size == .slice) {
65256535 return sema.fail(block, ptr_src, "export target cannot be slice", .{});
65266536 }
65276537 if (ptr_ty_info.packed_offset.host_size != 0) {
......@@ -7271,7 +7281,7 @@ fn checkCallArgumentCount(
72717281 .@"fn" => break :func_ty callee_ty,
72727282 .pointer => {
72737283 const ptr_info = callee_ty.ptrInfo(zcu);
7274 if (ptr_info.flags.size == .One and Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .@"fn") {
7284 if (ptr_info.flags.size == .one and Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .@"fn") {
72757285 break :func_ty Type.fromInterned(ptr_info.child);
72767286 }
72777287 },
......@@ -7350,7 +7360,7 @@ fn callBuiltin(
73507360 .@"fn" => break :func_ty callee_ty,
73517361 .pointer => {
73527362 const ptr_info = callee_ty.ptrInfo(zcu);
7353 if (ptr_info.flags.size == .One and Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .@"fn") {
7363 if (ptr_info.flags.size == .one and Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .@"fn") {
73547364 break :func_ty Type.fromInterned(ptr_info.child);
73557365 }
73567366 },
......@@ -8344,8 +8354,8 @@ fn zirIndexablePtrElemType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com
83448354 };
83458355 try sema.checkMemOperand(block, src, ptr_ty);
83468356 const elem_ty = switch (ptr_ty.ptrSize(zcu)) {
8347 .Slice, .Many, .C => ptr_ty.childType(zcu),
8348 .One => ptr_ty.childType(zcu).childType(zcu),
8357 .slice, .many, .c => ptr_ty.childType(zcu),
8358 .one => ptr_ty.childType(zcu).childType(zcu),
83498359 };
83508360 return Air.internedToRef(elem_ty.toIntern());
83518361}
......@@ -8943,7 +8953,7 @@ fn zirOptionalPayload(
89438953 const result_ty = switch (operand_ty.zigTypeTag(zcu)) {
89448954 .optional => operand_ty.optionalChild(zcu),
89458955 .pointer => t: {
8946 if (operand_ty.ptrSize(zcu) != .C) {
8956 if (operand_ty.ptrSize(zcu) != .c) {
89478957 return sema.failWithExpectedOptionalType(block, src, operand_ty);
89488958 }
89498959 // TODO https://github.com/ziglang/zig/issues/6597
......@@ -13972,7 +13982,7 @@ fn zirHasField(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1397213982 const has_field = hf: {
1397313983 switch (ip.indexToKey(ty.toIntern())) {
1397413984 .ptr_type => |ptr_type| switch (ptr_type.flags.size) {
13975 .Slice => {
13985 .slice => {
1397613986 if (field_name.eqlSlice("ptr", ip)) break :hf true;
1397713987 if (field_name.eqlSlice("len", ip)) break :hf true;
1397813988 break :hf false;
......@@ -14797,7 +14807,7 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1479714807 const slice_ty = try pt.ptrTypeSema(.{
1479814808 .child = resolved_elem_ty.toIntern(),
1479914809 .flags = .{
14800 .size = .Slice,
14810 .size = .slice,
1480114811 .address_space = ptr_as,
1480214812 },
1480314813 });
......@@ -14925,7 +14935,7 @@ fn getArrayCatInfo(sema: *Sema, block: *Block, src: LazySrcLoc, operand: Air.Ins
1492514935 .pointer => {
1492614936 const ptr_info = operand_ty.ptrInfo(zcu);
1492714937 switch (ptr_info.flags.size) {
14928 .Slice => {
14938 .slice => {
1492914939 const val = try sema.resolveConstDefinedValue(block, src, operand, .{ .simple = .slice_cat_operand });
1493014940 return Type.ArrayInfo{
1493114941 .elem_type = Type.fromInterned(ptr_info.child),
......@@ -14936,12 +14946,12 @@ fn getArrayCatInfo(sema: *Sema, block: *Block, src: LazySrcLoc, operand: Air.Ins
1493614946 .len = try val.sliceLen(pt),
1493714947 };
1493814948 },
14939 .One => {
14949 .one => {
1494014950 if (Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .array) {
1494114951 return Type.fromInterned(ptr_info.child).arrayInfo(zcu);
1494214952 }
1494314953 },
14944 .C, .Many => {},
14954 .c, .many => {},
1494514955 }
1494614956 },
1494714957 .@"struct" => {
......@@ -16610,7 +16620,7 @@ fn analyzeArithmetic(
1661016620
1661116621 if (lhs_zig_ty_tag == .pointer) {
1661216622 if (rhs_zig_ty_tag == .pointer) {
16613 if (lhs_ty.ptrSize(zcu) != .Slice and rhs_ty.ptrSize(zcu) != .Slice) {
16623 if (lhs_ty.ptrSize(zcu) != .slice and rhs_ty.ptrSize(zcu) != .slice) {
1661416624 if (zir_tag != .sub) {
1661516625 return sema.failWithInvalidPtrArithmetic(block, src, "pointer-pointer", "subtraction");
1661616626 }
......@@ -16662,8 +16672,8 @@ fn analyzeArithmetic(
1666216672 }
1666316673 } else {
1666416674 switch (lhs_ty.ptrSize(zcu)) {
16665 .One, .Slice => {},
16666 .Many, .C => {
16675 .one, .slice => {},
16676 .many, .c => {
1666716677 const air_tag: Air.Inst.Tag = switch (zir_tag) {
1666816678 .add => .ptr_add,
1666916679 .sub => .ptr_sub,
......@@ -17160,7 +17170,7 @@ fn analyzePtrArithmetic(
1716017170 const opt_off_val = try sema.resolveDefinedValue(block, offset_src, offset);
1716117171 const ptr_ty = sema.typeOf(ptr);
1716217172 const ptr_info = ptr_ty.ptrInfo(zcu);
17163 assert(ptr_info.flags.size == .Many or ptr_info.flags.size == .C);
17173 assert(ptr_info.flags.size == .many or ptr_info.flags.size == .c);
1716417174
1716517175 const new_ptr_ty = t: {
1716617176 // Calculate the new pointer alignment.
......@@ -18092,7 +18102,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1809218102 const slice_ty = (try pt.ptrTypeSema(.{
1809318103 .child = param_info_ty.toIntern(),
1809418104 .flags = .{
18095 .size = .Slice,
18105 .size = .slice,
1809618106 .is_const = true,
1809718107 },
1809818108 })).toIntern();
......@@ -18335,7 +18345,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1833518345 const slice_errors_ty = try pt.ptrTypeSema(.{
1833618346 .child = error_field_ty.toIntern(),
1833718347 .flags = .{
18338 .size = .Slice,
18348 .size = .slice,
1833918349 .is_const = true,
1834018350 },
1834118351 });
......@@ -18462,7 +18472,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1846218472 const slice_ty = (try pt.ptrTypeSema(.{
1846318473 .child = enum_field_ty.toIntern(),
1846418474 .flags = .{
18465 .size = .Slice,
18475 .size = .slice,
1846618476 .is_const = true,
1846718477 },
1846818478 })).toIntern();
......@@ -18575,7 +18585,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1857518585 const slice_ty = (try pt.ptrTypeSema(.{
1857618586 .child = union_field_ty.toIntern(),
1857718587 .flags = .{
18578 .size = .Slice,
18588 .size = .slice,
1857918589 .is_const = true,
1858018590 },
1858118591 })).toIntern();
......@@ -18770,7 +18780,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1877018780 const slice_ty = (try pt.ptrTypeSema(.{
1877118781 .child = struct_field_ty.toIntern(),
1877218782 .flags = .{
18773 .size = .Slice,
18783 .size = .slice,
1877418784 .is_const = true,
1877518785 },
1877618786 })).toIntern();
......@@ -18879,7 +18889,7 @@ fn typeInfoDecls(
1887918889 const slice_ty = (try pt.ptrTypeSema(.{
1888018890 .child = declaration_ty.toIntern(),
1888118891 .flags = .{
18882 .size = .Slice,
18892 .size = .slice,
1888318893 .is_const = true,
1888418894 },
1888518895 })).toIntern();
......@@ -20138,12 +20148,12 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
2013820148 }
2013920149
2014020150 if (elem_ty.zigTypeTag(zcu) == .@"fn") {
20141 if (inst_data.size != .One) {
20151 if (inst_data.size != .one) {
2014220152 return sema.fail(block, elem_ty_src, "function pointers must be single pointers", .{});
2014320153 }
20144 } else if (inst_data.size == .Many and elem_ty.zigTypeTag(zcu) == .@"opaque") {
20154 } else if (inst_data.size == .many and elem_ty.zigTypeTag(zcu) == .@"opaque") {
2014520155 return sema.fail(block, elem_ty_src, "unknown-length pointer to opaque not allowed", .{});
20146 } else if (inst_data.size == .C) {
20156 } else if (inst_data.size == .c) {
2014720157 if (!try sema.validateExternType(elem_ty, .other)) {
2014820158 const msg = msg: {
2014920159 const msg = try sema.errMsg(elem_ty_src, "C pointers cannot point to non-C-ABI-compatible type '{}'", .{elem_ty.fmt(pt)});
......@@ -21536,19 +21546,8 @@ fn zirReify(
2153621546 .@"anyframe" => return sema.failWithUseOfAsync(block, src),
2153721547 .enum_literal => return .enum_literal_type,
2153821548 .int => {
21539 const struct_type = ip.loadStructType(ip.typeOf(union_val.val));
21540 const signedness_val = try Value.fromInterned(union_val.val).fieldValue(
21541 pt,
21542 struct_type.nameIndex(ip, try ip.getOrPutString(gpa, pt.tid, "signedness", .no_embedded_nulls)).?,
21543 );
21544 const bits_val = try Value.fromInterned(union_val.val).fieldValue(
21545 pt,
21546 struct_type.nameIndex(ip, try ip.getOrPutString(gpa, pt.tid, "bits", .no_embedded_nulls)).?,
21547 );
21548
21549 const signedness = zcu.toEnum(std.builtin.Signedness, signedness_val);
21550 const bits: u16 = @intCast(try bits_val.toUnsignedIntSema(pt));
21551 const ty = try pt.intType(signedness, bits);
21549 const int = try sema.interpretBuiltinType(block, operand_src, .fromInterned(union_val.val), std.builtin.Type.Int);
21550 const ty = try pt.intType(int.signedness, int.bits);
2155221551 return Air.internedToRef(ty.toIntern());
2155321552 },
2155421553 .vector => {
......@@ -21574,20 +21573,15 @@ fn zirReify(
2157421573 return Air.internedToRef(ty.toIntern());
2157521574 },
2157621575 .float => {
21577 const struct_type = ip.loadStructType(ip.typeOf(union_val.val));
21578 const bits_val = try Value.fromInterned(union_val.val).fieldValue(pt, struct_type.nameIndex(
21579 ip,
21580 try ip.getOrPutString(gpa, pt.tid, "bits", .no_embedded_nulls),
21581 ).?);
21576 const float = try sema.interpretBuiltinType(block, operand_src, .fromInterned(union_val.val), std.builtin.Type.Float);
2158221577
21583 const bits: u16 = @intCast(try bits_val.toUnsignedIntSema(pt));
21584 const ty = switch (bits) {
21578 const ty = switch (float.bits) {
2158521579 16 => Type.f16,
2158621580 32 => Type.f32,
2158721581 64 => Type.f64,
2158821582 80 => Type.f80,
2158921583 128 => Type.f128,
21590 else => return sema.fail(block, src, "{}-bit float unsupported", .{bits}),
21584 else => return sema.fail(block, src, "{}-bit float unsupported", .{float.bits}),
2159121585 };
2159221586 return Air.internedToRef(ty.toIntern());
2159321587 },
......@@ -21623,7 +21617,7 @@ fn zirReify(
2162321617 ).?);
2162421618 const sentinel_val = try Value.fromInterned(union_val.val).fieldValue(pt, struct_type.nameIndex(
2162521619 ip,
21626 try ip.getOrPutString(gpa, pt.tid, "sentinel", .no_embedded_nulls),
21620 try ip.getOrPutString(gpa, pt.tid, "sentinel_ptr", .no_embedded_nulls),
2162721621 ).?);
2162821622
2162921623 if (!try sema.intFitsInType(alignment_val, Type.u32, null)) {
......@@ -21641,11 +21635,11 @@ fn zirReify(
2164121635 try elem_ty.resolveLayout(pt);
2164221636 }
2164321637
21644 const ptr_size = zcu.toEnum(std.builtin.Type.Pointer.Size, size_val);
21638 const ptr_size = try sema.interpretBuiltinType(block, operand_src, size_val, std.builtin.Type.Pointer.Size);
2164521639
2164621640 const actual_sentinel: InternPool.Index = s: {
2164721641 if (!sentinel_val.isNull(zcu)) {
21648 if (ptr_size == .One or ptr_size == .C) {
21642 if (ptr_size == .one or ptr_size == .c) {
2164921643 return sema.fail(block, src, "sentinels are only allowed on slices and unknown-length pointers", .{});
2165021644 }
2165121645 const sentinel_ptr_val = sentinel_val.optionalValue(zcu).?;
......@@ -21660,12 +21654,12 @@ fn zirReify(
2166021654 if (elem_ty.zigTypeTag(zcu) == .noreturn) {
2166121655 return sema.fail(block, src, "pointer to noreturn not allowed", .{});
2166221656 } else if (elem_ty.zigTypeTag(zcu) == .@"fn") {
21663 if (ptr_size != .One) {
21657 if (ptr_size != .one) {
2166421658 return sema.fail(block, src, "function pointers must be single pointers", .{});
2166521659 }
21666 } else if (ptr_size == .Many and elem_ty.zigTypeTag(zcu) == .@"opaque") {
21660 } else if (ptr_size == .many and elem_ty.zigTypeTag(zcu) == .@"opaque") {
2166721661 return sema.fail(block, src, "unknown-length pointer to opaque not allowed", .{});
21668 } else if (ptr_size == .C) {
21662 } else if (ptr_size == .c) {
2166921663 if (!try sema.validateExternType(elem_ty, .other)) {
2167021664 const msg = msg: {
2167121665 const msg = try sema.errMsg(src, "C pointers cannot point to non-C-ABI-compatible type '{}'", .{elem_ty.fmt(pt)});
......@@ -21691,7 +21685,7 @@ fn zirReify(
2169121685 .is_const = is_const_val.toBool(),
2169221686 .is_volatile = is_volatile_val.toBool(),
2169321687 .alignment = abi_align,
21694 .address_space = zcu.toEnum(std.builtin.AddressSpace, address_space_val),
21688 .address_space = try sema.interpretBuiltinType(block, operand_src, address_space_val, std.builtin.AddressSpace),
2169521689 .is_allowzero = is_allowzero_val.toBool(),
2169621690 },
2169721691 });
......@@ -21709,7 +21703,7 @@ fn zirReify(
2170921703 ).?);
2171021704 const sentinel_val = try Value.fromInterned(union_val.val).fieldValue(pt, struct_type.nameIndex(
2171121705 ip,
21712 try ip.getOrPutString(gpa, pt.tid, "sentinel", .no_embedded_nulls),
21706 try ip.getOrPutString(gpa, pt.tid, "sentinel_ptr", .no_embedded_nulls),
2171321707 ).?);
2171421708
2171521709 const len = try len_val.toUnsignedIntSema(pt);
......@@ -21813,7 +21807,7 @@ fn zirReify(
2181321807 try ip.getOrPutString(gpa, pt.tid, "is_tuple", .no_embedded_nulls),
2181421808 ).?);
2181521809
21816 const layout = zcu.toEnum(std.builtin.Type.ContainerLayout, layout_val);
21810 const layout = try sema.interpretBuiltinType(block, operand_src, layout_val, std.builtin.Type.ContainerLayout);
2181721811
2181821812 // Decls
2181921813 if (try decls_val.sliceLen(pt) > 0) {
......@@ -21929,7 +21923,7 @@ fn zirReify(
2192921923 if (try decls_val.sliceLen(pt) > 0) {
2193021924 return sema.fail(block, src, "reified unions must have no decls", .{});
2193121925 }
21932 const layout = zcu.toEnum(std.builtin.Type.ContainerLayout, layout_val);
21926 const layout = try sema.interpretBuiltinType(block, operand_src, layout_val, std.builtin.Type.ContainerLayout);
2193321927
2193421928 const fields_arr = try sema.derefSliceAsArray(block, operand_src, fields_val, .{ .simple = .union_fields });
2193521929
......@@ -23321,21 +23315,21 @@ fn ptrCastFull(
2332123315 try Type.fromInterned(src_info.child).resolveLayout(pt);
2332223316 try Type.fromInterned(dest_info.child).resolveLayout(pt);
2332323317
23324 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);
23318 const src_slice_like = src_info.flags.size == .slice or
23319 (src_info.flags.size == .one and Type.fromInterned(src_info.child).zigTypeTag(zcu) == .array);
2332623320
23327 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);
23321 const dest_slice_like = dest_info.flags.size == .slice or
23322 (dest_info.flags.size == .one and Type.fromInterned(dest_info.child).zigTypeTag(zcu) == .array);
2332923323
23330 if (dest_info.flags.size == .Slice and !src_slice_like) {
23324 if (dest_info.flags.size == .slice and !src_slice_like) {
2333123325 return sema.fail(block, src, "illegal pointer cast to slice", .{});
2333223326 }
2333323327
23334 if (dest_info.flags.size == .Slice) {
23328 if (dest_info.flags.size == .slice) {
2333523329 const src_elem_size = switch (src_info.flags.size) {
23336 .Slice => Type.fromInterned(src_info.child).abiSize(zcu),
23330 .slice => Type.fromInterned(src_info.child).abiSize(zcu),
2333723331 // pointer to array
23338 .One => Type.fromInterned(src_info.child).childType(zcu).abiSize(zcu),
23332 .one => Type.fromInterned(src_info.child).childType(zcu).abiSize(zcu),
2333923333 else => unreachable,
2334023334 };
2334123335 const dest_elem_size = Type.fromInterned(dest_info.child).abiSize(zcu);
......@@ -23350,17 +23344,17 @@ fn ptrCastFull(
2335023344 check_size: {
2335123345 if (src_info.flags.size == dest_info.flags.size) break :check_size;
2335223346 if (src_slice_like and dest_slice_like) break :check_size;
23353 if (src_info.flags.size == .C) break :check_size;
23354 if (dest_info.flags.size == .C) break :check_size;
23347 if (src_info.flags.size == .c) break :check_size;
23348 if (dest_info.flags.size == .c) break :check_size;
2335523349 return sema.failWithOwnedErrorMsg(block, msg: {
2335623350 const msg = try sema.errMsg(src, "cannot implicitly convert {s} to {s}", .{
2335723351 pointerSizeString(src_info.flags.size),
2335823352 pointerSizeString(dest_info.flags.size),
2335923353 });
2336023354 errdefer msg.destroy(sema.gpa);
23361 if (dest_info.flags.size == .Many and
23362 (src_info.flags.size == .Slice or
23363 (src_info.flags.size == .One and Type.fromInterned(src_info.child).zigTypeTag(zcu) == .array)))
23355 if (dest_info.flags.size == .many and
23356 (src_info.flags.size == .slice or
23357 (src_info.flags.size == .one and Type.fromInterned(src_info.child).zigTypeTag(zcu) == .array)))
2336423358 {
2336523359 try sema.errNote(src, msg, "use 'ptr' field to convert slice to many pointer", .{});
2336623360 } else {
......@@ -23371,7 +23365,7 @@ fn ptrCastFull(
2337123365 }
2337223366
2337323367 check_child: {
23374 const src_child = if (dest_info.flags.size == .Slice and src_info.flags.size == .One) blk: {
23368 const src_child = if (dest_info.flags.size == .slice and src_info.flags.size == .one) blk: {
2337523369 // *[n]T -> []T
2337623370 break :blk Type.fromInterned(src_info.child).childType(zcu);
2337723371 } else Type.fromInterned(src_info.child);
......@@ -23402,12 +23396,12 @@ fn ptrCastFull(
2340223396
2340323397 check_sent: {
2340423398 if (dest_info.sentinel == .none) break :check_sent;
23405 if (src_info.flags.size == .C) break :check_sent;
23399 if (src_info.flags.size == .c) break :check_sent;
2340623400 if (src_info.sentinel != .none) {
2340723401 const coerced_sent = try zcu.intern_pool.getCoerced(sema.gpa, pt.tid, src_info.sentinel, dest_info.child);
2340823402 if (dest_info.sentinel == coerced_sent) break :check_sent;
2340923403 }
23410 if (src_slice_like and src_info.flags.size == .One and dest_info.flags.size == .Slice) {
23404 if (src_slice_like and src_info.flags.size == .one and dest_info.flags.size == .slice) {
2341123405 // [*]nT -> []T
2341223406 const arr_ty = Type.fromInterned(src_info.child);
2341323407 if (arr_ty.sentinel(zcu)) |src_sentinel| {
......@@ -23555,7 +23549,7 @@ fn ptrCastFull(
2355523549 }
2355623550 }
2355723551
23558 const ptr = if (src_info.flags.size == .Slice and dest_info.flags.size != .Slice) ptr: {
23552 const ptr = if (src_info.flags.size == .slice and dest_info.flags.size != .slice) ptr: {
2355923553 if (operand_ty.zigTypeTag(zcu) == .optional) {
2356023554 break :ptr try sema.analyzeOptionalSlicePtr(block, operand_src, operand, operand_ty);
2356123555 } else {
......@@ -23563,10 +23557,10 @@ fn ptrCastFull(
2356323557 }
2356423558 } else operand;
2356523559
23566 const dest_ptr_ty = if (dest_info.flags.size == .Slice and src_info.flags.size != .Slice) blk: {
23560 const dest_ptr_ty = if (dest_info.flags.size == .slice and src_info.flags.size != .slice) blk: {
2356723561 // Only convert to a many-pointer at first
2356823562 var info = dest_info;
23569 info.flags.size = .Many;
23563 info.flags.size = .many;
2357023564 const ty = try pt.ptrTypeSema(info);
2357123565 if (dest_ty.zigTypeTag(zcu) == .optional) {
2357223566 break :blk try pt.optionalType(ty.toIntern());
......@@ -23594,7 +23588,7 @@ fn ptrCastFull(
2359423588 }
2359523589 }
2359623590 }
23597 if (dest_info.flags.size == .Slice and src_info.flags.size != .Slice) {
23591 if (dest_info.flags.size == .slice and src_info.flags.size != .slice) {
2359823592 if (ptr_val.isUndef(zcu)) return pt.undefRef(dest_ty);
2359923593 const arr_len = try pt.intValue(Type.usize, Type.fromInterned(src_info.child).arrayLen(zcu));
2360023594 const ptr_val_key = zcu.intern_pool.indexToKey(ptr_val.toIntern()).ptr;
......@@ -23622,7 +23616,7 @@ fn ptrCastFull(
2362223616 {
2362323617 const ptr_int = try block.addUnOp(.int_from_ptr, ptr);
2362423618 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: {
23619 const ok = if (src_info.flags.size == .slice and dest_info.flags.size == .slice) ok: {
2362623620 const len = try sema.analyzeSliceLen(block, operand_src, ptr);
2362723621 const len_zero = try block.addBinOp(.cmp_eq, len, .zero_usize);
2362823622 break :ok try block.addBinOp(.bool_or, len_zero, is_non_zero);
......@@ -23639,7 +23633,7 @@ fn ptrCastFull(
2363923633 const ptr_int = try block.addUnOp(.int_from_ptr, ptr);
2364023634 const remainder = try block.addBinOp(.bit_and, ptr_int, align_minus_1);
2364123635 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: {
23636 const ok = if (src_info.flags.size == .slice and dest_info.flags.size == .slice) ok: {
2364323637 const len = try sema.analyzeSliceLen(block, operand_src, ptr);
2364423638 const len_zero = try block.addBinOp(.cmp_eq, len, .zero_usize);
2364523639 break :ok try block.addBinOp(.bool_or, len_zero, is_aligned);
......@@ -23672,7 +23666,7 @@ fn ptrCastFull(
2367223666 break :ptr try block.addBitCast(dest_ptr_ty, ptr);
2367323667 };
2367423668
23675 if (dest_info.flags.size == .Slice and src_info.flags.size != .Slice) {
23669 if (dest_info.flags.size == .slice and src_info.flags.size != .slice) {
2367623670 // We have to construct a slice using the operand's child's array length
2367723671 // Note that we know from the check at the start of the function that operand_ty is slice-like
2367823672 const arr_len = Air.internedToRef((try pt.intValue(Type.usize, Type.fromInterned(src_info.child).arrayLen(zcu))).toIntern());
......@@ -24066,8 +24060,8 @@ fn checkInvalidPtrIntArithmetic(
2406624060 const zcu = pt.zcu;
2406724061 switch (try ty.zigTypeTagOrPoison(zcu)) {
2406824062 .pointer => switch (ty.ptrSize(zcu)) {
24069 .One, .Slice => return,
24070 .Many, .C => return sema.failWithInvalidPtrArithmetic(block, src, "pointer-integer", "addition and subtraction"),
24063 .one, .slice => return,
24064 .many, .c => return sema.failWithInvalidPtrArithmetic(block, src, "pointer-integer", "addition and subtraction"),
2407124065 },
2407224066 else => return,
2407324067 }
......@@ -24456,7 +24450,7 @@ fn resolveExportOptions(
2445624450
2445724451 const linkage_operand = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, pt.tid, "linkage", .no_embedded_nulls), linkage_src);
2445824452 const linkage_val = try sema.resolveConstDefinedValue(block, linkage_src, linkage_operand, .{ .simple = .export_options });
24459 const linkage = zcu.toEnum(std.builtin.GlobalLinkage, linkage_val);
24453 const linkage = try sema.interpretBuiltinType(block, linkage_src, linkage_val, std.builtin.GlobalLinkage);
2446024454
2446124455 const section_operand = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, pt.tid, "section", .no_embedded_nulls), section_src);
2446224456 const section_opt_val = try sema.resolveConstDefinedValue(block, section_src, section_operand, .{ .simple = .export_options });
......@@ -24467,7 +24461,7 @@ fn resolveExportOptions(
2446724461
2446824462 const visibility_operand = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, pt.tid, "visibility", .no_embedded_nulls), visibility_src);
2446924463 const visibility_val = try sema.resolveConstDefinedValue(block, visibility_src, visibility_operand, .{ .simple = .export_options });
24470 const visibility = zcu.toEnum(std.builtin.SymbolVisibility, visibility_val);
24464 const visibility = try sema.interpretBuiltinType(block, visibility_src, visibility_val, std.builtin.SymbolVisibility);
2447124465
2447224466 if (name.len < 1) {
2447324467 return sema.fail(block, name_src, "exported symbol name cannot be empty", .{});
......@@ -24495,12 +24489,11 @@ fn resolveBuiltinEnum(
2449524489 comptime name: Zcu.BuiltinDecl,
2449624490 reason: ComptimeReason,
2449724491) CompileError!@field(std.builtin, @tagName(name)) {
24498 const pt = sema.pt;
2449924492 const ty = try sema.getBuiltinType(src, name);
2450024493 const air_ref = try sema.resolveInst(zir_ref);
2450124494 const coerced = try sema.coerce(block, ty, air_ref, src);
2450224495 const val = try sema.resolveConstDefinedValue(block, src, coerced, reason);
24503 return pt.zcu.toEnum(@field(std.builtin, @tagName(name)), val);
24496 return sema.interpretBuiltinType(block, src, val, @field(std.builtin, @tagName(name)));
2450424497}
2450524498
2450624499fn resolveAtomicOrder(
......@@ -25293,7 +25286,7 @@ fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
2529325286 const air_ref = try sema.resolveInst(extra.modifier);
2529425287 const modifier_ref = try sema.coerce(block, modifier_ty, air_ref, modifier_src);
2529525288 const modifier_val = try sema.resolveConstDefinedValue(block, modifier_src, modifier_ref, .{ .simple = .call_modifier });
25296 var modifier = zcu.toEnum(std.builtin.CallModifier, modifier_val);
25289 var modifier = try sema.interpretBuiltinType(block, modifier_src, modifier_val, std.builtin.CallModifier);
2529725290 switch (modifier) {
2529825291 // These can be upgraded to comptime or nosuspend calls.
2529925292 .auto, .never_tail, .no_async => {
......@@ -25384,7 +25377,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins
2538425377 const parent_ptr_ty = try sema.resolveDestType(block, inst_src, extra.parent_ptr_type, .remove_eu, "@fieldParentPtr");
2538525378 try sema.checkPtrType(block, inst_src, parent_ptr_ty, true);
2538625379 const parent_ptr_info = parent_ptr_ty.ptrInfo(zcu);
25387 if (parent_ptr_info.flags.size != .One) {
25380 if (parent_ptr_info.flags.size != .one) {
2538825381 return sema.fail(block, inst_src, "expected single pointer type, found '{}'", .{parent_ptr_ty.fmt(pt)});
2538925382 }
2539025383 const parent_ty = Type.fromInterned(parent_ptr_info.child);
......@@ -25862,7 +25855,7 @@ fn upgradeToArrayPtr(sema: *Sema, block: *Block, ptr: Air.Inst.Ref, len: u64) !A
2586225855 const zcu = pt.zcu;
2586325856 const ptr_ty = sema.typeOf(ptr);
2586425857 const info = ptr_ty.ptrInfo(zcu);
25865 if (info.flags.size == .One) {
25858 if (info.flags.size == .one) {
2586625859 // Already an array pointer.
2586725860 return ptr;
2586825861 }
......@@ -25880,7 +25873,7 @@ fn upgradeToArrayPtr(sema: *Sema, block: *Block, ptr: Air.Inst.Ref, len: u64) !A
2588025873 .address_space = info.flags.address_space,
2588125874 },
2588225875 });
25883 const non_slice_ptr = if (info.flags.size == .Slice)
25876 const non_slice_ptr = if (info.flags.size == .slice)
2588425877 try block.addTyOp(.slice_ptr, ptr_ty.slicePtrFieldType(zcu), ptr)
2588525878 else
2588625879 ptr;
......@@ -26069,22 +26062,22 @@ fn zirMemcpy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void
2606926062 const new_dest_ptr_ty = sema.typeOf(new_dest_ptr);
2607026063 const raw_dest_ptr = if (new_dest_ptr_ty.isSlice(zcu))
2607126064 try sema.analyzeSlicePtr(block, dest_src, new_dest_ptr, new_dest_ptr_ty)
26072 else if (new_dest_ptr_ty.ptrSize(zcu) == .One) ptr: {
26065 else if (new_dest_ptr_ty.ptrSize(zcu) == .one) ptr: {
2607326066 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);
26067 assert(dest_manyptr_ty_key.flags.size == .one);
2607526068 dest_manyptr_ty_key.child = dest_elem_ty.toIntern();
26076 dest_manyptr_ty_key.flags.size = .Many;
26069 dest_manyptr_ty_key.flags.size = .many;
2607726070 break :ptr try sema.coerceCompatiblePtrs(block, try pt.ptrTypeSema(dest_manyptr_ty_key), new_dest_ptr, dest_src);
2607826071 } else new_dest_ptr;
2607926072
2608026073 const new_src_ptr_ty = sema.typeOf(new_src_ptr);
2608126074 const raw_src_ptr = if (new_src_ptr_ty.isSlice(zcu))
2608226075 try sema.analyzeSlicePtr(block, src_src, new_src_ptr, new_src_ptr_ty)
26083 else if (new_src_ptr_ty.ptrSize(zcu) == .One) ptr: {
26076 else if (new_src_ptr_ty.ptrSize(zcu) == .one) ptr: {
2608426077 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);
26078 assert(src_manyptr_ty_key.flags.size == .one);
2608626079 src_manyptr_ty_key.child = src_elem_ty.toIntern();
26087 src_manyptr_ty_key.flags.size = .Many;
26080 src_manyptr_ty_key.flags.size = .many;
2608826081 break :ptr try sema.coerceCompatiblePtrs(block, try pt.ptrTypeSema(src_manyptr_ty_key), new_src_ptr, src_src);
2608926082 } else new_src_ptr;
2609026083
......@@ -26129,13 +26122,13 @@ fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void
2612926122 const dest_elem_ty: Type = dest_elem_ty: {
2613026123 const ptr_info = dest_ptr_ty.ptrInfo(zcu);
2613126124 switch (ptr_info.flags.size) {
26132 .Slice => break :dest_elem_ty Type.fromInterned(ptr_info.child),
26133 .One => {
26125 .slice => break :dest_elem_ty Type.fromInterned(ptr_info.child),
26126 .one => {
2613426127 if (Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .array) {
2613526128 break :dest_elem_ty Type.fromInterned(ptr_info.child).childType(zcu);
2613626129 }
2613726130 },
26138 .Many, .C => {},
26131 .many, .c => {},
2613926132 }
2614026133 return sema.failWithOwnedErrorMsg(block, msg: {
2614126134 const msg = try sema.errMsg(src, "unknown @memset length", .{});
......@@ -26172,7 +26165,7 @@ fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void
2617226165 } }));
2617326166 const array_ptr_ty = ty: {
2617426167 var info = dest_ptr_ty.ptrInfo(zcu);
26175 info.flags.size = .One;
26168 info.flags.size = .one;
2617626169 info.child = array_ty.toIntern();
2617726170 break :ty try pt.ptrType(info);
2617826171 };
......@@ -26468,9 +26461,9 @@ fn resolvePrefetchOptions(
2646826461 const cache_val = try sema.resolveConstDefinedValue(block, cache_src, cache, .{ .simple = .prefetch_options });
2646926462
2647026463 return std.builtin.PrefetchOptions{
26471 .rw = zcu.toEnum(std.builtin.PrefetchOptions.Rw, rw_val),
26464 .rw = try sema.interpretBuiltinType(block, rw_src, rw_val, std.builtin.PrefetchOptions.Rw),
2647226465 .locality = @intCast(try locality_val.toUnsignedIntSema(pt)),
26473 .cache = zcu.toEnum(std.builtin.PrefetchOptions.Cache, cache_val),
26466 .cache = try sema.interpretBuiltinType(block, cache_src, cache_val, std.builtin.PrefetchOptions.Cache),
2647426467 };
2647526468}
2647626469
......@@ -26536,7 +26529,7 @@ fn resolveExternOptions(
2653626529
2653726530 const linkage_ref = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, pt.tid, "linkage", .no_embedded_nulls), linkage_src);
2653826531 const linkage_val = try sema.resolveConstDefinedValue(block, linkage_src, linkage_ref, .{ .simple = .extern_options });
26539 const linkage = zcu.toEnum(std.builtin.GlobalLinkage, linkage_val);
26532 const linkage = try sema.interpretBuiltinType(block, linkage_src, linkage_val, std.builtin.GlobalLinkage);
2654026533
2654126534 const is_thread_local = try sema.fieldVal(block, src, options, try ip.getOrPutString(gpa, pt.tid, "is_thread_local", .no_embedded_nulls), thread_local_src);
2654226535 const is_thread_local_val = try sema.resolveConstDefinedValue(block, thread_local_src, is_thread_local, .{ .simple = .extern_options });
......@@ -26754,15 +26747,15 @@ fn zirInplaceArithResultTy(sema: *Sema, extended: Zir.Inst.Extended.InstData) Co
2675426747 .add_eq => ty: {
2675526748 const ptr_size = lhs_ty.ptrSizeOrNull(zcu) orelse break :ty lhs_ty;
2675626749 switch (ptr_size) {
26757 .One, .Slice => break :ty lhs_ty, // invalid, let it error
26758 .Many, .C => break :ty .usize, // `[*]T + usize`
26750 .one, .slice => break :ty lhs_ty, // invalid, let it error
26751 .many, .c => break :ty .usize, // `[*]T + usize`
2675926752 }
2676026753 },
2676126754 .sub_eq => ty: {
2676226755 const ptr_size = lhs_ty.ptrSizeOrNull(zcu) orelse break :ty lhs_ty;
2676326756 switch (ptr_size) {
26764 .One, .Slice => break :ty lhs_ty, // invalid, let it error
26765 .Many, .C => break :ty .generic_poison, // could be `[*]T - [*]T` or `[*]T - usize`
26757 .one, .slice => break :ty lhs_ty, // invalid, let it error
26758 .many, .c => break :ty .generic_poison, // could be `[*]T - [*]T` or `[*]T - usize`
2676626759 }
2676726760 },
2676826761 };
......@@ -26770,9 +26763,6 @@ fn zirInplaceArithResultTy(sema: *Sema, extended: Zir.Inst.Extended.InstData) Co
2677026763}
2677126764
2677226765fn zirBranchHint(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!void {
26773 const pt = sema.pt;
26774 const zcu = pt.zcu;
26775
2677626766 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;
2677726767 const uncoerced_hint = try sema.resolveInst(extra.operand);
2677826768 const operand_src = block.builtinCallArgSrc(extra.node, 0);
......@@ -26784,7 +26774,7 @@ fn zirBranchHint(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstDat
2678426774 // We only apply the first hint in a branch.
2678526775 // This allows user-provided hints to override implicit cold hints.
2678626776 if (sema.branch_hint == null) {
26787 sema.branch_hint = zcu.toEnum(std.builtin.BranchHint, hint_val);
26777 sema.branch_hint = try sema.interpretBuiltinType(block, operand_src, hint_val, std.builtin.BranchHint);
2678826778 }
2678926779}
2679026780
......@@ -27556,7 +27546,7 @@ fn fieldVal(
2755627546 .child = Type.fromInterned(ptr_info.child).childType(zcu).toIntern(),
2755727547 .sentinel = if (inner_ty.sentinel(zcu)) |s| s.toIntern() else .none,
2755827548 .flags = .{
27559 .size = .Many,
27549 .size = .many,
2756027550 .alignment = ptr_info.flags.alignment,
2756127551 .is_const = ptr_info.flags.is_const,
2756227552 .is_volatile = ptr_info.flags.is_volatile,
......@@ -27578,7 +27568,7 @@ fn fieldVal(
2757827568 },
2757927569 .pointer => {
2758027570 const ptr_info = inner_ty.ptrInfo(zcu);
27581 if (ptr_info.flags.size == .Slice) {
27571 if (ptr_info.flags.size == .slice) {
2758227572 if (field_name.eqlSlice("ptr", ip)) {
2758327573 const slice = if (is_pointer_to)
2758427574 try sema.analyzeLoad(block, src, object, object_src)
......@@ -27740,7 +27730,7 @@ fn fieldPtr(
2774027730 .child = Type.fromInterned(ptr_info.child).childType(zcu).toIntern(),
2774127731 .sentinel = if (object_ty.sentinel(zcu)) |s| s.toIntern() else .none,
2774227732 .flags = .{
27743 .size = .Many,
27733 .size = .many,
2774427734 .alignment = ptr_info.flags.alignment,
2774527735 .is_const = ptr_info.flags.is_const,
2774627736 .is_volatile = ptr_info.flags.is_volatile,
......@@ -27953,13 +27943,13 @@ fn fieldCallBind(
2795327943 const ip = &zcu.intern_pool;
2795427944 const raw_ptr_src = src; // TODO better source location
2795527945 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))
27946 const inner_ty = if (raw_ptr_ty.zigTypeTag(zcu) == .pointer and (raw_ptr_ty.ptrSize(zcu) == .one or raw_ptr_ty.ptrSize(zcu) == .c))
2795727947 raw_ptr_ty.childType(zcu)
2795827948 else
2795927949 return sema.fail(block, raw_ptr_src, "expected single pointer, found '{}'", .{raw_ptr_ty.fmt(pt)});
2796027950
2796127951 // 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;
27952 const is_double_ptr = inner_ty.zigTypeTag(zcu) == .pointer and inner_ty.ptrSize(zcu) == .one;
2796327953 const concrete_ty = if (is_double_ptr) inner_ty.childType(zcu) else inner_ty;
2796427954 const ptr_ty = if (is_double_ptr) inner_ty else raw_ptr_ty;
2796527955 const object_ptr = if (is_double_ptr)
......@@ -28025,8 +28015,8 @@ fn fieldCallBind(
2802528015 const first_param_type = Type.fromInterned(func_type.param_types.get(ip)[0]);
2802628016 if (first_param_type.isGenericPoison() or
2802728017 (first_param_type.zigTypeTag(zcu) == .pointer and
28028 (first_param_type.ptrSize(zcu) == .One or
28029 first_param_type.ptrSize(zcu) == .C) and
28018 (first_param_type.ptrSize(zcu) == .one or
28019 first_param_type.ptrSize(zcu) == .c) and
2803028020 first_param_type.childType(zcu).eql(concrete_ty, zcu)))
2803128021 {
2803228022 // Note that if the param type is generic poison, we know that it must
......@@ -28053,7 +28043,7 @@ fn fieldCallBind(
2805328043 .arg0_inst = deref,
2805428044 } };
2805528045 } else if (child.zigTypeTag(zcu) == .pointer and
28056 child.ptrSize(zcu) == .One and
28046 child.ptrSize(zcu) == .one and
2805728047 child.childType(zcu).eql(concrete_ty, zcu))
2805828048 {
2805928049 return .{ .method = .{
......@@ -28673,8 +28663,8 @@ fn elemPtrOneLayerOnly(
2867328663 try checkIndexable(sema, block, src, indexable_ty);
2867428664
2867528665 switch (indexable_ty.ptrSize(zcu)) {
28676 .Slice => return sema.elemPtrSlice(block, src, indexable_src, indexable, elem_index_src, elem_index, oob_safety),
28677 .Many, .C => {
28666 .slice => return sema.elemPtrSlice(block, src, indexable_src, indexable, elem_index_src, elem_index, oob_safety),
28667 .many, .c => {
2867828668 const maybe_ptr_val = try sema.resolveDefinedValue(block, indexable_src, indexable);
2867928669 const maybe_index_val = try sema.resolveDefinedValue(block, elem_index_src, elem_index);
2868028670 ct: {
......@@ -28688,7 +28678,7 @@ fn elemPtrOneLayerOnly(
2868828678
2868928679 return block.addPtrElemPtr(indexable, elem_index, result_ty);
2869028680 },
28691 .One => {
28681 .one => {
2869228682 const child_ty = indexable_ty.childType(zcu);
2869328683 const elem_ptr = switch (child_ty.zigTypeTag(zcu)) {
2869428684 .array, .vector => try sema.elemPtrArray(block, src, indexable_src, indexable, elem_index_src, elem_index, init, oob_safety),
......@@ -28728,8 +28718,8 @@ fn elemVal(
2872828718
2872928719 switch (indexable_ty.zigTypeTag(zcu)) {
2873028720 .pointer => switch (indexable_ty.ptrSize(zcu)) {
28731 .Slice => return sema.elemValSlice(block, src, indexable_src, indexable, elem_index_src, elem_index, oob_safety),
28732 .Many, .C => {
28721 .slice => return sema.elemValSlice(block, src, indexable_src, indexable, elem_index_src, elem_index, oob_safety),
28722 .many, .c => {
2873328723 const maybe_indexable_val = try sema.resolveDefinedValue(block, indexable_src, indexable);
2873428724 const maybe_index_val = try sema.resolveDefinedValue(block, elem_index_src, elem_index);
2873528725
......@@ -28748,7 +28738,7 @@ fn elemVal(
2874828738
2874928739 return block.addBinOp(.ptr_elem_val, indexable, elem_index);
2875028740 },
28751 .One => {
28741 .one => {
2875228742 arr_sent: {
2875328743 const inner_ty = indexable_ty.childType(zcu);
2875428744 if (inner_ty.zigTypeTag(zcu) != .array) break :arr_sent;
......@@ -29293,7 +29283,7 @@ fn coerceExtra(
2929329283
2929429284 // *T to *[1]T
2929529285 single_item: {
29296 if (dest_info.flags.size != .One) break :single_item;
29286 if (dest_info.flags.size != .one) break :single_item;
2929729287 if (!inst_ty.isSinglePointer(zcu)) break :single_item;
2929829288 if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :pointer;
2929929289 const ptr_elem_ty = inst_ty.childType(zcu);
......@@ -29312,7 +29302,7 @@ fn coerceExtra(
2931229302 // Coercions where the source is a single pointer to an array.
2931329303 src_array_ptr: {
2931429304 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 valid
29305 if (dest_info.flags.size == .one) break :src_array_ptr; // `*[n]T` -> `*T` isn't valid
2931629306 if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :pointer;
2931729307 const array_ty = inst_ty.childType(zcu);
2931829308 if (array_ty.zigTypeTag(zcu) != .array) break :src_array_ptr;
......@@ -29356,25 +29346,25 @@ fn coerceExtra(
2935629346 }
2935729347
2935829348 switch (dest_info.flags.size) {
29359 .Slice => {
29349 .slice => {
2936029350 // *[N]T to []T
2936129351 return sema.coerceArrayPtrToSlice(block, dest_ty, inst, inst_src);
2936229352 },
29363 .C => {
29353 .c => {
2936429354 // *[N]T to [*c]T
2936529355 return sema.coerceCompatiblePtrs(block, dest_ty, inst, inst_src);
2936629356 },
29367 .Many => {
29357 .many => {
2936829358 // *[N]T to [*]T
2936929359 return sema.coerceCompatiblePtrs(block, dest_ty, inst, inst_src);
2937029360 },
29371 .One => unreachable, // early exit at top of block
29361 .one => unreachable, // early exit at top of block
2937229362 }
2937329363 }
2937429364
2937529365 // coercion from C pointer
2937629366 if (inst_ty.isCPtr(zcu)) src_c_ptr: {
29377 if (dest_info.flags.size == .Slice) break :src_c_ptr;
29367 if (dest_info.flags.size == .slice) break :src_c_ptr;
2937829368 if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :src_c_ptr;
2937929369 // In this case we must add a safety check because the C pointer
2938029370 // could be null.
......@@ -29413,7 +29403,7 @@ fn coerceExtra(
2941329403
2941429404 switch (dest_info.flags.size) {
2941529405 // coercion to C pointer
29416 .C => switch (inst_ty.zigTypeTag(zcu)) {
29406 .c => switch (inst_ty.zigTypeTag(zcu)) {
2941729407 .null => return Air.internedToRef(try pt.intern(.{ .ptr = .{
2941829408 .ty = dest_ty.toIntern(),
2941929409 .base_addr = .int,
......@@ -29457,7 +29447,7 @@ fn coerceExtra(
2945729447 .ok => {},
2945829448 else => break :p,
2945929449 }
29460 if (inst_info.flags.size == .Slice) {
29450 if (inst_info.flags.size == .slice) {
2946129451 assert(dest_info.sentinel == .none);
2946229452 if (inst_info.sentinel == .none or
2946329453 inst_info.sentinel != (try pt.intValue(Type.fromInterned(inst_info.child), 0)).toIntern())
......@@ -29470,8 +29460,8 @@ fn coerceExtra(
2947029460 },
2947129461 else => {},
2947229462 },
29473 .One => {},
29474 .Slice => to_slice: {
29463 .one => {},
29464 .slice => to_slice: {
2947529465 if (inst_ty.zigTypeTag(zcu) == .array) {
2947629466 return sema.fail(
2947729467 block,
......@@ -29512,7 +29502,7 @@ fn coerceExtra(
2951229502 }
2951329503 return sema.coerceTupleToSlicePtrs(block, dest_ty, dest_ty_src, inst, inst_src);
2951429504 },
29515 .Many => p: {
29505 .many => p: {
2951629506 if (!inst_ty.isSlice(zcu)) break :p;
2951729507 if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :p;
2951829508 const inst_info = inst_ty.ptrInfo(zcu);
......@@ -30224,10 +30214,10 @@ const InMemoryCoercionResult = union(enum) {
3022430214
3022530215fn pointerSizeString(size: std.builtin.Type.Pointer.Size) []const u8 {
3022630216 return switch (size) {
30227 .One => "single pointer",
30228 .Many => "many pointer",
30229 .C => "C pointer",
30230 .Slice => "slice",
30217 .one => "single pointer",
30218 .many => "many pointer",
30219 .c => "C pointer",
30220 .slice => "slice",
3023130221 };
3023230222}
3023330223
......@@ -30775,7 +30765,7 @@ fn coerceInMemoryAllowedPtrs(
3077530765 const src_info = src_ptr_ty.ptrInfo(zcu);
3077630766
3077730767 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;
30768 src_info.flags.size == .c or dest_info.flags.size == .c;
3077930769 if (!ok_ptr_size) {
3078030770 return InMemoryCoercionResult{ .ptr_size = .{
3078130771 .actual = src_info.flags.size,
......@@ -30874,7 +30864,7 @@ fn coerceInMemoryAllowedPtrs(
3087430864 if (ss != .none and ds != .none) {
3087530865 if (ds == try zcu.intern_pool.getCoerced(sema.gpa, pt.tid, ss, dest_info.child)) break :ok true;
3087630866 }
30877 if (src_info.flags.size == .C) break :ok true;
30867 if (src_info.flags.size == .c) break :ok true;
3087830868 if (!dest_is_mut and dest_info.sentinel == .none) break :ok true;
3087930869 break :ok false;
3088030870 };
......@@ -31392,7 +31382,7 @@ fn checkPtrAttributes(sema: *Sema, dest_ty: Type, inst_ty: Type, in_memory_resul
3139231382 const dest_info = dest_ty.ptrInfo(zcu);
3139331383 const inst_info = inst_ty.ptrInfo(zcu);
3139431384 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))) or
31385 (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
3139631386 (Type.fromInterned(inst_info.child).isTuple(zcu) and Type.fromInterned(inst_info.child).structFieldCount(zcu) == 0);
3139731387
3139831388 const ok_const = (!inst_info.flags.is_const or dest_info.flags.is_const) or len0;
......@@ -32631,7 +32621,7 @@ fn analyzeSlice(
3263132621 elem_ty = ptr_ptr_child_ty.childType(zcu);
3263232622 },
3263332623 .pointer => switch (ptr_ptr_child_ty.ptrSize(zcu)) {
32634 .One => {
32624 .one => {
3263532625 const double_child_ty = ptr_ptr_child_ty.childType(zcu);
3263632626 ptr_or_slice = try sema.analyzeLoad(block, src, ptr_ptr, ptr_src);
3263732627 if (double_child_ty.zigTypeTag(zcu) == .array) {
......@@ -32721,14 +32711,14 @@ fn analyzeSlice(
3272132711 elem_ty = double_child_ty;
3272232712 }
3272332713 },
32724 .Many, .C => {
32714 .many, .c => {
3272532715 ptr_sentinel = ptr_ptr_child_ty.sentinel(zcu);
3272632716 ptr_or_slice = try sema.analyzeLoad(block, src, ptr_ptr, ptr_src);
3272732717 slice_ty = ptr_ptr_child_ty;
3272832718 array_ty = ptr_ptr_child_ty;
3272932719 elem_ty = ptr_ptr_child_ty.childType(zcu);
3273032720
32731 if (ptr_ptr_child_ty.ptrSize(zcu) == .C) {
32721 if (ptr_ptr_child_ty.ptrSize(zcu) == .c) {
3273232722 if (try sema.resolveDefinedValue(block, ptr_src, ptr_or_slice)) |ptr_val| {
3273332723 if (ptr_val.isNull(zcu)) {
3273432724 return sema.fail(block, src, "slice of null pointer", .{});
......@@ -32736,7 +32726,7 @@ fn analyzeSlice(
3273632726 }
3273732727 }
3273832728 },
32739 .Slice => {
32729 .slice => {
3274032730 ptr_sentinel = ptr_ptr_child_ty.sentinel(zcu);
3274132731 ptr_or_slice = try sema.analyzeLoad(block, src, ptr_ptr, ptr_src);
3274232732 slice_ty = ptr_ptr_child_ty;
......@@ -32752,9 +32742,9 @@ fn analyzeSlice(
3275232742 else if (array_ty.zigTypeTag(zcu) == .array) ptr: {
3275332743 var manyptr_ty_key = zcu.intern_pool.indexToKey(slice_ty.toIntern()).ptr_type;
3275432744 assert(manyptr_ty_key.child == array_ty.toIntern());
32755 assert(manyptr_ty_key.flags.size == .One);
32745 assert(manyptr_ty_key.flags.size == .one);
3275632746 manyptr_ty_key.child = elem_ty.toIntern();
32757 manyptr_ty_key.flags.size = .Many;
32747 manyptr_ty_key.flags.size = .many;
3275832748 break :ptr try sema.coerceCompatiblePtrs(block, try pt.ptrTypeSema(manyptr_ty_key), ptr_or_slice, ptr_src);
3275932749 } else ptr_or_slice;
3276032750
......@@ -32967,7 +32957,7 @@ fn analyzeSlice(
3296732957 const opt_new_len_val = try sema.resolveDefinedValue(block, src, new_len);
3296832958
3296932959 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;
32960 const new_allowzero = new_ptr_ty_info.flags.is_allowzero and sema.typeOf(ptr).ptrSize(zcu) != .c;
3297132961
3297232962 if (opt_new_len_val) |new_len_val| {
3297332963 const new_len_int = try new_len_val.toUnsignedIntSema(pt);
......@@ -33038,7 +33028,7 @@ fn analyzeSlice(
3303833028 .child = elem_ty.toIntern(),
3303933029 .sentinel = if (sentinel) |s| s.toIntern() else .none,
3304033030 .flags = .{
33041 .size = .Slice,
33031 .size = .slice,
3304233032 .alignment = new_ptr_ty_info.flags.alignment,
3304333033 .is_const = new_ptr_ty_info.flags.is_const,
3304433034 .is_volatile = new_ptr_ty_info.flags.is_volatile,
......@@ -33739,7 +33729,7 @@ const PeerResolveStrategy = enum {
3373933729 .int => .fixed_int,
3374033730 .comptime_float => .comptime_float,
3374133731 .float => .fixed_float,
33742 .pointer => if (ty.ptrInfo(zcu).flags.size == .C) .c_ptr else .ptr,
33732 .pointer => if (ty.ptrInfo(zcu).flags.size == .c) .c_ptr else .ptr,
3374333733 .array => .array,
3374433734 .vector => .vector,
3374533735 .optional => .optional,
......@@ -34235,7 +34225,7 @@ fn resolvePeerTypesInner(
3423534225
3423634226 var ptr_info = opt_ptr_info orelse {
3423734227 opt_ptr_info = peer_info;
34238 opt_ptr_info.?.flags.size = .C;
34228 opt_ptr_info.?.flags.size = .c;
3423934229 first_idx = i;
3424034230 continue;
3424134231 };
......@@ -34323,9 +34313,9 @@ fn resolvePeerTypesInner(
3432334313 };
3432434314
3432534315 switch (peer_info.flags.size) {
34326 .One, .Many => {},
34327 .Slice => opt_slice_idx = i,
34328 .C => return .{ .conflict = .{
34316 .one, .many => {},
34317 .slice => opt_slice_idx = i,
34318 .c => return .{ .conflict = .{
3432934319 .peer_idx_a = strat_reason,
3433034320 .peer_idx_b = i,
3433134321 } },
......@@ -34370,21 +34360,21 @@ fn resolvePeerTypesInner(
3437034360 ptr_info.flags.is_allowzero = ptr_info.flags.is_allowzero or peer_info.flags.is_allowzero;
3437134361
3437234362 const peer_sentinel: InternPool.Index = switch (peer_info.flags.size) {
34373 .One => switch (ip.indexToKey(peer_info.child)) {
34363 .one => switch (ip.indexToKey(peer_info.child)) {
3437434364 .array_type => |array_type| array_type.sentinel,
3437534365 else => .none,
3437634366 },
34377 .Many, .Slice => peer_info.sentinel,
34378 .C => unreachable,
34367 .many, .slice => peer_info.sentinel,
34368 .c => unreachable,
3437934369 };
3438034370
3438134371 const cur_sentinel: InternPool.Index = switch (ptr_info.flags.size) {
34382 .One => switch (ip.indexToKey(ptr_info.child)) {
34372 .one => switch (ip.indexToKey(ptr_info.child)) {
3438334373 .array_type => |array_type| array_type.sentinel,
3438434374 else => .none,
3438534375 },
34386 .Many, .Slice => ptr_info.sentinel,
34387 .C => unreachable,
34376 .many, .slice => ptr_info.sentinel,
34377 .c => unreachable,
3438834378 };
3438934379
3439034380 // We abstract array handling slightly so that tuple pointers can work like array pointers
......@@ -34395,8 +34385,8 @@ fn resolvePeerTypesInner(
3439534385 // single-pointer array sentinel).
3439634386 good: {
3439734387 switch (peer_info.flags.size) {
34398 .One => switch (ptr_info.flags.size) {
34399 .One => {
34388 .one => switch (ptr_info.flags.size) {
34389 .one => {
3440034390 if (try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), Type.fromInterned(peer_info.child))) |pointee| {
3440134391 ptr_info.child = pointee.toIntern();
3440234392 break :good;
......@@ -34415,28 +34405,28 @@ fn resolvePeerTypesInner(
3441534405 break :good;
3441634406 }
3441734407 // *[a]T + *[b]T = []T
34418 ptr_info.flags.size = .Slice;
34408 ptr_info.flags.size = .slice;
3441934409 ptr_info.child = elem_ty.toIntern();
3442034410 break :good;
3442134411 }
3442234412
3442334413 if (peer_arr.elem_ty.toIntern() == .noreturn_type) {
3442434414 // *struct{} + *[a]T = []T
34425 ptr_info.flags.size = .Slice;
34415 ptr_info.flags.size = .slice;
3442634416 ptr_info.child = cur_arr.elem_ty.toIntern();
3442734417 break :good;
3442834418 }
3442934419
3443034420 if (cur_arr.elem_ty.toIntern() == .noreturn_type) {
3443134421 // *[a]T + *struct{} = []T
34432 ptr_info.flags.size = .Slice;
34422 ptr_info.flags.size = .slice;
3443334423 ptr_info.child = peer_arr.elem_ty.toIntern();
3443434424 break :good;
3443534425 }
3443634426
3443734427 return generic_err;
3443834428 },
34439 .Many => {
34429 .many => {
3444034430 // Only works for *[n]T + [*]T -> [*]T
3444134431 const arr = peer_pointee_array orelse return generic_err;
3444234432 if (try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), arr.elem_ty)) |pointee| {
......@@ -34449,7 +34439,7 @@ fn resolvePeerTypesInner(
3444934439 }
3445034440 return generic_err;
3445134441 },
34452 .Slice => {
34442 .slice => {
3445334443 // Only works for *[n]T + []T -> []T
3445434444 const arr = peer_pointee_array orelse return generic_err;
3445534445 if (try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), arr.elem_ty)) |pointee| {
......@@ -34462,33 +34452,33 @@ fn resolvePeerTypesInner(
3446234452 }
3446334453 return generic_err;
3446434454 },
34465 .C => unreachable,
34455 .c => unreachable,
3446634456 },
34467 .Many => switch (ptr_info.flags.size) {
34468 .One => {
34457 .many => switch (ptr_info.flags.size) {
34458 .one => {
3446934459 // Only works for [*]T + *[n]T -> [*]T
3447034460 const arr = cur_pointee_array orelse return generic_err;
3447134461 if (try sema.resolvePairInMemoryCoercible(block, src, arr.elem_ty, Type.fromInterned(peer_info.child))) |pointee| {
34472 ptr_info.flags.size = .Many;
34462 ptr_info.flags.size = .many;
3447334463 ptr_info.child = pointee.toIntern();
3447434464 break :good;
3447534465 }
3447634466 if (arr.elem_ty.toIntern() == .noreturn_type) {
3447734467 // [*]T + *struct{} -> [*]T
34478 ptr_info.flags.size = .Many;
34468 ptr_info.flags.size = .many;
3447934469 ptr_info.child = peer_info.child;
3448034470 break :good;
3448134471 }
3448234472 return generic_err;
3448334473 },
34484 .Many => {
34474 .many => {
3448534475 if (try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), Type.fromInterned(peer_info.child))) |pointee| {
3448634476 ptr_info.child = pointee.toIntern();
3448734477 break :good;
3448834478 }
3448934479 return generic_err;
3449034480 },
34491 .Slice => {
34481 .slice => {
3449234482 // Only works if no peers are actually slices
3449334483 if (opt_slice_idx) |slice_idx| {
3449434484 return .{ .conflict = .{
......@@ -34498,54 +34488,54 @@ fn resolvePeerTypesInner(
3449834488 }
3449934489 // Okay, then works for [*]T + "[]T" -> [*]T
3450034490 if (try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), Type.fromInterned(peer_info.child))) |pointee| {
34501 ptr_info.flags.size = .Many;
34491 ptr_info.flags.size = .many;
3450234492 ptr_info.child = pointee.toIntern();
3450334493 break :good;
3450434494 }
3450534495 return generic_err;
3450634496 },
34507 .C => unreachable,
34497 .c => unreachable,
3450834498 },
34509 .Slice => switch (ptr_info.flags.size) {
34510 .One => {
34499 .slice => switch (ptr_info.flags.size) {
34500 .one => {
3451134501 // Only works for []T + *[n]T -> []T
3451234502 const arr = cur_pointee_array orelse return generic_err;
3451334503 if (try sema.resolvePairInMemoryCoercible(block, src, arr.elem_ty, Type.fromInterned(peer_info.child))) |pointee| {
34514 ptr_info.flags.size = .Slice;
34504 ptr_info.flags.size = .slice;
3451534505 ptr_info.child = pointee.toIntern();
3451634506 break :good;
3451734507 }
3451834508 if (arr.elem_ty.toIntern() == .noreturn_type) {
3451934509 // []T + *struct{} -> []T
34520 ptr_info.flags.size = .Slice;
34510 ptr_info.flags.size = .slice;
3452134511 ptr_info.child = peer_info.child;
3452234512 break :good;
3452334513 }
3452434514 return generic_err;
3452534515 },
34526 .Many => {
34516 .many => {
3452734517 // Impossible! (current peer is an actual slice)
3452834518 return generic_err;
3452934519 },
34530 .Slice => {
34520 .slice => {
3453134521 if (try sema.resolvePairInMemoryCoercible(block, src, Type.fromInterned(ptr_info.child), Type.fromInterned(peer_info.child))) |pointee| {
3453234522 ptr_info.child = pointee.toIntern();
3453334523 break :good;
3453434524 }
3453534525 return generic_err;
3453634526 },
34537 .C => unreachable,
34527 .c => unreachable,
3453834528 },
34539 .C => unreachable,
34529 .c => unreachable,
3454034530 }
3454134531 }
3454234532
3454334533 const sentinel_ty = switch (ptr_info.flags.size) {
34544 .One => switch (ip.indexToKey(ptr_info.child)) {
34534 .one => switch (ip.indexToKey(ptr_info.child)) {
3454534535 .array_type => |array_type| array_type.child,
3454634536 else => ptr_info.child,
3454734537 },
34548 .Many, .Slice, .C => ptr_info.child,
34538 .many, .slice, .c => ptr_info.child,
3454934539 };
3455034540
3455134541 sentinel: {
......@@ -34556,7 +34546,7 @@ fn resolvePeerTypesInner(
3455634546 const cur_sent_coerced = try ip.getCoerced(sema.gpa, pt.tid, cur_sentinel, sentinel_ty);
3455734547 if (peer_sent_coerced != cur_sent_coerced) break :no_sentinel;
3455834548 // Sentinels match
34559 if (ptr_info.flags.size == .One) switch (ip.indexToKey(ptr_info.child)) {
34549 if (ptr_info.flags.size == .one) switch (ip.indexToKey(ptr_info.child)) {
3456034550 .array_type => |array_type| ptr_info.child = (try pt.arrayType(.{
3456134551 .len = array_type.len,
3456234552 .child = array_type.child,
......@@ -35416,8 +35406,8 @@ fn checkMemOperand(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) !void
3541635406 const zcu = pt.zcu;
3541735407 if (ty.zigTypeTag(zcu) == .pointer) {
3541835408 switch (ty.ptrSize(zcu)) {
35419 .Slice, .Many, .C => return,
35420 .One => {
35409 .slice, .many, .c => return,
35410 .one => {
3542135411 const elem_ty = ty.childType(zcu);
3542235412 if (elem_ty.zigTypeTag(zcu) == .array) return;
3542335413 // TODO https://github.com/ziglang/zig/issues/15479
......@@ -37136,11 +37126,10 @@ pub fn analyzeAsAddressSpace(
3713637126 ctx: AddressSpaceContext,
3713737127) !std.builtin.AddressSpace {
3713837128 const pt = sema.pt;
37139 const zcu = pt.zcu;
3714037129 const addrspace_ty = try sema.getBuiltinType(src, .AddressSpace);
3714137130 const coerced = try sema.coerce(block, addrspace_ty, air_ref, src);
3714237131 const addrspace_val = try sema.resolveConstDefinedValue(block, src, coerced, .{ .simple = .@"addrspace" });
37143 const address_space = zcu.toEnum(std.builtin.AddressSpace, addrspace_val);
37132 const address_space = try sema.interpretBuiltinType(block, src, addrspace_val, std.builtin.AddressSpace);
3714437133 const target = pt.zcu.getTarget();
3714537134 const arch = target.cpu.arch;
3714637135
......@@ -37248,13 +37237,13 @@ fn typePtrOrOptionalPtrTy(sema: *Sema, ty: Type) !?Type {
3724837237 const zcu = pt.zcu;
3724937238 return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {
3725037239 .ptr_type => |ptr_type| switch (ptr_type.flags.size) {
37251 .One, .Many, .C => ty,
37252 .Slice => null,
37240 .one, .many, .c => ty,
37241 .slice => null,
3725337242 },
3725437243 .opt_type => |opt_child| switch (zcu.intern_pool.indexToKey(opt_child)) {
3725537244 .ptr_type => |ptr_type| switch (ptr_type.flags.size) {
37256 .Slice, .C => null,
37257 .Many, .One => {
37245 .slice, .c => null,
37246 .many, .one => {
3725837247 if (ptr_type.flags.is_allowzero) return null;
3725937248
3726037249 // optionals of zero sized types behave like bools, not pointers
......@@ -38260,7 +38249,7 @@ fn maybeDerefSliceAsArray(
3826038249 });
3826138250 const ptr_ty = try pt.ptrTypeSema(p: {
3826238251 var p = Type.fromInterned(slice.ty).ptrInfo(zcu);
38263 p.flags.size = .One;
38252 p.flags.size = .one;
3826438253 p.child = array_ty.toIntern();
3826538254 p.sentinel = .none;
3826638255 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
192192 const info = ty.ptrInfo(zcu);
193193
194194 if (info.sentinel != .none) switch (info.flags.size) {
195 .One, .C => unreachable,
196 .Many => try writer.print("[*:{}]", .{Value.fromInterned(info.sentinel).fmtValue(pt)}),
197 .Slice => try writer.print("[:{}]", .{Value.fromInterned(info.sentinel).fmtValue(pt)}),
195 .one, .c => unreachable,
196 .many => try writer.print("[*:{}]", .{Value.fromInterned(info.sentinel).fmtValue(pt)}),
197 .slice => try writer.print("[:{}]", .{Value.fromInterned(info.sentinel).fmtValue(pt)}),
198198 } else switch (info.flags.size) {
199 .One => try writer.writeAll("*"),
200 .Many => try writer.writeAll("[*]"),
201 .C => try writer.writeAll("[*c]"),
202 .Slice => try writer.writeAll("[]"),
199 .one => try writer.writeAll("*"),
200 .many => try writer.writeAll("[*]"),
201 .c => try writer.writeAll("[*c]"),
202 .slice => try writer.writeAll("[]"),
203203 }
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 ");
205205 if (info.flags.alignment != .none or
206206 info.packed_offset.host_size != 0 or
207207 info.flags.vector_index != .none)
......@@ -686,7 +686,7 @@ pub fn hasWellDefinedLayout(ty: Type, zcu: *const Zcu) bool {
686686
687687 .array_type => |array_type| Type.fromInterned(array_type.child).hasWellDefinedLayout(zcu),
688688 .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
691691 .simple_type => |t| switch (t) {
692692 .f16,
......@@ -1303,7 +1303,7 @@ pub fn abiSizeInner(
13031303 return .{ .scalar = intAbiSize(int_type.bits, target, use_llvm) };
13041304 },
13051305 .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 },
13071307 else => return .{ .scalar = @divExact(target.ptrBitWidth(), 8) },
13081308 },
13091309 .anyframe_type => return .{ .scalar = @divExact(target.ptrBitWidth(), 8) },
......@@ -1741,7 +1741,7 @@ pub fn bitSizeInner(
17411741 switch (ip.indexToKey(ty.toIntern())) {
17421742 .int_type => |int_type| return int_type.bits,
17431743 .ptr_type => |ptr_type| switch (ptr_type.flags.size) {
1744 .Slice => return target.ptrBitWidth() * 2,
1744 .slice => return target.ptrBitWidth() * 2,
17451745 else => return target.ptrBitWidth(),
17461746 },
17471747 .anyframe_type => return target.ptrBitWidth(),
......@@ -1903,7 +1903,7 @@ pub fn layoutIsResolved(ty: Type, zcu: *const Zcu) bool {
19031903
19041904pub fn isSinglePointer(ty: Type, zcu: *const Zcu) bool {
19051905 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,
19071907 else => false,
19081908 };
19091909}
......@@ -1923,7 +1923,7 @@ pub fn ptrSizeOrNull(ty: Type, zcu: *const Zcu) ?std.builtin.Type.Pointer.Size {
19231923
19241924pub fn isSlice(ty: Type, zcu: *const Zcu) bool {
19251925 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,
19271927 else => false,
19281928 };
19291929}
......@@ -1960,7 +1960,7 @@ pub fn isAllowzeroPtr(ty: Type, zcu: *const Zcu) bool {
19601960
19611961pub fn isCPtr(ty: Type, zcu: *const Zcu) bool {
19621962 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,
19641964 else => false,
19651965 };
19661966}
......@@ -1968,13 +1968,13 @@ pub fn isCPtr(ty: Type, zcu: *const Zcu) bool {
19681968pub fn isPtrAtRuntime(ty: Type, zcu: *const Zcu) bool {
19691969 return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {
19701970 .ptr_type => |ptr_type| switch (ptr_type.flags.size) {
1971 .Slice => false,
1972 .One, .Many, .C => true,
1971 .slice => false,
1972 .one, .many, .c => true,
19731973 },
19741974 .opt_type => |child| switch (zcu.intern_pool.indexToKey(child)) {
19751975 .ptr_type => |p| switch (p.flags.size) {
1976 .Slice, .C => false,
1977 .Many, .One => !p.flags.is_allowzero,
1976 .slice, .c => false,
1977 .many, .one => !p.flags.is_allowzero,
19781978 },
19791979 else => false,
19801980 },
......@@ -1995,11 +1995,11 @@ pub fn ptrAllowsZero(ty: Type, zcu: *const Zcu) bool {
19951995pub fn optionalReprIsPayload(ty: Type, zcu: *const Zcu) bool {
19961996 return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {
19971997 .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,
19991999 .error_set_type, .inferred_error_set_type => true,
20002000 else => false,
20012001 },
2002 .ptr_type => |ptr_type| ptr_type.flags.size == .C,
2002 .ptr_type => |ptr_type| ptr_type.flags.size == .c,
20032003 else => false,
20042004 };
20052005}
......@@ -2009,11 +2009,11 @@ pub fn optionalReprIsPayload(ty: Type, zcu: *const Zcu) bool {
20092009/// This function must be kept in sync with `Sema.typePtrOrOptionalPtrTy`.
20102010pub fn isPtrLikeOptional(ty: Type, zcu: *const Zcu) bool {
20112011 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,
20132013 .opt_type => |child| switch (zcu.intern_pool.indexToKey(child)) {
20142014 .ptr_type => |ptr_type| switch (ptr_type.flags.size) {
2015 .Slice, .C => false,
2016 .Many, .One => !ptr_type.flags.is_allowzero,
2015 .slice, .c => false,
2016 .many, .one => !ptr_type.flags.is_allowzero,
20172017 },
20182018 else => false,
20192019 },
......@@ -2044,8 +2044,8 @@ pub fn childTypeIp(ty: Type, ip: *const InternPool) Type {
20442044pub fn elemType2(ty: Type, zcu: *const Zcu) Type {
20452045 return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {
20462046 .ptr_type => |ptr_type| switch (ptr_type.flags.size) {
2047 .One => Type.fromInterned(ptr_type.child).shallowElemType(zcu),
2048 .Many, .C, .Slice => Type.fromInterned(ptr_type.child),
2047 .one => Type.fromInterned(ptr_type.child).shallowElemType(zcu),
2048 .many, .c, .slice => Type.fromInterned(ptr_type.child),
20492049 },
20502050 .anyframe_type => |child| {
20512051 assert(child != .none);
......@@ -2079,7 +2079,7 @@ pub fn optionalChild(ty: Type, zcu: *const Zcu) Type {
20792079 return switch (zcu.intern_pool.indexToKey(ty.toIntern())) {
20802080 .opt_type => |child| Type.fromInterned(child),
20812081 .ptr_type => |ptr_type| b: {
2082 assert(ptr_type.flags.size == .C);
2082 assert(ptr_type.flags.size == .c);
20832083 break :b ty;
20842084 },
20852085 else => unreachable,
......@@ -2991,8 +2991,8 @@ pub fn isIndexable(ty: Type, zcu: *const Zcu) bool {
29912991 return switch (ty.zigTypeTag(zcu)) {
29922992 .array, .vector => true,
29932993 .pointer => switch (ty.ptrSize(zcu)) {
2994 .Slice, .Many, .C => true,
2995 .One => switch (ty.childType(zcu).zigTypeTag(zcu)) {
2994 .slice, .many, .c => true,
2995 .one => switch (ty.childType(zcu).zigTypeTag(zcu)) {
29962996 .array, .vector => true,
29972997 .@"struct" => ty.childType(zcu).isTuple(zcu),
29982998 else => false,
......@@ -3007,9 +3007,9 @@ pub fn indexableHasLen(ty: Type, zcu: *const Zcu) bool {
30073007 return switch (ty.zigTypeTag(zcu)) {
30083008 .array, .vector => true,
30093009 .pointer => switch (ty.ptrSize(zcu)) {
3010 .Many, .C => false,
3011 .Slice => true,
3012 .One => switch (ty.childType(zcu).zigTypeTag(zcu)) {
3010 .many, .c => false,
3011 .slice => true,
3012 .one => switch (ty.childType(zcu).zigTypeTag(zcu)) {
30133013 .array, .vector => true,
30143014 .@"struct" => ty.childType(zcu).isTuple(zcu),
30153015 else => false,
......@@ -4049,7 +4049,7 @@ pub fn elemPtrType(ptr_ty: Type, offset: ?usize, pt: Zcu.PerThread) !Type {
40494049 host_size: u16 = 0,
40504050 alignment: Alignment = .none,
40514051 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: {
40534053 const elem_bits = elem_ty.bitSize(zcu);
40544054 if (elem_bits == 0) break :blk .{};
40554055 const is_packed = elem_bits < 8 or !std.math.isPowerOfTwo(elem_bits);
src/Value.zig+113-39
......@@ -1,5 +1,6 @@
11const std = @import("std");
22const builtin = @import("builtin");
3const build_options = @import("build_options");
34const Type = @import("Type.zig");
45const assert = std.debug.assert;
56const BigIntConst = std.math.big.int.Const;
......@@ -3724,7 +3725,7 @@ pub fn ptrOptPayload(parent_ptr: Value, pt: Zcu.PerThread) !Value {
37243725 const parent_ptr_ty = parent_ptr.typeOf(zcu);
37253726 const opt_ty = parent_ptr_ty.childType(zcu);
37263727
3727 assert(parent_ptr_ty.ptrSize(zcu) == .One);
3728 assert(parent_ptr_ty.ptrSize(zcu) == .one);
37283729 assert(opt_ty.zigTypeTag(zcu) == .optional);
37293730
37303731 const result_ty = try pt.ptrTypeSema(info: {
......@@ -3742,7 +3743,7 @@ pub fn ptrOptPayload(parent_ptr: Value, pt: Zcu.PerThread) !Value {
37423743 return pt.getCoerced(parent_ptr, result_ty);
37433744 }
37443745
3745 const base_ptr = try parent_ptr.canonicalizeBasePtr(.One, opt_ty, pt);
3746 const base_ptr = try parent_ptr.canonicalizeBasePtr(.one, opt_ty, pt);
37463747 return Value.fromInterned(try pt.intern(.{ .ptr = .{
37473748 .ty = result_ty.toIntern(),
37483749 .base_addr = .{ .opt_payload = base_ptr.toIntern() },
......@@ -3758,7 +3759,7 @@ pub fn ptrEuPayload(parent_ptr: Value, pt: Zcu.PerThread) !Value {
37583759 const parent_ptr_ty = parent_ptr.typeOf(zcu);
37593760 const eu_ty = parent_ptr_ty.childType(zcu);
37603761
3761 assert(parent_ptr_ty.ptrSize(zcu) == .One);
3762 assert(parent_ptr_ty.ptrSize(zcu) == .one);
37623763 assert(eu_ty.zigTypeTag(zcu) == .error_union);
37633764
37643765 const result_ty = try pt.ptrTypeSema(info: {
......@@ -3771,7 +3772,7 @@ pub fn ptrEuPayload(parent_ptr: Value, pt: Zcu.PerThread) !Value {
37713772
37723773 if (parent_ptr.isUndef(zcu)) return pt.undefValue(result_ty);
37733774
3774 const base_ptr = try parent_ptr.canonicalizeBasePtr(.One, eu_ty, pt);
3775 const base_ptr = try parent_ptr.canonicalizeBasePtr(.one, eu_ty, pt);
37753776 return Value.fromInterned(try pt.intern(.{ .ptr = .{
37763777 .ty = result_ty.toIntern(),
37773778 .base_addr = .{ .eu_payload = base_ptr.toIntern() },
......@@ -3789,7 +3790,7 @@ pub fn ptrField(parent_ptr: Value, field_idx: u32, pt: Zcu.PerThread) !Value {
37893790 const aggregate_ty = parent_ptr_ty.childType(zcu);
37903791
37913792 const parent_ptr_info = parent_ptr_ty.ptrInfo(zcu);
3792 assert(parent_ptr_info.flags.size == .One);
3793 assert(parent_ptr_info.flags.size == .one);
37933794
37943795 // Exiting this `switch` indicates that the `field` pointer representation should be used.
37953796 // `field_align` may be `.none` to represent the natural alignment of `field_ty`, but is not necessarily.
......@@ -3920,7 +3921,7 @@ pub fn ptrField(parent_ptr: Value, field_idx: u32, pt: Zcu.PerThread) !Value {
39203921
39213922 if (parent_ptr.isUndef(zcu)) return pt.undefValue(result_ty);
39223923
3923 const base_ptr = try parent_ptr.canonicalizeBasePtr(.One, aggregate_ty, pt);
3924 const base_ptr = try parent_ptr.canonicalizeBasePtr(.one, aggregate_ty, pt);
39243925 return Value.fromInterned(try pt.intern(.{ .ptr = .{
39253926 .ty = result_ty.toIntern(),
39263927 .base_addr = .{ .field = .{
......@@ -3937,8 +3938,8 @@ pub fn ptrField(parent_ptr: Value, field_idx: u32, pt: Zcu.PerThread) !Value {
39373938pub fn ptrElem(orig_parent_ptr: Value, field_idx: u64, pt: Zcu.PerThread) !Value {
39383939 const zcu = pt.zcu;
39393940 const parent_ptr = switch (orig_parent_ptr.typeOf(zcu).ptrSize(zcu)) {
3940 .One, .Many, .C => orig_parent_ptr,
3941 .Slice => orig_parent_ptr.slicePtr(zcu),
3941 .one, .many, .c => orig_parent_ptr,
3942 .slice => orig_parent_ptr.slicePtr(zcu),
39423943 };
39433944
39443945 const parent_ptr_ty = parent_ptr.typeOf(zcu);
......@@ -3959,7 +3960,7 @@ pub fn ptrElem(orig_parent_ptr: Value, field_idx: u64, pt: Zcu.PerThread) !Value
39593960 };
39603961
39613962 const strat: PtrStrat = switch (parent_ptr_ty.ptrSize(zcu)) {
3962 .One => switch (elem_ty.zigTypeTag(zcu)) {
3963 .one => switch (elem_ty.zigTypeTag(zcu)) {
39633964 .vector => .{ .offset = field_idx * @divExact(try elem_ty.childType(zcu).bitSizeSema(pt), 8) },
39643965 .array => strat: {
39653966 const arr_elem_ty = elem_ty.childType(zcu);
......@@ -3971,12 +3972,12 @@ pub fn ptrElem(orig_parent_ptr: Value, field_idx: u64, pt: Zcu.PerThread) !Value
39713972 else => unreachable,
39723973 },
39733974
3974 .Many, .C => if (try elem_ty.comptimeOnlySema(pt))
3975 .many, .c => if (try elem_ty.comptimeOnlySema(pt))
39753976 .{ .elem_ptr = elem_ty }
39763977 else
39773978 .{ .offset = field_idx * (try elem_ty.abiSizeInner(.sema, zcu, pt.tid)).scalar },
39783979
3979 .Slice => unreachable,
3980 .slice => unreachable,
39803981 };
39813982
39823983 switch (strat) {
......@@ -4004,7 +4005,7 @@ pub fn ptrElem(orig_parent_ptr: Value, field_idx: u64, pt: Zcu.PerThread) !Value
40044005 },
40054006 else => {},
40064007 }
4007 const base_ptr = try parent_ptr.canonicalizeBasePtr(.Many, arr_base_ty, pt);
4008 const base_ptr = try parent_ptr.canonicalizeBasePtr(.many, arr_base_ty, pt);
40084009 return Value.fromInterned(try pt.intern(.{ .ptr = .{
40094010 .ty = result_ty.toIntern(),
40104011 .base_addr = .{ .arr_elem = .{
......@@ -4234,7 +4235,7 @@ pub fn pointerDerivationAdvanced(ptr_val: Value, arena: Allocator, pt: Zcu.PerTh
42344235 .child = parent_ptr_info.child,
42354236 .flags = flags: {
42364237 var flags = parent_ptr_info.flags;
4237 flags.size = .One;
4238 flags.size = .one;
42384239 break :flags flags;
42394240 },
42404241 });
......@@ -4304,8 +4305,8 @@ pub fn pointerDerivationAdvanced(ptr_val: Value, arena: Allocator, pt: Zcu.PerTh
43044305 if (!cur_ty.isPtrLikeOptional(zcu)) break :ptr_opt;
43054306 if (need_child.zigTypeTag(zcu) != .pointer) break :ptr_opt;
43064307 switch (need_child.ptrSize(zcu)) {
4307 .One, .Many => {},
4308 .Slice, .C => break :ptr_opt,
4308 .one, .many => {},
4309 .slice, .c => break :ptr_opt,
43094310 }
43104311 const parent = try arena.create(PointerDeriveStep);
43114312 parent.* = cur_derive;
......@@ -4323,7 +4324,7 @@ pub fn pointerDerivationAdvanced(ptr_val: Value, arena: Allocator, pt: Zcu.PerTh
43234324 const elem_size = elem_ty.abiSize(zcu);
43244325 const start_idx = cur_offset / elem_size;
43254326 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) {
4327 if (end_idx == start_idx + 1 and ptr_ty_info.flags.size == .one) {
43274328 const parent = try arena.create(PointerDeriveStep);
43284329 parent.* = cur_derive;
43294330 cur_derive = .{ .elem_ptr = .{
......@@ -4531,6 +4532,20 @@ pub fn resolveLazy(
45314532 }
45324533}
45334534
4535const InterpretMode = enum {
4536 /// In this mode, types are assumed to match what the compiler was built with in terms of field
4537 /// order, field types, etc. This improves compiler performance. However, it means that certain
4538 /// modifications to `std.builtin` will result in compiler crashes.
4539 direct,
4540 /// In this mode, various details of the type are allowed to differ from what the compiler was built
4541 /// with. Fields are matched by name rather than index; added struct fields are ignored, and removed
4542 /// struct fields use their default value if one exists. This is slower than `.direct`, but permits
4543 /// making certain changes to `std.builtin` (in particular reordering/adding/removing fields), so it
4544 /// is useful when applying breaking changes.
4545 by_name,
4546};
4547const interpret_mode: InterpretMode = @field(InterpretMode, @tagName(build_options.value_interpret_mode));
4548
45344549/// Given a `Value` representing a comptime-known value of type `T`, unwrap it into an actual `T` known to the compiler.
45354550/// This is useful for accessing `std.builtin` structures received from comptime logic.
45364551/// `val` must be fully resolved.
......@@ -4583,11 +4598,20 @@ pub fn interpret(val: Value, comptime T: type, pt: Zcu.PerThread) error{ OutOfMe
45834598 else
45844599 null,
45854600
4586 .@"enum" => zcu.toEnum(T, val),
4601 .@"enum" => switch (interpret_mode) {
4602 .direct => {
4603 const int = val.getUnsignedInt(zcu) orelse return error.TypeMismatch;
4604 return std.meta.intToEnum(T, int) catch error.TypeMismatch;
4605 },
4606 .by_name => {
4607 const field_index = ty.enumTagFieldIndex(val, zcu) orelse return error.TypeMismatch;
4608 const field_name = ty.enumFieldName(field_index, zcu);
4609 return std.meta.stringToEnum(T, field_name.toSlice(ip)) orelse error.TypeMismatch;
4610 },
4611 },
45874612
45884613 .@"union" => |@"union"| {
4589 const union_obj = zcu.typeToUnion(ty) orelse return error.TypeMismatch;
4590 if (union_obj.field_types.len != @"union".fields.len) return error.TypeMismatch;
4614 // No need to handle `interpret_mode`, because the `.@"enum"` handling already deals with it.
45914615 const tag_val = val.unionTag(zcu) orelse return error.TypeMismatch;
45924616 const tag = try tag_val.interpret(@"union".tag_type.?, pt);
45934617 return switch (tag) {
......@@ -4599,14 +4623,28 @@ pub fn interpret(val: Value, comptime T: type, pt: Zcu.PerThread) error{ OutOfMe
45994623 };
46004624 },
46014625
4602 .@"struct" => |@"struct"| {
4603 if (ty.structFieldCount(zcu) != @"struct".fields.len) return error.TypeMismatch;
4604 var result: T = undefined;
4605 inline for (@"struct".fields, 0..) |field, field_idx| {
4606 const field_val = try val.fieldValue(pt, field_idx);
4607 @field(result, field.name) = try field_val.interpret(field.type, pt);
4608 }
4609 return result;
4626 .@"struct" => |@"struct"| switch (interpret_mode) {
4627 .direct => {
4628 if (ty.structFieldCount(zcu) != @"struct".fields.len) return error.TypeMismatch;
4629 var result: T = undefined;
4630 inline for (@"struct".fields, 0..) |field, field_idx| {
4631 const field_val = try val.fieldValue(pt, field_idx);
4632 @field(result, field.name) = try field_val.interpret(field.type, pt);
4633 }
4634 return result;
4635 },
4636 .by_name => {
4637 const struct_obj = zcu.typeToStruct(ty) orelse return error.TypeMismatch;
4638 var result: T = undefined;
4639 inline for (@"struct".fields) |field| {
4640 const field_name_ip = try ip.getOrPutString(zcu.gpa, pt.tid, field.name, .no_embedded_nulls);
4641 @field(result, field.name) = if (struct_obj.nameIndex(ip, field_name_ip)) |field_idx| f: {
4642 const field_val = try val.fieldValue(pt, field_idx);
4643 break :f try field_val.interpret(field.type, pt);
4644 } else (field.defaultValue() orelse return error.TypeMismatch);
4645 }
4646 return result;
4647 },
46104648 },
46114649 };
46124650}
......@@ -4618,6 +4656,7 @@ pub fn uninterpret(val: anytype, ty: Type, pt: Zcu.PerThread) error{ OutOfMemory
46184656 const T = @TypeOf(val);
46194657
46204658 const zcu = pt.zcu;
4659 const ip = &zcu.intern_pool;
46214660 if (ty.zigTypeTag(zcu) != @typeInfo(T)) return error.TypeMismatch;
46224661
46234662 return switch (@typeInfo(T)) {
......@@ -4657,9 +4696,17 @@ pub fn uninterpret(val: anytype, ty: Type, pt: Zcu.PerThread) error{ OutOfMemory
46574696 else
46584697 try pt.nullValue(ty),
46594698
4660 .@"enum" => try pt.enumValue(ty, (try uninterpret(@intFromEnum(val), ty.intTagType(zcu), pt)).toIntern()),
4699 .@"enum" => switch (interpret_mode) {
4700 .direct => try pt.enumValue(ty, (try uninterpret(@intFromEnum(val), ty.intTagType(zcu), pt)).toIntern()),
4701 .by_name => {
4702 const field_name_ip = try ip.getOrPutString(zcu.gpa, pt.tid, @tagName(val), .no_embedded_nulls);
4703 const field_idx = ty.enumFieldIndex(field_name_ip, zcu) orelse return error.TypeMismatch;
4704 return pt.enumValueFieldIndex(ty, field_idx);
4705 },
4706 },
46614707
46624708 .@"union" => |@"union"| {
4709 // No need to handle `interpret_mode`, because the `.@"enum"` handling already deals with it.
46634710 const tag: @"union".tag_type.? = val;
46644711 const tag_val = try uninterpret(tag, ty.unionTagType(zcu).?, pt);
46654712 const field_ty = ty.unionFieldType(tag_val, zcu) orelse return error.TypeMismatch;
......@@ -4672,17 +4719,44 @@ pub fn uninterpret(val: anytype, ty: Type, pt: Zcu.PerThread) error{ OutOfMemory
46724719 };
46734720 },
46744721
4675 .@"struct" => |@"struct"| {
4676 if (ty.structFieldCount(zcu) != @"struct".fields.len) return error.TypeMismatch;
4677 var field_vals: [@"struct".fields.len]InternPool.Index = undefined;
4678 inline for (&field_vals, @"struct".fields, 0..) |*field_val, field, field_idx| {
4679 const field_ty = ty.fieldType(field_idx, zcu);
4680 field_val.* = (try uninterpret(@field(val, field.name), field_ty, pt)).toIntern();
4681 }
4682 return .fromInterned(try pt.intern(.{ .aggregate = .{
4683 .ty = ty.toIntern(),
4684 .storage = .{ .elems = &field_vals },
4685 } }));
4722 .@"struct" => |@"struct"| switch (interpret_mode) {
4723 .direct => {
4724 if (ty.structFieldCount(zcu) != @"struct".fields.len) return error.TypeMismatch;
4725 var field_vals: [@"struct".fields.len]InternPool.Index = undefined;
4726 inline for (&field_vals, @"struct".fields, 0..) |*field_val, field, field_idx| {
4727 const field_ty = ty.fieldType(field_idx, zcu);
4728 field_val.* = (try uninterpret(@field(val, field.name), field_ty, pt)).toIntern();
4729 }
4730 return .fromInterned(try pt.intern(.{ .aggregate = .{
4731 .ty = ty.toIntern(),
4732 .storage = .{ .elems = &field_vals },
4733 } }));
4734 },
4735 .by_name => {
4736 const struct_obj = zcu.typeToStruct(ty) orelse return error.TypeMismatch;
4737 const want_fields_len = struct_obj.field_types.len;
4738 const field_vals = try zcu.gpa.alloc(InternPool.Index, want_fields_len);
4739 defer zcu.gpa.free(field_vals);
4740 @memset(field_vals, .none);
4741 inline for (@"struct".fields) |field| {
4742 const field_name_ip = try ip.getOrPutString(zcu.gpa, pt.tid, field.name, .no_embedded_nulls);
4743 if (struct_obj.nameIndex(ip, field_name_ip)) |field_idx| {
4744 const field_ty = ty.fieldType(field_idx, zcu);
4745 field_vals[field_idx] = (try uninterpret(@field(val, field.name), field_ty, pt)).toIntern();
4746 }
4747 }
4748 for (field_vals, 0..) |*field_val, field_idx| {
4749 if (field_val.* == .none) {
4750 const default_init = struct_obj.field_inits.get(ip)[field_idx];
4751 if (default_init == .none) return error.TypeMismatch;
4752 field_val.* = default_init;
4753 }
4754 }
4755 return .fromInterned(try pt.intern(.{ .aggregate = .{
4756 .ty = ty.toIntern(),
4757 .storage = .{ .elems = field_vals },
4758 } }));
4759 },
46864760 },
46874761 };
46884762}
src/Zcu.zig-4
......@@ -3486,10 +3486,6 @@ pub fn funcInfo(zcu: *const Zcu, func_index: InternPool.Index) InternPool.Key.Fu
34863486 return zcu.intern_pool.toFunc(func_index);
34873487}
34883488
3489pub fn toEnum(zcu: *const Zcu, comptime E: type, val: Value) E {
3490 return zcu.intern_pool.toEnum(E, val.toIntern());
3491}
3492
34933489pub const UnionLayout = struct {
34943490 abi_size: u64,
34953491 abi_align: Alignment,
src/Zcu/PerThread.zig+3-3
......@@ -3068,7 +3068,7 @@ pub fn populateTestFunctions(
30683068 .child = test_fn_ty.toIntern(),
30693069 .flags = .{
30703070 .is_const = true,
3071 .size = .Slice,
3071 .size = .slice,
30723072 },
30733073 });
30743074 const new_init = try pt.intern(.{ .slice = .{
......@@ -3303,7 +3303,7 @@ pub fn optionalType(pt: Zcu.PerThread, child_type: InternPool.Index) Allocator.E
33033303pub fn ptrType(pt: Zcu.PerThread, info: InternPool.Key.PtrType) Allocator.Error!Type {
33043304 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
33083308 // Canonicalize non-zero alignment. If it matches the ABI alignment of the pointee
33093309 // 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
33603360 return pt.ptrType(.{
33613361 .child = child_type.toIntern(),
33623362 .flags = .{
3363 .size = .Many,
3363 .size = .many,
33643364 .is_const = true,
33653365 },
33663366 });
src/arch/aarch64/CodeGen.zig+1-1
......@@ -2398,7 +2398,7 @@ fn ptrArithmetic(
23982398
23992399 const ptr_ty = lhs_ty;
24002400 const elem_ty = switch (ptr_ty.ptrSize(zcu)) {
2401 .One => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type
2401 .one => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type
24022402 else => ptr_ty.childType(zcu),
24032403 };
24042404 const elem_size = elem_ty.abiSize(zcu);
src/arch/arm/CodeGen.zig+1-1
......@@ -3919,7 +3919,7 @@ fn ptrArithmetic(
39193919
39203920 const ptr_ty = lhs_ty;
39213921 const elem_ty = switch (ptr_ty.ptrSize(zcu)) {
3922 .One => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type
3922 .one => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type
39233923 else => ptr_ty.childType(zcu),
39243924 };
39253925 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 {
78437843 if (elem_abi_size == 1) {
78447844 const ptr: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) {
78457845 // TODO: this only handles slices stored in the stack
7846 .Slice => dst_ptr,
7847 .One => dst_ptr,
7848 .C, .Many => unreachable,
7846 .slice => dst_ptr,
7847 .one => dst_ptr,
7848 .c, .many => unreachable,
78497849 };
78507850 const len: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) {
78517851 // TODO: this only handles slices stored in the stack
7852 .Slice => dst_ptr.address().offset(8).deref(),
7853 .One => .{ .immediate = dst_ptr_ty.childType(zcu).arrayLen(zcu) },
7854 .C, .Many => unreachable,
7852 .slice => dst_ptr.address().offset(8).deref(),
7853 .one => .{ .immediate = dst_ptr_ty.childType(zcu).arrayLen(zcu) },
7854 .c, .many => unreachable,
78557855 };
78567856 const len_lock: ?RegisterLock = switch (len) {
78577857 .register => |reg| func.register_manager.lockRegAssumeUnused(reg),
......@@ -7867,8 +7867,8 @@ fn airMemset(func: *Func, inst: Air.Inst.Index, safety: bool) !void {
78677867 // Length zero requires a runtime check - so we handle arrays specially
78687868 // here to elide it.
78697869 switch (dst_ptr_ty.ptrSize(zcu)) {
7870 .Slice => return func.fail("TODO: airMemset Slices", .{}),
7871 .One => {
7870 .slice => return func.fail("TODO: airMemset Slices", .{}),
7871 .one => {
78727872 const elem_ptr_ty = try pt.singleMutPtrType(elem_ty);
78737873
78747874 const len = dst_ptr_ty.childType(zcu).arrayLen(zcu);
......@@ -7889,7 +7889,7 @@ fn airMemset(func: *Func, inst: Air.Inst.Index, safety: bool) !void {
78897889 const bytes_to_copy: MCValue = .{ .immediate = elem_abi_size * (len - 1) };
78907890 try func.genInlineMemcpy(second_elem_ptr_mcv, dst_ptr, bytes_to_copy);
78917891 },
7892 .C, .Many => unreachable,
7892 .c, .many => unreachable,
78937893 }
78947894 }
78957895 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 {
79067906 const dst_ty = func.typeOf(bin_op.lhs);
79077907
79087908 const len_mcv: MCValue = switch (dst_ty.ptrSize(zcu)) {
7909 .Slice => len: {
7909 .slice => len: {
79107910 const len_reg, const len_lock = try func.allocReg(.int);
79117911 defer func.register_manager.unlockReg(len_lock);
79127912
......@@ -7921,7 +7921,7 @@ fn airMemcpy(func: *Func, inst: Air.Inst.Index) !void {
79217921 );
79227922 break :len .{ .register = len_reg };
79237923 },
7924 .One => len: {
7924 .one => len: {
79257925 const array_ty = dst_ty.childType(zcu);
79267926 break :len .{ .immediate = array_ty.arrayLen(zcu) * array_ty.childType(zcu).abiSize(zcu) };
79277927 },
src/arch/riscv64/abi.zig+1-1
......@@ -109,7 +109,7 @@ pub fn classifySystem(ty: Type, zcu: *Zcu) [8]SystemClass {
109109 return result;
110110 },
111111 .pointer => switch (ty.ptrSize(zcu)) {
112 .Slice => {
112 .slice => {
113113 result[0] = .integer;
114114 result[1] = .integer;
115115 return result;
src/arch/sparc64/CodeGen.zig+1-1
......@@ -2953,7 +2953,7 @@ fn binOp(
29532953 .pointer => {
29542954 const ptr_ty = lhs_ty;
29552955 const elem_ty = switch (ptr_ty.ptrSize(zcu)) {
2956 .One => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type
2956 .one => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type
29572957 else => ptr_ty.childType(zcu),
29582958 };
29592959 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 {
47264726 const offset = try cg.resolveInst(bin_op.rhs);
47274727 const ptr_ty = cg.typeOf(bin_op.lhs);
47284728 const pointee_ty = switch (ptr_ty.ptrSize(zcu)) {
4729 .One => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type
4729 .one => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type
47304730 else => ptr_ty.childType(zcu),
47314731 };
47324732
......@@ -4756,12 +4756,12 @@ fn airMemset(cg: *CodeGen, inst: Air.Inst.Index, safety: bool) InnerError!void {
47564756 const ptr_ty = cg.typeOf(bin_op.lhs);
47574757 const value = try cg.resolveInst(bin_op.rhs);
47584758 const len = switch (ptr_ty.ptrSize(zcu)) {
4759 .Slice => try cg.sliceLen(ptr),
4760 .One => @as(WValue, .{ .imm32 = @as(u32, @intCast(ptr_ty.childType(zcu).arrayLen(zcu))) }),
4761 .C, .Many => unreachable,
4759 .slice => try cg.sliceLen(ptr),
4760 .one => @as(WValue, .{ .imm32 = @as(u32, @intCast(ptr_ty.childType(zcu).arrayLen(zcu))) }),
4761 .c, .many => unreachable,
47624762 };
47634763
4764 const elem_ty = if (ptr_ty.ptrSize(zcu) == .One)
4764 const elem_ty = if (ptr_ty.ptrSize(zcu) == .one)
47654765 ptr_ty.childType(zcu).childType(zcu)
47664766 else
47674767 ptr_ty.childType(zcu);
......@@ -5688,7 +5688,7 @@ fn airMemcpy(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
56885688 const src = try cg.resolveInst(bin_op.rhs);
56895689 const src_ty = cg.typeOf(bin_op.rhs);
56905690 const len = switch (dst_ty.ptrSize(zcu)) {
5691 .Slice => blk: {
5691 .slice => blk: {
56925692 const slice_len = try cg.sliceLen(dst);
56935693 if (ptr_elem_ty.abiSize(zcu) != 1) {
56945694 try cg.emitWValue(slice_len);
......@@ -5698,10 +5698,10 @@ fn airMemcpy(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
56985698 }
56995699 break :blk slice_len;
57005700 },
5701 .One => @as(WValue, .{
5701 .one => @as(WValue, .{
57025702 .imm32 = @as(u32, @intCast(ptr_elem_ty.arrayLen(zcu) * ptr_elem_ty.childType(zcu).abiSize(zcu))),
57035703 }),
5704 .C, .Many => unreachable,
5704 .c, .many => unreachable,
57055705 };
57065706 const dst_ptr = try cg.sliceOrArrayPtr(dst, dst_ty);
57075707 const src_ptr = try cg.sliceOrArrayPtr(src, src_ty);
src/arch/x86_64/CodeGen.zig+14-14
......@@ -9607,13 +9607,13 @@ fn genMulDivBinOp(
96079607 const manyptr_u32_ty = try pt.ptrType(.{
96089608 .child = .u32_type,
96099609 .flags = .{
9610 .size = .Many,
9610 .size = .many,
96119611 },
96129612 });
96139613 const manyptr_const_u32_ty = try pt.ptrType(.{
96149614 .child = .u32_type,
96159615 .flags = .{
9616 .size = .Many,
9616 .size = .many,
96179617 .is_const = true,
96189618 },
96199619 });
......@@ -16614,15 +16614,15 @@ fn airMemset(self: *Self, inst: Air.Inst.Index, safety: bool) !void {
1661416614 if (elem_abi_size == 1) {
1661516615 const ptr: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) {
1661616616 // TODO: this only handles slices stored in the stack
16617 .Slice => dst_ptr,
16618 .One => dst_ptr,
16619 .C, .Many => unreachable,
16617 .slice => dst_ptr,
16618 .one => dst_ptr,
16619 .c, .many => unreachable,
1662016620 };
1662116621 const len: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) {
1662216622 // TODO: this only handles slices stored in the stack
16623 .Slice => dst_ptr.address().offset(8).deref(),
16624 .One => .{ .immediate = dst_ptr_ty.childType(zcu).arrayLen(zcu) },
16625 .C, .Many => unreachable,
16623 .slice => dst_ptr.address().offset(8).deref(),
16624 .one => .{ .immediate = dst_ptr_ty.childType(zcu).arrayLen(zcu) },
16625 .c, .many => unreachable,
1662616626 };
1662716627 const len_lock: ?RegisterLock = switch (len) {
1662816628 .register => |reg| self.register_manager.lockRegAssumeUnused(reg),
......@@ -16638,7 +16638,7 @@ fn airMemset(self: *Self, inst: Air.Inst.Index, safety: bool) !void {
1663816638 // Length zero requires a runtime check - so we handle arrays specially
1663916639 // here to elide it.
1664016640 switch (dst_ptr_ty.ptrSize(zcu)) {
16641 .Slice => {
16641 .slice => {
1664216642 const slice_ptr_ty = dst_ptr_ty.slicePtrFieldType(zcu);
1664316643
1664416644 // TODO: this only handles slices stored in the stack
......@@ -16681,7 +16681,7 @@ fn airMemset(self: *Self, inst: Air.Inst.Index, safety: bool) !void {
1668116681
1668216682 self.performReloc(skip_reloc);
1668316683 },
16684 .One => {
16684 .one => {
1668516685 const elem_ptr_ty = try pt.singleMutPtrType(elem_ty);
1668616686
1668716687 const len = dst_ptr_ty.childType(zcu).arrayLen(zcu);
......@@ -16704,7 +16704,7 @@ fn airMemset(self: *Self, inst: Air.Inst.Index, safety: bool) !void {
1670416704 const bytes_to_copy: MCValue = .{ .immediate = elem_abi_size * (len - 1) };
1670516705 try self.genInlineMemcpy(second_elem_ptr_mcv, dst_ptr, bytes_to_copy);
1670616706 },
16707 .C, .Many => unreachable,
16707 .c, .many => unreachable,
1670816708 }
1670916709 }
1671016710 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 {
1673516735 defer if (src_ptr_lock) |lock| self.register_manager.unlockReg(lock);
1673616736
1673716737 const len: MCValue = switch (dst_ptr_ty.ptrSize(zcu)) {
16738 .Slice => len: {
16738 .slice => len: {
1673916739 const len_reg = try self.register_manager.allocReg(null, abi.RegisterClass.gp);
1674016740 const len_lock = self.register_manager.lockRegAssumeUnused(len_reg);
1674116741 defer self.register_manager.unlockReg(len_lock);
......@@ -16748,11 +16748,11 @@ fn airMemcpy(self: *Self, inst: Air.Inst.Index) !void {
1674816748 );
1674916749 break :len .{ .register = len_reg };
1675016750 },
16751 .One => len: {
16751 .one => len: {
1675216752 const array_ty = dst_ptr_ty.childType(zcu);
1675316753 break :len .{ .immediate = array_ty.arrayLen(zcu) * array_ty.childType(zcu).abiSize(zcu) };
1675416754 },
16755 .C, .Many => unreachable,
16755 .c, .many => unreachable,
1675616756 };
1675716757 const len_lock: ?RegisterLock = switch (len) {
1675816758 .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
108108 var result = [1]Class{.none} ** 8;
109109 switch (ty.zigTypeTag(zcu)) {
110110 .pointer => switch (ty.ptrSize(zcu)) {
111 .Slice => {
111 .slice => {
112112 result[0] = .integer;
113113 result[1] = .integer;
114114 return result;
src/clang.zig+1-1
......@@ -177,7 +177,7 @@ pub const ASTUnit = opaque {
177177 extern fn ZigClangASTUnit_visitLocalTopLevelDecls(
178178 *ASTUnit,
179179 context: ?*anyopaque,
180 Fn: ?*const fn (?*anyopaque, *const Decl) callconv(.C) bool,
180 Fn: ?*const fn (?*anyopaque, *const Decl) callconv(.c) bool,
181181 ) bool;
182182
183183 pub const getLocalPreprocessingEntities_begin = ZigClangASTUnit_getLocalPreprocessingEntities_begin;
src/codegen.zig+1-1
......@@ -945,7 +945,7 @@ pub fn genTypedValue(
945945 switch (ty.zigTypeTag(zcu)) {
946946 .void => return .{ .mcv = .none },
947947 .pointer => switch (ty.ptrSize(zcu)) {
948 .Slice => {},
948 .slice => {},
949949 else => switch (val.toIntern()) {
950950 .null_value => {
951951 return .{ .mcv = .{ .immediate = 0 } };
src/codegen/c.zig+19-19
......@@ -1589,14 +1589,14 @@ pub const DeclGen = struct {
15891589 try dg.fmtIntLiteral(try pt.undefValue(ty), location),
15901590 }),
15911591 .ptr_type => |ptr_type| switch (ptr_type.flags.size) {
1592 .One, .Many, .C => {
1592 .one, .many, .c => {
15931593 try writer.writeAll("((");
15941594 try dg.renderCType(writer, ctype);
15951595 return writer.print("){x})", .{
15961596 try dg.fmtIntLiteral(try pt.undefValue(Type.usize), .Other),
15971597 });
15981598 },
1599 .Slice => {
1599 .slice => {
16001600 if (!location.isInitializer()) {
16011601 try writer.writeByte('(');
16021602 try dg.renderCType(writer, ctype);
......@@ -3570,7 +3570,7 @@ fn airPtrElemPtr(f: *Function, inst: Air.Inst.Index) !CValue {
35703570 try f.renderType(writer, inst_ty);
35713571 try writer.writeByte(')');
35723572 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) {
35743574 // It's a pointer to an array, so we need to de-reference.
35753575 try f.writeCValueDeref(writer, ptr);
35763576 } else try f.writeCValue(writer, ptr, .Other);
......@@ -5798,8 +5798,8 @@ fn fieldLocation(
57985798 }
57995799 },
58005800 .ptr_type => |ptr_info| switch (ptr_info.flags.size) {
5801 .One, .Many, .C => unreachable,
5802 .Slice => switch (field_index) {
5801 .one, .many, .c => unreachable,
5802 .slice => switch (field_index) {
58035803 0 => return .{ .field = .{ .identifier = "ptr" } },
58045804 1 => return .{ .field = .{ .identifier = "len" } },
58055805 else => unreachable,
......@@ -6902,7 +6902,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue {
69026902
69036903 try writer.writeAll("memset(");
69046904 switch (dest_ty.ptrSize(zcu)) {
6905 .Slice => {
6905 .slice => {
69066906 try f.writeCValueMember(writer, dest_slice, .{ .identifier = "ptr" });
69076907 try writer.writeAll(", 0xaa, ");
69086908 try f.writeCValueMember(writer, dest_slice, .{ .identifier = "len" });
......@@ -6912,14 +6912,14 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue {
69126912 try writer.writeAll(");\n");
69136913 }
69146914 },
6915 .One => {
6915 .one => {
69166916 const array_ty = dest_ty.childType(zcu);
69176917 const len = array_ty.arrayLen(zcu) * elem_abi_size;
69186918
69196919 try f.writeCValue(writer, dest_slice, .FunctionArgument);
69206920 try writer.print(", 0xaa, {d});\n", .{len});
69216921 },
6922 .Many, .C => unreachable,
6922 .many, .c => unreachable,
69236923 }
69246924 try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs });
69256925 return .none;
......@@ -6932,7 +6932,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue {
69326932 const elem_ptr_ty = try pt.ptrType(.{
69336933 .child = elem_ty.toIntern(),
69346934 .flags = .{
6935 .size = .C,
6935 .size = .c,
69366936 },
69376937 });
69386938
......@@ -6946,14 +6946,14 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue {
69466946 try f.writeCValue(writer, index, .Other);
69476947 try writer.writeAll(" != ");
69486948 switch (dest_ty.ptrSize(zcu)) {
6949 .Slice => {
6949 .slice => {
69506950 try f.writeCValueMember(writer, dest_slice, .{ .identifier = "len" });
69516951 },
6952 .One => {
6952 .one => {
69536953 const array_ty = dest_ty.childType(zcu);
69546954 try writer.print("{d}", .{array_ty.arrayLen(zcu)});
69556955 },
6956 .Many, .C => unreachable,
6956 .many, .c => unreachable,
69576957 }
69586958 try writer.writeAll("; ++");
69596959 try f.writeCValue(writer, index, .Other);
......@@ -6981,7 +6981,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue {
69816981
69826982 try writer.writeAll("memset(");
69836983 switch (dest_ty.ptrSize(zcu)) {
6984 .Slice => {
6984 .slice => {
69856985 try f.writeCValueMember(writer, dest_slice, .{ .identifier = "ptr" });
69866986 try writer.writeAll(", ");
69876987 try f.writeCValue(writer, bitcasted, .FunctionArgument);
......@@ -6989,7 +6989,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue {
69896989 try f.writeCValueMember(writer, dest_slice, .{ .identifier = "len" });
69906990 try writer.writeAll(");\n");
69916991 },
6992 .One => {
6992 .one => {
69936993 const array_ty = dest_ty.childType(zcu);
69946994 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 {
69986998 try f.writeCValue(writer, bitcasted, .FunctionArgument);
69996999 try writer.print(", {d});\n", .{len});
70007000 },
7001 .Many, .C => unreachable,
7001 .many, .c => unreachable,
70027002 }
70037003 try f.freeCValue(inst, bitcasted);
70047004 try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs });
......@@ -7015,7 +7015,7 @@ fn airMemcpy(f: *Function, inst: Air.Inst.Index) !CValue {
70157015 const src_ty = f.typeOf(bin_op.rhs);
70167016 const writer = f.object.writer();
70177017
7018 if (dest_ty.ptrSize(zcu) != .One) {
7018 if (dest_ty.ptrSize(zcu) != .one) {
70197019 try writer.writeAll("if (");
70207020 try writeArrayLen(f, writer, dest_ptr, dest_ty);
70217021 try writer.writeAll(" != 0) ");
......@@ -7038,11 +7038,11 @@ fn writeArrayLen(f: *Function, writer: ArrayListWriter, dest_ptr: CValue, dest_t
70387038 const pt = f.object.dg.pt;
70397039 const zcu = pt.zcu;
70407040 switch (dest_ty.ptrSize(zcu)) {
7041 .One => try writer.print("{}", .{
7041 .one => try writer.print("{}", .{
70427042 try f.fmtIntLiteral(try pt.intValue(Type.usize, dest_ty.childType(zcu).arrayLen(zcu))),
70437043 }),
7044 .Many, .C => unreachable,
7045 .Slice => try f.writeCValueMember(writer, dest_ptr, .{ .identifier = "len" }),
7044 .many, .c => unreachable,
7045 .slice => try f.writeCValueMember(writer, dest_ptr, .{ .identifier = "len" }),
70467046 }
70477047}
70487048
src/codegen/c/Type.zig+3-3
......@@ -1458,7 +1458,7 @@ pub const Pool = struct {
14581458 _ => |ip_index| switch (ip.indexToKey(ip_index)) {
14591459 .int_type => |int_info| return pool.fromIntInfo(allocator, int_info, mod, kind),
14601460 .ptr_type => |ptr_info| switch (ptr_info.flags.size) {
1461 .One, .Many, .C => {
1461 .one, .many, .c => {
14621462 const elem_ctype = elem_ctype: {
14631463 if (ptr_info.packed_offset.host_size > 0 and
14641464 ptr_info.flags.vector_index == .none)
......@@ -1505,7 +1505,7 @@ pub const Pool = struct {
15051505 .@"volatile" = ptr_info.flags.is_volatile,
15061506 });
15071507 },
1508 .Slice => {
1508 .slice => {
15091509 const target = &mod.resolved_target.result;
15101510 var fields = [_]Info.Field{
15111511 .{
......@@ -1598,7 +1598,7 @@ pub const Pool = struct {
15981598 switch (payload_type) {
15991599 .anyerror_type => return payload_ctype,
16001600 else => switch (ip.indexToKey(payload_type)) {
1601 .ptr_type => |payload_ptr_info| if (payload_ptr_info.flags.size != .C and
1601 .ptr_type => |payload_ptr_info| if (payload_ptr_info.flags.size != .c and
16021602 !payload_ptr_info.flags.is_allowzero) return payload_ctype,
16031603 .error_set_type, .inferred_error_set_type => return payload_ctype,
16041604 else => {},
src/codegen/llvm.zig+17-17
......@@ -2109,7 +2109,7 @@ pub const Object = struct {
21092109 ptr_info.flags.is_allowzero or
21102110 ptr_info.flags.is_const or
21112111 ptr_info.flags.is_volatile or
2112 ptr_info.flags.size == .Many or ptr_info.flags.size == .C or
2112 ptr_info.flags.size == .many or ptr_info.flags.size == .c or
21132113 !Type.fromInterned(ptr_info.child).hasRuntimeBitsIgnoreComptime(zcu))
21142114 {
21152115 const bland_ptr_ty = try pt.ptrType(.{
......@@ -2120,8 +2120,8 @@ pub const Object = struct {
21202120 .flags = .{
21212121 .alignment = ptr_info.flags.alignment,
21222122 .size = switch (ptr_info.flags.size) {
2123 .Many, .C, .One => .One,
2124 .Slice => .Slice,
2123 .many, .c, .one => .one,
2124 .slice => .slice,
21252125 },
21262126 },
21272127 });
......@@ -3382,8 +3382,8 @@ pub const Object = struct {
33823382 toLlvmAddressSpace(ptr_type.flags.address_space, target),
33833383 );
33843384 break :type switch (ptr_type.flags.size) {
3385 .One, .Many, .C => ptr_ty,
3386 .Slice => try o.builder.structType(.normal, &.{
3385 .one, .many, .c => ptr_ty,
3386 .slice => try o.builder.structType(.normal, &.{
33873387 ptr_ty,
33883388 try o.lowerType(Type.usize),
33893389 }),
......@@ -6988,7 +6988,7 @@ pub const FuncGen = struct {
69886988 const zcu = pt.zcu;
69896989 const llvm_usize = try o.lowerType(Type.usize);
69906990 switch (ty.ptrSize(zcu)) {
6991 .Slice => {
6991 .slice => {
69926992 const len = try fg.wip.extractValue(ptr, &.{1}, "");
69936993 const elem_ty = ty.childType(zcu);
69946994 const abi_size = elem_ty.abiSize(zcu);
......@@ -6996,13 +6996,13 @@ pub const FuncGen = struct {
69966996 const abi_size_llvm_val = try o.builder.intValue(llvm_usize, abi_size);
69976997 return fg.wip.bin(.@"mul nuw", len, abi_size_llvm_val, "");
69986998 },
6999 .One => {
6999 .one => {
70007000 const array_ty = ty.childType(zcu);
70017001 const elem_ty = array_ty.childType(zcu);
70027002 const abi_size = elem_ty.abiSize(zcu);
70037003 return o.builder.intValue(llvm_usize, array_ty.arrayLen(zcu) * abi_size);
70047004 },
7005 .Many, .C => unreachable,
7005 .many, .c => unreachable,
70067006 }
70077007 }
70087008
......@@ -8670,11 +8670,11 @@ pub const FuncGen = struct {
86708670 const llvm_elem_ty = try o.lowerPtrElemTy(ptr_ty.childType(zcu));
86718671 switch (ptr_ty.ptrSize(zcu)) {
86728672 // 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, &.{
86748674 try o.builder.intValue(try o.lowerType(Type.usize), 0), offset,
86758675 }, ""),
8676 .C, .Many => return self.wip.gep(.inbounds, llvm_elem_ty, ptr, &.{offset}, ""),
8677 .Slice => {
8676 .c, .many => return self.wip.gep(.inbounds, llvm_elem_ty, ptr, &.{offset}, ""),
8677 .slice => {
86788678 const base = try self.wip.extractValue(ptr, &.{0}, "");
86798679 return self.wip.gep(.inbounds, llvm_elem_ty, base, &.{offset}, "");
86808680 },
......@@ -8693,11 +8693,11 @@ pub const FuncGen = struct {
86938693 const llvm_elem_ty = try o.lowerPtrElemTy(ptr_ty.childType(zcu));
86948694 switch (ptr_ty.ptrSize(zcu)) {
86958695 // 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, &.{
86978697 try o.builder.intValue(try o.lowerType(Type.usize), 0), negative_offset,
86988698 }, ""),
8699 .C, .Many => return self.wip.gep(.inbounds, llvm_elem_ty, ptr, &.{negative_offset}, ""),
8700 .Slice => {
8699 .c, .many => return self.wip.gep(.inbounds, llvm_elem_ty, ptr, &.{negative_offset}, ""),
8700 .slice => {
87018701 const base = try self.wip.extractValue(ptr, &.{0}, "");
87028702 return self.wip.gep(.inbounds, llvm_elem_ty, base, &.{negative_offset}, "");
87038703 },
......@@ -10034,9 +10034,9 @@ pub const FuncGen = struct {
1003410034
1003510035 const llvm_usize_ty = try o.lowerType(Type.usize);
1003610036 const len = switch (ptr_ty.ptrSize(zcu)) {
10037 .Slice => try self.wip.extractValue(dest_slice, &.{1}, ""),
10038 .One => try o.builder.intValue(llvm_usize_ty, ptr_ty.childType(zcu).arrayLen(zcu)),
10039 .Many, .C => unreachable,
10037 .slice => try self.wip.extractValue(dest_slice, &.{1}, ""),
10038 .one => try o.builder.intValue(llvm_usize_ty, ptr_ty.childType(zcu).arrayLen(zcu)),
10039 .many, .c => unreachable,
1004010040 };
1004110041 const elem_llvm_ty = try o.lowerType(elem_ty);
1004210042 const end_ptr = try self.wip.gep(.inbounds, elem_llvm_ty, dest_ptr, &.{len}, "");
src/codegen/llvm/Builder.zig+2-2
......@@ -8463,7 +8463,7 @@ pub const Metadata = enum(u32) {
84638463 field.* = .{
84648464 .name = name,
84658465 .type = []const u8,
8466 .default_value = null,
8466 .default_value_ptr = null,
84678467 .is_comptime = false,
84688468 .alignment = 0,
84698469 };
......@@ -8474,7 +8474,7 @@ pub const Metadata = enum(u32) {
84748474 field.* = .{
84758475 .name = name,
84768476 .type = std.fmt.Formatter(format),
8477 .default_value = null,
8477 .default_value_ptr = null,
84788478 .is_comptime = false,
84798479 .alignment = 0,
84808480 };
src/codegen/spirv.zig+8-8
......@@ -1705,13 +1705,13 @@ const NavGen = struct {
17051705 const storage_class = self.spvStorageClass(ptr_info.flags.address_space);
17061706 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) {
17091709 try self.spv.decorate(ptr_ty_id, .{ .ArrayStride = .{
17101710 .array_stride = @intCast(child_ty.abiSize(zcu)),
17111711 } });
17121712 }
17131713
1714 if (ptr_info.flags.size != .Slice) {
1714 if (ptr_info.flags.size != .slice) {
17151715 return ptr_ty_id;
17161716 }
17171717
......@@ -4399,15 +4399,15 @@ const NavGen = struct {
43994399 const result_ty_id = try self.resolveType(result_ty, .direct);
44004400
44014401 switch (ptr_ty.ptrSize(zcu)) {
4402 .One => {
4402 .one => {
44034403 // Pointer to array
44044404 // TODO: Is this correct?
44054405 return try self.accessChainId(result_ty_id, ptr_id, &.{offset_id});
44064406 },
4407 .C, .Many => {
4407 .c, .many => {
44084408 return try self.ptrAccessChain(result_ty_id, ptr_id, offset_id, &.{});
44094409 },
4410 .Slice => {
4410 .slice => {
44114411 // TODO: This is probably incorrect. A slice should be returned here, though this is what llvm does.
44124412 const slice_ptr_id = try self.extractField(result_ty, ptr_id, 0);
44134413 return try self.ptrAccessChain(result_ty_id, slice_ptr_id, offset_id, &.{});
......@@ -4989,15 +4989,15 @@ const NavGen = struct {
49894989 const pt = self.pt;
49904990 const zcu = pt.zcu;
49914991 switch (ty.ptrSize(zcu)) {
4992 .Slice => return self.extractField(Type.usize, operand_id, 1),
4993 .One => {
4992 .slice => return self.extractField(Type.usize, operand_id, 1),
4993 .one => {
49944994 const array_ty = ty.childType(zcu);
49954995 const elem_ty = array_ty.childType(zcu);
49964996 const abi_size = elem_ty.abiSize(zcu);
49974997 const size = array_ty.arrayLenIncludingSentinel(zcu) * abi_size;
49984998 return try self.constInt(Type.usize, size, .direct);
49994999 },
5000 .Many, .C => unreachable,
5000 .many, .c => unreachable,
50015001 }
50025002 }
50035003
src/codegen/spirv/Section.zig+2-2
......@@ -159,7 +159,7 @@ pub fn writeOperand(section: *Section, comptime Operand: type, operand: Operand)
159159 section.writeOperand(info.child, child);
160160 },
161161 .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.
163163 for (operand) |item| {
164164 section.writeOperand(info.child, item);
165165 }
......@@ -292,7 +292,7 @@ fn operandSize(comptime Operand: type, operand: Operand) usize {
292292 .@"enum" => 1,
293293 .optional => |info| if (operand) |child| operandSize(info.child, child) else 0,
294294 .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.
296296 var total: usize = 0;
297297 for (operand) |item| {
298298 total += operandSize(info.child, item);
src/crash_report.zig+1-1
......@@ -190,7 +190,7 @@ pub fn attachSegfaultHandler() void {
190190 debug.updateSegfaultHandler(&act);
191191}
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 {
194194 // TODO: use alarm() here to prevent infinite loops
195195 PanicSwitch.preDispatch();
196196
src/link/Dwarf.zig+2-2
......@@ -3182,7 +3182,7 @@ fn updateLazyType(
31823182 try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?);
31833183 },
31843184 .ptr_type => |ptr_type| switch (ptr_type.flags.size) {
3185 .One, .Many, .C => {
3185 .one, .many, .c => {
31863186 const ptr_child_type: Type = .fromInterned(ptr_type.child);
31873187 try wip_nav.abbrevCode(if (ptr_type.sentinel == .none) .ptr_type else .ptr_sentinel_type);
31883188 try wip_nav.strp(name);
......@@ -3210,7 +3210,7 @@ fn updateLazyType(
32103210 try wip_nav.refType(ptr_child_type);
32113211 }
32123212 },
3213 .Slice => {
3213 .slice => {
32143214 try wip_nav.abbrevCode(.generated_struct_type);
32153215 try wip_nav.strp(name);
32163216 try uleb128(diw, ty.abiSize(zcu));
src/link/tapi/yaml.zig+4-4
......@@ -248,7 +248,7 @@ pub const Value = union(enum) {
248248 .array => return encode(arena, &input),
249249
250250 .pointer => |info| switch (info.size) {
251 .One => switch (@typeInfo(info.child)) {
251 .one => switch (@typeInfo(info.child)) {
252252 .array => |child_info| {
253253 const Slice = []const child_info.child;
254254 return encode(arena, @as(Slice, input));
......@@ -257,7 +257,7 @@ pub const Value = union(enum) {
257257 @compileError("Unhandled type: {s}" ++ @typeName(info.child));
258258 },
259259 },
260 .Slice => {
260 .slice => {
261261 if (info.child == u8) {
262262 return Value{ .string = try arena.dupe(u8, input) };
263263 }
......@@ -357,7 +357,7 @@ pub const Yaml = struct {
357357 },
358358 .pointer => |info| {
359359 switch (info.size) {
360 .Slice => {
360 .slice => {
361361 var parsed = try self.arena.allocator().alloc(info.child, self.docs.items.len);
362362 for (self.docs.items, 0..) |doc, i| {
363363 parsed[i] = try self.parseValue(info.child, doc);
......@@ -446,7 +446,7 @@ pub const Yaml = struct {
446446 const arena = self.arena.allocator();
447447
448448 switch (ptr_info.size) {
449 .Slice => {
449 .slice => {
450450 if (ptr_info.child == u8) {
451451 return value.asString();
452452 }
src/mutable_value.zig+1-1
......@@ -256,7 +256,7 @@ pub const MutableValue = union(enum) {
256256 },
257257 .pointer => {
258258 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;
260260 const ptr = try arena.create(MutableValue);
261261 const len = try arena.create(MutableValue);
262262 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 {
231231 }
232232}
233233
234fn declVisitorNamesOnlyC(context: ?*anyopaque, decl: *const clang.Decl) callconv(.C) bool {
234fn declVisitorNamesOnlyC(context: ?*anyopaque, decl: *const clang.Decl) callconv(.c) bool {
235235 const c: *Context = @ptrCast(@alignCast(context));
236236 declVisitorNamesOnly(c, decl) catch return false;
237237 return true;
238238}
239239
240fn declVisitorC(context: ?*anyopaque, decl: *const clang.Decl) callconv(.C) bool {
240fn declVisitorC(context: ?*anyopaque, decl: *const clang.Decl) callconv(.c) bool {
241241 const c: *Context = @ptrCast(@alignCast(context));
242242 declVisitor(c, decl) catch return false;
243243 return true;
stage1/config.zig.in+1
......@@ -13,3 +13,4 @@ pub const value_tracing = false;
1313pub const skip_non_native = false;
1414pub const force_gpa = false;
1515pub const dev = .core;
16pub const value_interpret_mode = .direct;
stage1/zig.h+304-143
......@@ -1,33 +1,143 @@
11#undef linux
22
3#ifndef __STDC_WANT_IEC_60559_TYPES_EXT__
4#define __STDC_WANT_IEC_60559_TYPES_EXT__
5#endif
6#include <float.h>
7#include <limits.h>
83#include <stdarg.h>
94#include <stddef.h>
10#include <stdint.h>
11
12#if _MSC_VER
13#include <intrin.h>
14#elif defined(__i386__) || defined(__x86_64__)
15#include <cpuid.h>
16#endif
175
18#if !defined(__cplusplus) && __STDC_VERSION__ <= 201710L
19#if __STDC_VERSION__ >= 199901L
20#include <stdbool.h>
6#if defined(_MSC_VER)
7#define zig_msvc
8#elif defined(__clang__)
9#define zig_clang
10#define zig_gnuc
11#elif defined(__GNUC__)
12#define zig_gnuc
13#elif defined(__IBMC__)
14#define zig_xlc
15#elif defined(__TINYC__)
16#define zig_tinyc
17#elif defined(__slimcc__)
18#define zig_slimcc
19#endif
20
21#if defined(__aarch64__) || (defined(zig_msvc) && defined(_M_ARM64))
22#define zig_aarch64
23#elif defined(__thumb__) || (defined(zig_msvc) && defined(_M_ARM))
24#define zig_thumb
25#define zig_arm
26#elif defined(__arm__)
27#define zig_arm
28#elif defined(__hexagon__)
29#define zig_hexagon
30#elif defined(__loongarch32)
31#define zig_loongarch32
32#define zig_loongarch
33#elif defined(__loongarch64)
34#define zig_loongarch64
35#define zig_loongarch
36#elif defined(__mips64)
37#define zig_mips64
38#define zig_mips
39#elif defined(__mips__)
40#define zig_mips32
41#define zig_mips
42#elif defined(__powerpc64__)
43#define zig_powerpc64
44#define zig_powerpc
45#elif defined(__powerpc__)
46#define zig_powerpc32
47#define zig_powerpc
48#elif defined(__riscv) && __riscv_xlen == 32
49#define zig_riscv32
50#define zig_riscv
51#elif defined(__riscv) && __riscv_xlen == 64
52#define zig_riscv64
53#define zig_riscv
54#elif defined(__s390x__)
55#define zig_s390x
56#elif defined(__sparc__) && defined(__arch64__)
57#define zig_sparc64
58#define zig_sparc
59#elif defined(__sparc__)
60#define zig_sparc32
61#define zig_sparc
62#elif defined(__wasm32__)
63#define zig_wasm32
64#define zig_wasm
65#elif defined(__wasm64__)
66#define zig_wasm64
67#define zig_wasm
68#elif defined(__i386__) || (defined(zig_msvc) && defined(_M_IX86))
69#define zig_x86_32
70#define zig_x86
71#elif defined (__x86_64__) || (defined(zig_msvc) && defined(_M_X64))
72#define zig_x86_64
73#define zig_x86
74#endif
75
76#if defined(zig_msvc) || __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
77#define zig_little_endian 1
78#define zig_big_endian 0
2179#else
22typedef char bool;
23#define false 0
24#define true 1
80#define zig_little_endian 0
81#define zig_big_endian 1
2582#endif
83
84#if defined(_AIX)
85#define zig_aix
86#elif defined(__MACH__)
87#define zig_darwin
88#elif defined(__DragonFly__)
89#define zig_dragonfly
90#define zig_bsd
91#elif defined(__EMSCRIPTEN__)
92#define zig_emscripten
93#elif defined(__FreeBSD__)
94#define zig_freebsd
95#define zig_bsd
96#elif defined(__Fuchsia__)
97#define zig_fuchsia
98#elif defined(__HAIKU__)
99#define zig_haiku
100#elif defined(__gnu_hurd__)
101#define zig_hurd
102#elif defined(__linux__)
103#define zig_linux
104#elif defined(__NetBSD__)
105#define zig_netbsd
106#define zig_bsd
107#elif defined(__OpenBSD__)
108#define zig_openbsd
109#define zig_bsd
110#elif defined(__SVR4)
111#define zig_solaris
112#elif defined(__wasi__)
113#define zig_wasi
114#elif defined(_WIN32)
115#define zig_windows
116#elif defined(__MVS__)
117#define zig_zos
118#endif
119
120#if defined(zig_windows)
121#define zig_coff
122#elif defined(__ELF__)
123#define zig_elf
124#elif defined(zig_zos)
125#define zig_goff
126#elif defined(zig_darwin)
127#define zig_macho
128#elif defined(zig_aix)
129#define zig_xcoff
26130#endif
27131
28132#define zig_concat(lhs, rhs) lhs##rhs
29133#define zig_expand_concat(lhs, rhs) zig_concat(lhs, rhs)
30134
135#if defined(__has_include)
136#define zig_has_include(include) __has_include(include)
137#else
138#define zig_has_include(include) 0
139#endif
140
31141#if defined(__has_builtin)
32142#define zig_has_builtin(builtin) __has_builtin(__builtin_##builtin)
33143#else
......@@ -41,37 +151,19 @@ typedef char bool;
41151#define zig_has_attribute(attribute) 0
42152#endif
43153
44#if __LITTLE_ENDIAN__ || _MSC_VER
45#define zig_little_endian 1
46#define zig_big_endian 0
47#else
48#define zig_little_endian 0
49#define zig_big_endian 1
50#endif
51
52#if __STDC_VERSION__ >= 201112L
154#if __STDC_VERSION__ >= 202311L
155#define zig_threadlocal thread_local
156#elif __STDC_VERSION__ >= 201112L
53157#define zig_threadlocal _Thread_local
54#elif defined(__GNUC__)
158#elif defined(zig_gnuc) || defined(zig_slimcc)
55159#define zig_threadlocal __thread
56#elif _MSC_VER
160#elif defined(zig_msvc)
57161#define zig_threadlocal __declspec(thread)
58162#else
59163#define zig_threadlocal zig_threadlocal_unavailable
60164#endif
61165
62#if defined(__clang__)
63#define zig_clang
64#elif defined(__GNUC__)
65#define zig_gnuc
66#endif
67
68#if defined(zig_gnuc) && (defined(__i386__) || defined(__x86_64__))
69#define zig_f128_has_miscompilations 1
70#else
71#define zig_f128_has_miscompilations 0
72#endif
73
74#if _MSC_VER
166#if defined(zig_msvc)
75167#define zig_const_arr
76168#define zig_callconv(c) __##c
77169#else
......@@ -82,7 +174,7 @@ typedef char bool;
82174#if zig_has_attribute(naked) || defined(zig_gnuc)
83175#define zig_naked_decl __attribute__((naked))
84176#define zig_naked __attribute__((naked))
85#elif defined(_MSC_VER)
177#elif defined(zig_msvc)
86178#define zig_naked_decl
87179#define zig_naked __declspec(naked)
88180#else
......@@ -104,7 +196,7 @@ typedef char bool;
104196
105197#if zig_has_attribute(noinline)
106198#define zig_never_inline __attribute__((noinline)) zig_maybe_flatten
107#elif defined(_MSC_VER)
199#elif defined(zig_msvc)
108200#define zig_never_inline __declspec(noinline) zig_maybe_flatten
109201#else
110202#define zig_never_inline zig_never_inline_unavailable
......@@ -124,46 +216,48 @@ typedef char bool;
124216
125217#if __STDC_VERSION__ >= 199901L
126218#define zig_restrict restrict
127#elif defined(__GNUC__)
219#elif defined(zig_gnuc) || defined(zig_tinyc)
128220#define zig_restrict __restrict
129221#else
130222#define zig_restrict
131223#endif
132224
133#if zig_has_attribute(aligned)
225#if zig_has_attribute(aligned) || defined(zig_tinyc)
134226#define zig_under_align(alignment) __attribute__((aligned(alignment)))
135#elif _MSC_VER
227#elif defined(zig_msvc)
136228#define zig_under_align(alignment) __declspec(align(alignment))
137229#else
138230#define zig_under_align zig_align_unavailable
139231#endif
140232
141#if __STDC_VERSION__ >= 201112L
233#if __STDC_VERSION__ >= 202311L
234#define zig_align(alignment) alignas(alignment)
235#elif __STDC_VERSION__ >= 201112L
142236#define zig_align(alignment) _Alignas(alignment)
143237#else
144238#define zig_align(alignment) zig_under_align(alignment)
145239#endif
146240
147#if zig_has_attribute(aligned)
241#if zig_has_attribute(aligned) || defined(zig_tinyc)
148242#define zig_align_fn(alignment) __attribute__((aligned(alignment)))
149#elif _MSC_VER
243#elif defined(zig_msvc)
150244#define zig_align_fn(alignment)
151245#else
152246#define zig_align_fn zig_align_fn_unavailable
153247#endif
154248
155#if zig_has_attribute(packed)
249#if zig_has_attribute(packed) || defined(zig_tinyc)
156250#define zig_packed(definition) __attribute__((packed)) definition
157#elif _MSC_VER
251#elif defined(zig_msvc)
158252#define zig_packed(definition) __pragma(pack(1)) definition __pragma(pack())
159253#else
160254#define zig_packed(definition) zig_packed_unavailable
161255#endif
162256
163#if zig_has_attribute(section)
257#if zig_has_attribute(section) || defined(zig_tinyc)
164258#define zig_linksection(name) __attribute__((section(name)))
165259#define zig_linksection_fn zig_linksection
166#elif _MSC_VER
260#elif defined(zig_msvc)
167261#define zig_linksection(name) __pragma(section(name, read, write)) __declspec(allocate(name))
168262#define zig_linksection_fn(name) __pragma(section(name, read, execute)) __declspec(code_seg(name))
169263#else
......@@ -171,8 +265,10 @@ typedef char bool;
171265#define zig_linksection_fn zig_linksection
172266#endif
173267
174#if zig_has_builtin(unreachable) || defined(zig_gnuc)
268#if zig_has_builtin(unreachable) || defined(zig_gnuc) || defined(zig_tinyc)
175269#define zig_unreachable() __builtin_unreachable()
270#elif defined(zig_msvc)
271#define zig_unreachable() __assume(0)
176272#else
177273#define zig_unreachable()
178274#endif
......@@ -183,23 +279,23 @@ typedef char bool;
183279#define zig_extern extern
184280#endif
185281
186#if _MSC_VER
187#if _M_X64
282#if defined(zig_msvc)
283#if defined(zig_x86_64)
188284#define zig_mangle_c(symbol) symbol
189#else /*_M_X64 */
285#else /* zig_x86_64 */
190286#define zig_mangle_c(symbol) "_" symbol
191#endif /*_M_X64 */
192#else /* _MSC_VER */
193#if __APPLE__
287#endif /* zig_x86_64 */
288#else /* zig_msvc */
289#if defined(zig_macho)
194290#define zig_mangle_c(symbol) "_" symbol
195#else /* __APPLE__ */
291#else /* zig_macho */
196292#define zig_mangle_c(symbol) symbol
197#endif /* __APPLE__ */
198#endif /* _MSC_VER */
293#endif /* zig_macho */
294#endif /* zig_msvc */
199295
200#if zig_has_attribute(alias) && !__APPLE__
296#if (zig_has_attribute(alias) || defined(zig_tinyc)) && !defined(zig_macho)
201297#define zig_export(symbol, name) __attribute__((alias(symbol)))
202#elif _MSC_VER
298#elif defined(zig_msvc)
203299#define zig_export(symbol, name) ; \
204300 __pragma(comment(linker, "/alternatename:" zig_mangle_c(name) "=" zig_mangle_c(symbol)))
205301#else
......@@ -209,24 +305,24 @@ typedef char bool;
209305
210306#define zig_mangled_tentative zig_mangled
211307#define zig_mangled_final zig_mangled
212#if _MSC_VER
308#if defined(zig_msvc)
213309#define zig_mangled(mangled, unmangled) ; \
214310 zig_export(#mangled, unmangled)
215311#define zig_mangled_export(mangled, unmangled, symbol) \
216312 zig_export(unmangled, #mangled) \
217313 zig_export(symbol, unmangled)
218#else /* _MSC_VER */
314#else /* zig_msvc */
219315#define zig_mangled(mangled, unmangled) __asm(zig_mangle_c(unmangled))
220316#define zig_mangled_export(mangled, unmangled, symbol) \
221317 zig_mangled_final(mangled, unmangled) \
222318 zig_export(symbol, unmangled)
223#endif /* _MSC_VER */
319#endif /* zig_msvc */
224320
225#if _MSC_VER
321#if defined(zig_msvc)
226322#define zig_import(Type, fn_name, libc_name, sig_args, call_args) zig_extern Type fn_name sig_args;\
227323 __pragma(comment(linker, "/alternatename:" zig_mangle_c(#fn_name) "=" zig_mangle_c(#libc_name)));
228324#define zig_import_builtin(Type, fn_name, libc_name, sig_args, call_args) zig_import(Type, fn_name, sig_args, call_args)
229#else /* _MSC_VER */
325#else /* zig_msvc */
230326#define zig_import(Type, fn_name, libc_name, sig_args, call_args) zig_extern Type fn_name sig_args __asm(zig_mangle_c(#libc_name));
231327#define zig_import_builtin(Type, fn_name, libc_name, sig_args, call_args) zig_extern Type libc_name sig_args; \
232328 static inline Type fn_name sig_args { return libc_name call_args; }
......@@ -235,10 +331,10 @@ typedef char bool;
235331#define zig_expand_import_0(Type, fn_name, libc_name, sig_args, call_args) zig_import(Type, fn_name, libc_name, sig_args, call_args)
236332#define zig_expand_import_1(Type, fn_name, libc_name, sig_args, call_args) zig_import_builtin(Type, fn_name, libc_name, sig_args, call_args)
237333
238#if zig_has_attribute(weak) || defined(zig_gnuc)
334#if zig_has_attribute(weak) || defined(zig_gnuc) || defined(zig_tinyc)
239335#define zig_weak_linkage __attribute__((weak))
240336#define zig_weak_linkage_fn __attribute__((weak))
241#elif _MSC_VER
337#elif defined(zig_msvc)
242338#define zig_weak_linkage __declspec(selectany)
243339#define zig_weak_linkage_fn
244340#else
......@@ -246,68 +342,94 @@ typedef char bool;
246342#define zig_weak_linkage_fn zig_weak_linkage_unavailable
247343#endif
248344
345#if defined(zig_gnuc) || defined(zig_tinyc) || defined(zig_slimcc)
346#define zig_gnuc_asm
347#endif
348
249349#if zig_has_builtin(trap)
250350#define zig_trap() __builtin_trap()
251#elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))
351#elif defined(zig_msvc)
352
353#if defined(zig_x86)
252354#define zig_trap() __ud2()
253#elif defined(_MSC_VER)
355#else
254356#define zig_trap() __fastfail(7)
255#elif defined(__thumb__)
357#endif
358
359#elif defined(zig_gnuc_asm)
360
361#if defined(zig_thumb)
256362#define zig_trap() __asm__ volatile("udf #0xfe")
257#elif defined(__arm__) || defined(__aarch64__)
363#elif defined(zig_arm) || defined(zig_aarch64)
258364#define zig_trap() __asm__ volatile("udf #0xfdee")
259#elif defined(__loongarch__) || defined(__powerpc__)
365#elif defined(zig_hexagon)
366#define zig_trap() __asm__ volatile("r27:26 = memd(#0xbadc0fee)")
367#elif defined(zig_loongarch) || defined(zig_powerpc)
260368#define zig_trap() __asm__ volatile(".word 0x0")
261#elif defined(__mips__)
369#elif defined(zig_mips)
262370#define zig_trap() __asm__ volatile(".word 0x3d")
263#elif defined(__riscv)
371#elif defined(zig_riscv)
264372#define zig_trap() __asm__ volatile("unimp")
265#elif defined(__s390__)
373#elif defined(zig_s390x)
266374#define zig_trap() __asm__ volatile("j 0x2")
267#elif defined(__sparc__)
375#elif defined(zig_sparc)
268376#define zig_trap() __asm__ volatile("illtrap")
269#elif defined(__i386__) || defined(__x86_64__)
377#elif defined(zig_x86)
270378#define zig_trap() __asm__ volatile("ud2")
271379#else
272380#define zig_trap() zig_trap_unavailable
273381#endif
274382
383#else
384#define zig_trap() zig_trap_unavailable
385#endif
386
275387#if zig_has_builtin(debugtrap)
276388#define zig_breakpoint() __builtin_debugtrap()
277#elif defined(_MSC_VER) || defined(__MINGW32__) || defined(__MINGW64__)
389#elif defined(zig_msvc)
278390#define zig_breakpoint() __debugbreak()
279#elif defined(__arm__)
391#elif defined(zig_gnuc_asm)
392
393#if defined(zig_arm)
280394#define zig_breakpoint() __asm__ volatile("bkpt #0x0")
281#elif defined(__aarch64__)
395#elif defined(zig_aarch64)
282396#define zig_breakpoint() __asm__ volatile("brk #0xf000")
283#elif defined(__loongarch__)
397#elif defined(zig_hexagon)
398#define zig_breakpoint() __asm__ volatile("brkpt")
399#elif defined(zig_loongarch)
284400#define zig_breakpoint() __asm__ volatile("break 0x0")
285#elif defined(__mips__)
401#elif defined(zig_mips)
286402#define zig_breakpoint() __asm__ volatile("break")
287#elif defined(__powerpc__)
403#elif defined(zig_powerpc)
288404#define zig_breakpoint() __asm__ volatile("trap")
289#elif defined(__riscv)
405#elif defined(zig_riscv)
290406#define zig_breakpoint() __asm__ volatile("ebreak")
291#elif defined(__s390__)
407#elif defined(zig_s390x)
292408#define zig_breakpoint() __asm__ volatile("j 0x6")
293#elif defined(__sparc__)
409#elif defined(zig_sparc)
294410#define zig_breakpoint() __asm__ volatile("ta 0x1")
295#elif defined(__i386__) || defined(__x86_64__)
411#elif defined(zig_x86)
296412#define zig_breakpoint() __asm__ volatile("int $0x3")
297413#else
298414#define zig_breakpoint() zig_breakpoint_unavailable
299415#endif
300416
301#if zig_has_builtin(return_address) || defined(zig_gnuc)
417#else
418#define zig_breakpoint() zig_breakpoint_unavailable
419#endif
420
421#if zig_has_builtin(return_address) || defined(zig_gnuc) || defined(zig_tinyc)
302422#define zig_return_address() __builtin_extract_return_addr(__builtin_return_address(0))
303#elif defined(_MSC_VER)
423#elif defined(zig_msvc)
304424#define zig_return_address() _ReturnAddress()
305425#else
306426#define zig_return_address() 0
307427#endif
308428
309#if zig_has_builtin(frame_address) || defined(zig_gnuc)
429#if zig_has_builtin(frame_address) || defined(zig_gnuc) || defined(zig_tinyc)
310430#define zig_frame_address() __builtin_frame_address(0)
431#elif defined(zig_msvc)
432#define zig_frame_address() _AddressOfReturnAddress()
311433#else
312434#define zig_frame_address() 0
313435#endif
......@@ -326,18 +448,18 @@ typedef char bool;
326448#define zig_wasm_memory_grow(index, delta) zig_unimplemented()
327449#endif
328450
329#if __STDC_VERSION__ >= 201112L
451#if __STDC_VERSION__ >= 202311L
452#define zig_noreturn [[noreturn]]
453#elif __STDC_VERSION__ >= 201112L
330454#define zig_noreturn _Noreturn
331#elif zig_has_attribute(noreturn) || defined(zig_gnuc)
455#elif zig_has_attribute(noreturn) || defined(zig_gnuc) || defined(zig_tinyc)
332456#define zig_noreturn __attribute__((noreturn))
333#elif _MSC_VER
457#elif defined(zig_msvc)
334458#define zig_noreturn __declspec(noreturn)
335459#else
336460#define zig_noreturn
337461#endif
338462
339#define zig_bitSizeOf(T) (CHAR_BIT * sizeof(T))
340
341463#define zig_compiler_rt_abbrev_uint32_t si
342464#define zig_compiler_rt_abbrev_int32_t si
343465#define zig_compiler_rt_abbrev_uint64_t di
......@@ -353,12 +475,25 @@ typedef char bool;
353475zig_extern void *memcpy (void *zig_restrict, void const *zig_restrict, size_t);
354476zig_extern void *memset (void *, int, size_t);
355477
356/* ===================== 8/16/32/64-bit Integer Support ===================== */
478/* ================ Bool and 8/16/32/64-bit Integer Support ================= */
357479
358#if __STDC_VERSION__ >= 199901L || _MSC_VER
359#include <stdint.h>
480#include <limits.h>
481
482#define zig_bitSizeOf(T) (CHAR_BIT * sizeof(T))
483
484#if __STDC_VERSION__ >= 202311L
485/* bool, true, and false are provided by the language. */
486#elif __STDC_VERSION__ >= 199901L || zig_has_include(<stdbool.h>)
487#include <stdbool.h>
360488#else
489typedef char bool;
490#define false 0
491#define true 1
492#endif
361493
494#if __STDC_VERSION__ >= 199901L || defined(zig_msvc) || zig_has_include(<stdint.h>)
495#include <stdint.h>
496#else
362497#if SCHAR_MIN == ~0x7F && SCHAR_MAX == 0x7F && UCHAR_MAX == 0xFF
363498typedef unsigned char uint8_t;
364499typedef signed char int8_t;
......@@ -1132,7 +1267,7 @@ static inline int64_t zig_bit_reverse_i64(int64_t val, uint8_t bits) {
11321267 static inline uint8_t zig_popcount_i##w(int##w##_t val, uint8_t bits) { \
11331268 return zig_popcount_u##w((uint##w##_t)val, bits); \
11341269 }
1135#if zig_has_builtin(popcount) || defined(zig_gnuc)
1270#if zig_has_builtin(popcount) || defined(zig_gnuc) || defined(zig_tinyc)
11361271#define zig_builtin_popcount(w) \
11371272 static inline uint8_t zig_popcount_u##w(uint##w##_t val, uint8_t bits) { \
11381273 (void)bits; \
......@@ -1161,7 +1296,7 @@ zig_builtin_popcount(64)
11611296 static inline uint8_t zig_ctz_i##w(int##w##_t val, uint8_t bits) { \
11621297 return zig_ctz_u##w((uint##w##_t)val, bits); \
11631298 }
1164#if zig_has_builtin(ctz) || defined(zig_gnuc)
1299#if zig_has_builtin(ctz) || defined(zig_gnuc) || defined(zig_tinyc)
11651300#define zig_builtin_ctz(w) \
11661301 static inline uint8_t zig_ctz_u##w(uint##w##_t val, uint8_t bits) { \
11671302 if (val == 0) return bits; \
......@@ -1186,7 +1321,7 @@ zig_builtin_ctz(64)
11861321 static inline uint8_t zig_clz_i##w(int##w##_t val, uint8_t bits) { \
11871322 return zig_clz_u##w((uint##w##_t)val, bits); \
11881323 }
1189#if zig_has_builtin(clz) || defined(zig_gnuc)
1324#if zig_has_builtin(clz) || defined(zig_gnuc) || defined(zig_tinyc)
11901325#define zig_builtin_clz(w) \
11911326 static inline uint8_t zig_clz_u##w(uint##w##_t val, uint8_t bits) { \
11921327 if (val == 0) return bits; \
......@@ -1254,7 +1389,7 @@ typedef struct { zig_align(16) int64_t hi; uint64_t lo; } zig_i128;
12541389#define zig_make_u128(hi, lo) ((zig_u128){ .h##i = (hi), .l##o = (lo) })
12551390#define zig_make_i128(hi, lo) ((zig_i128){ .h##i = (hi), .l##o = (lo) })
12561391
1257#if _MSC_VER /* MSVC doesn't allow struct literals in constant expressions */
1392#if defined(zig_msvc) /* MSVC doesn't allow struct literals in constant expressions */
12581393#define zig_init_u128(hi, lo) { .h##i = (hi), .l##o = (lo) }
12591394#define zig_init_i128(hi, lo) { .h##i = (hi), .l##o = (lo) }
12601395#else /* But non-MSVC doesn't like the unprotected commas */
......@@ -3016,7 +3151,13 @@ static inline uint16_t zig_popcount_big(const void *val, bool is_signed, uint16_
30163151
30173152/* ========================= Floating Point Support ========================= */
30183153
3019#if _MSC_VER
3154#ifndef __STDC_WANT_IEC_60559_TYPES_EXT__
3155#define __STDC_WANT_IEC_60559_TYPES_EXT__
3156#endif
3157
3158#include <float.h>
3159
3160#if defined(zig_msvc)
30203161float __cdecl nanf(char const* input);
30213162double __cdecl nan(char const* input);
30223163long double __cdecl nanl(char const* input);
......@@ -3078,7 +3219,7 @@ typedef uint16_t zig_f16;
30783219#undef zig_init_special_f16
30793220#define zig_init_special_f16(sign, name, arg, repr) repr
30803221#endif
3081#if __APPLE__ && (defined(__i386__) || defined(__x86_64__))
3222#if defined(zig_darwin) && defined(zig_x86)
30823223typedef uint16_t zig_compiler_rt_f16;
30833224#else
30843225typedef zig_f16 zig_compiler_rt_f16;
......@@ -3086,7 +3227,7 @@ typedef zig_f16 zig_compiler_rt_f16;
30863227
30873228#define zig_has_f32 1
30883229#define zig_libc_name_f32(name) name##f
3089#if _MSC_VER
3230#if defined(zig_msvc)
30903231#define zig_init_special_f32(sign, name, arg, repr) sign zig_make_f32(zig_msvc_flt_##name, )
30913232#else
30923233#define zig_init_special_f32(sign, name, arg, repr) zig_make_special_f32(sign, name, arg, repr)
......@@ -3118,7 +3259,7 @@ typedef uint32_t zig_f32;
31183259#define zig_has_f64 1
31193260#define zig_libc_name_f64(name) name
31203261
3121#if _MSC_VER
3262#if defined(zig_msvc)
31223263#define zig_init_special_f64(sign, name, arg, repr) sign zig_make_f64(zig_msvc_flt_##name, )
31233264#else
31243265#define zig_init_special_f64(sign, name, arg, repr) zig_make_special_f64(sign, name, arg, repr)
......@@ -3183,6 +3324,12 @@ typedef zig_u128 zig_f80;
31833324#define zig_init_special_f80(sign, name, arg, repr) repr
31843325#endif
31853326
3327#if !defined(zig_clang) && defined(zig_gnuc) && defined(zig_x86)
3328#define zig_f128_has_miscompilations 1
3329#else
3330#define zig_f128_has_miscompilations 0
3331#endif
3332
31863333#define zig_has_f128 1
31873334#define zig_libc_name_f128(name) name##q
31883335#define zig_init_special_f128(sign, name, arg, repr) zig_make_special_f128(sign, name, arg, repr)
......@@ -3211,7 +3358,7 @@ typedef __float128 zig_f128;
32113358#define zig_has_f128 0
32123359#undef zig_make_special_f128
32133360#undef zig_init_special_f128
3214#if __APPLE__ || defined(__aarch64__)
3361#if defined(zig_darwin) || defined(zig_aarch64)
32153362typedef __attribute__((__vector_size__(2 * sizeof(uint64_t)))) uint64_t zig_v2u64;
32163363zig_basic_operator(zig_v2u64, xor_v2u64, ^)
32173364#define zig_repr_f128 v2u64
......@@ -3230,10 +3377,10 @@ typedef zig_u128 zig_f128;
32303377#endif
32313378#endif
32323379
3233#if !_MSC_VER && defined(ZIG_TARGET_ABI_MSVC)
3380#if !defined(zig_msvc) && defined(ZIG_TARGET_ABI_MSVC)
32343381/* Emulate msvc abi on a gnu compiler */
32353382typedef zig_f64 zig_c_longdouble;
3236#elif _MSC_VER && !defined(ZIG_TARGET_ABI_MSVC)
3383#elif defined(zig_msvc) && !defined(ZIG_TARGET_ABI_MSVC)
32373384/* Emulate gnu abi on an msvc compiler */
32383385typedef zig_f128 zig_c_longdouble;
32393386#else
......@@ -3582,7 +3729,7 @@ zig_float_builtins(64)
35823729 res = zig_atomicrmw_expected; \
35833730} while (0)
35843731
3585#if __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_ATOMICS__)
3732#if (__STDC_VERSION__ >= 201112L || (zig_has_include(<stdatomic.h>) && !defined(zig_msvc))) && !defined(__STDC_NO_ATOMICS__)
35863733#include <stdatomic.h>
35873734typedef enum memory_order zig_memory_order;
35883735#define zig_memory_order_relaxed memory_order_relaxed
......@@ -3610,7 +3757,7 @@ typedef enum memory_order zig_memory_order;
36103757#define zig_atomicrmw_add_float zig_atomicrmw_add
36113758#undef zig_atomicrmw_sub_float
36123759#define zig_atomicrmw_sub_float zig_atomicrmw_sub
3613#elif defined(__GNUC__)
3760#elif defined(zig_gnuc)
36143761typedef int zig_memory_order;
36153762#define zig_memory_order_relaxed __ATOMIC_RELAXED
36163763#define zig_memory_order_acquire __ATOMIC_ACQUIRE
......@@ -3633,7 +3780,7 @@ typedef int zig_memory_order;
36333780#define zig_atomic_load(res, obj, order, Type, ReprType) __atomic_load (obj, &(res), order)
36343781#undef zig_atomicrmw_xchg_float
36353782#define zig_atomicrmw_xchg_float zig_atomicrmw_xchg
3636#elif _MSC_VER && (_M_IX86 || _M_X64)
3783#elif defined(zig_msvc) && defined(zig_x86)
36373784#define zig_memory_order_relaxed 0
36383785#define zig_memory_order_acquire 2
36393786#define zig_memory_order_release 3
......@@ -3653,7 +3800,7 @@ typedef int zig_memory_order;
36533800#define zig_atomicrmw_max(res, obj, arg, order, Type, ReprType) res = zig_msvc_atomicrmw_max_ ##Type(obj, arg)
36543801#define zig_atomic_store( obj, arg, order, Type, ReprType) zig_msvc_atomic_store_ ##Type(obj, arg)
36553802#define zig_atomic_load(res, obj, order, Type, ReprType) res = zig_msvc_atomic_load_ ##order##_##Type(obj)
3656/* TODO: _MSC_VER && (_M_ARM || _M_ARM64) */
3803/* TODO: zig_msvc && (zig_thumb || zig_aarch64) */
36573804#else
36583805#define zig_memory_order_relaxed 0
36593806#define zig_memory_order_acquire 2
......@@ -3676,7 +3823,7 @@ typedef int zig_memory_order;
36763823#define zig_atomic_load(res, obj, order, Type, ReprType) zig_atomics_unavailable
36773824#endif
36783825
3679#if _MSC_VER && (_M_IX86 || _M_X64)
3826#if defined(zig_msvc) && defined(zig_x86)
36803827
36813828/* TODO: zig_msvc_atomic_load should load 32 bit without interlocked on x86, and load 64 bit without interlocked on x64 */
36823829
......@@ -3773,7 +3920,7 @@ zig_msvc_atomics(i16, int16_t, short, 16, 16)
37733920zig_msvc_atomics(u32, uint32_t, long, , 32)
37743921zig_msvc_atomics(i32, int32_t, long, , 32)
37753922
3776#if _M_X64
3923#if defined(zig_x86_64)
37773924zig_msvc_atomics(u64, uint64_t, __int64, 64, 64)
37783925zig_msvc_atomics(i64, int64_t, __int64, 64, 64)
37793926#endif
......@@ -3818,11 +3965,11 @@ zig_msvc_atomics(i64, int64_t, __int64, 64, 64)
38183965 }
38193966
38203967zig_msvc_flt_atomics(f32, long, , 32)
3821#if _M_X64
3968#if defined(zig_x86_64)
38223969zig_msvc_flt_atomics(f64, int64_t, 64, 64)
38233970#endif
38243971
3825#if _M_IX86
3972#if defined(zig_x86_32)
38263973static inline void zig_msvc_atomic_barrier() {
38273974 int32_t barrier;
38283975 __asm {
......@@ -3859,7 +4006,7 @@ static inline bool zig_msvc_cmpxchg_p32(void volatile* obj, void* expected, void
38594006 if (!success) *(void**)expected = initial;
38604007 return success;
38614008}
3862#else /* _M_IX86 */
4009#else /* zig_x86_32 */
38634010static inline void* zig_msvc_atomicrmw_xchg_p64(void volatile* obj, void* arg) {
38644011 return _InterlockedExchangePointer(obj, arg);
38654012}
......@@ -3920,55 +4067,59 @@ static inline void zig_msvc_atomic_store_i128(zig_i128 volatile* obj, zig_i128 a
39204067 while (!zig_cmpxchg_weak(obj, expected, arg, zig_memory_order_seq_cst, zig_memory_order_seq_cst, i128, zig_i128));
39214068}
39224069
3923#endif /* _M_IX86 */
4070#endif /* zig_x86_32 */
39244071
3925#endif /* _MSC_VER && (_M_IX86 || _M_X64) */
4072#endif /* zig_msvc && zig_x86 */
39264073
39274074/* ======================== Special Case Intrinsics ========================= */
39284075
3929#if defined(_M_ARM) || defined(__thumb__)
4076#if defined(zig_msvc)
4077#include <intrin.h>
4078#endif
4079
4080#if defined(zig_thumb)
39304081
39314082static inline void* zig_thumb_windows_teb(void) {
39324083 void* teb = 0;
3933#if defined(_MSC_VER)
4084#if defined(zig_msvc)
39344085 teb = (void*)_MoveFromCoprocessor(15, 0, 13, 0, 2);
3935#elif defined(__GNUC__)
4086#elif defined(zig_gnuc_asm)
39364087 __asm__ ("mrc p15, 0, %[ptr], c13, c0, 2" : [ptr] "=r" (teb));
39374088#endif
39384089 return teb;
39394090}
39404091
3941#elif defined(_M_ARM64) || defined(__arch64__)
4092#elif defined(zig_aarch64)
39424093
39434094static inline void* zig_aarch64_windows_teb(void) {
39444095 void* teb = 0;
3945#if defined(_MSC_VER)
4096#if defined(zig_msvc)
39464097 teb = (void*)__readx18qword(0x0);
3947#elif defined(__GNUC__)
4098#elif defined(zig_gnuc_asm)
39484099 __asm__ ("mov %[ptr], x18" : [ptr] "=r" (teb));
39494100#endif
39504101 return teb;
39514102}
39524103
3953#elif defined(_M_IX86) || defined(__i386__)
4104#elif defined(zig_x86_32)
39544105
39554106static inline void* zig_x86_windows_teb(void) {
39564107 void* teb = 0;
3957#if defined(_MSC_VER)
4108#if defined(zig_msvc)
39584109 teb = (void*)__readfsdword(0x18);
3959#elif defined(__GNUC__)
4110#elif defined(zig_gnuc_asm)
39604111 __asm__ ("movl %%fs:0x18, %[ptr]" : [ptr] "=r" (teb));
39614112#endif
39624113 return teb;
39634114}
39644115
3965#elif defined(_M_X64) || defined(__x86_64__)
4116#elif defined(zig_x86_64)
39664117
39674118static inline void* zig_x86_64_windows_teb(void) {
39684119 void* teb = 0;
3969#if defined(_MSC_VER)
4120#if defined(zig_msvc)
39704121 teb = (void*)__readgsqword(0x30);
3971#elif defined(__GNUC__)
4122#elif defined(zig_gnuc_asm)
39724123 __asm__ ("movq %%gs:0x30, %[ptr]" : [ptr] "=r" (teb));
39734124#endif
39744125 return teb;
......@@ -3976,29 +4127,39 @@ static inline void* zig_x86_64_windows_teb(void) {
39764127
39774128#endif
39784129
3979#if (_MSC_VER && (_M_IX86 || _M_X64)) || defined(__i386__) || defined(__x86_64__)
4130#if defined(zig_x86)
39804131
39814132static inline void zig_x86_cpuid(uint32_t leaf_id, uint32_t subid, uint32_t* eax, uint32_t* ebx, uint32_t* ecx, uint32_t* edx) {
3982#if _MSC_VER
4133#if defined(zig_msvc)
39834134 int cpu_info[4];
39844135 __cpuidex(cpu_info, leaf_id, subid);
39854136 *eax = (uint32_t)cpu_info[0];
39864137 *ebx = (uint32_t)cpu_info[1];
39874138 *ecx = (uint32_t)cpu_info[2];
39884139 *edx = (uint32_t)cpu_info[3];
4140#elif defined(zig_gnuc_asm)
4141 __asm__("cpuid" : "=a"(*eax), "=b"(*ebx), "=c"(*ecx), "=d"(*edx) : "a"(leaf_id), "c"(subid));
39894142#else
3990 __cpuid_count(leaf_id, subid, *eax, *ebx, *ecx, *edx);
4143 *eax = 0;
4144 *ebx = 0;
4145 *ecx = 0;
4146 *edx = 0;
39914147#endif
39924148}
39934149
39944150static inline uint32_t zig_x86_get_xcr0(void) {
3995#if _MSC_VER
4151#if defined(zig_msvc)
39964152 return (uint32_t)_xgetbv(0);
3997#else
4153#elif defined(zig_gnuc_asm)
39984154 uint32_t eax;
39994155 uint32_t edx;
40004156 __asm__("xgetbv" : "=a"(eax), "=d"(edx) : "c"(0));
40014157 return eax;
4158#else
4159 *eax = 0;
4160 *ebx = 0;
4161 *ecx = 0;
4162 *edx = 0;
40024163#endif
40034164}
40044165
stage1/zig1.wasm
Binary files a/stage1/zig1.wasm and b/stage1/zig1.wasm differ
test/behavior/align.zig+2-2
......@@ -410,11 +410,11 @@ test "alignment of function with c calling convention" {
410410 var runtime_nothing = &nothing;
411411 _ = &runtime_nothing;
412412 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);
414414 casted2();
415415}
416416
417fn nothing() callconv(.C) void {}
417fn nothing() callconv(.c) void {}
418418
419419const DefaultAligned = struct {
420420 nevermind: u32,
test/behavior/cast.zig+5-5
......@@ -1118,7 +1118,7 @@ test "compile time int to ptr of function" {
11181118// On some architectures function pointers must be aligned.
11191119const hardcoded_fn_addr = maxInt(usize) & ~@as(usize, 0xf);
11201120pub 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
11231123fn foobar(func: PFN_void) !void {
11241124 try std.testing.expect(@intFromPtr(func) == hardcoded_fn_addr);
......@@ -1281,11 +1281,11 @@ test "implicit cast *[0]T to E![]const u8" {
12811281
12821282var global_array: [4]u8 = undefined;
12831283test "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));
12851285 try expect(@intFromPtr(f) == @intFromPtr(&global_array));
12861286}
12871287test "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));
12891289 _ = &f;
12901290 try expect(@intFromPtr(f) == @intFromPtr(&global_array));
12911291}
......@@ -1309,12 +1309,12 @@ test "*const [N]null u8 to ?[]const u8" {
13091309
13101310test "cast between [*c]T and ?[*:0]T on fn parameter" {
13111311 const S = struct {
1312 const Handler = ?fn ([*c]const u8) callconv(.C) void;
1312 const Handler = ?fn ([*c]const u8) callconv(.c) void;
13131313 fn addCallback(comptime handler: Handler) void {
13141314 _ = handler;
13151315 }
13161316
1317 fn myCallback(cstr: ?[*:0]const u8) callconv(.C) void {
1317 fn myCallback(cstr: ?[*:0]const u8) callconv(.c) void {
13181318 _ = cstr;
13191319 }
13201320
test/behavior/export_builtin.zig+1-1
......@@ -26,7 +26,7 @@ test "exporting with internal linkage" {
2626 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
2727
2828 const S = struct {
29 fn foo() callconv(.C) void {}
29 fn foo() callconv(.c) void {}
3030 comptime {
3131 @export(&foo, .{ .name = "exporting_with_internal_linkage_foo", .linkage = .internal });
3232 }
test/behavior/export_keyword.zig+1-1
......@@ -44,7 +44,7 @@ test "export function alias" {
4444 if (builtin.zig_backend == .stage2_x86_64 and builtin.target.ofmt != .elf and builtin.target.ofmt != .macho) return error.SkipZigTest;
4545
4646 _ = struct {
47 fn foo_internal() callconv(.C) u32 {
47 fn foo_internal() callconv(.c) u32 {
4848 return 123;
4949 }
5050 export const foo_exported = foo_internal;
test/behavior/extern.zig+3-3
......@@ -20,7 +20,7 @@ test "function extern symbol" {
2020 if (builtin.zig_backend == .stage2_x86_64 and builtin.target.ofmt != .elf and builtin.target.ofmt != .macho) return error.SkipZigTest;
2121 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" });
2424 try expect(a() == 4567);
2525}
2626
......@@ -35,7 +35,7 @@ test "function extern symbol matches extern decl" {
3535
3636 const S = struct {
3737 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" });
3939 };
4040 try expect(S.another_mystery_function() == 12345);
4141 try expect(S.same_thing() == 12345);
......@@ -55,5 +55,5 @@ test "coerce extern function types" {
5555 };
5656 _ = S;
5757
58 _ = @as(fn () callconv(.C) ?*u32, c_extern_function);
58 _ = @as(fn () callconv(.c) ?*u32, c_extern_function);
5959}
test/behavior/fn.zig+5-5
......@@ -153,9 +153,9 @@ test "extern struct with stdcallcc fn pointer" {
153153 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
154154
155155 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 {
159159 return 1234;
160160 }
161161 };
......@@ -169,7 +169,7 @@ const nComplexCallconv = 100;
169169fn fComplexCallconvRet(x: u32) callconv(blk: {
170170 const s: struct { n: u32 } = .{ .n = nComplexCallconv };
171171 break :blk switch (s.n) {
172 0 => .C,
172 0 => .c,
173173 1 => .Inline,
174174 else => .Unspecified,
175175 };
......@@ -435,13 +435,13 @@ test "implicit cast function to function ptr" {
435435 return 123;
436436 }
437437 };
438 var fnPtr1: *const fn () callconv(.C) c_int = S1.someFunctionThatReturnsAValue;
438 var fnPtr1: *const fn () callconv(.c) c_int = S1.someFunctionThatReturnsAValue;
439439 _ = &fnPtr1;
440440 try expect(fnPtr1() == 123);
441441 const S2 = struct {
442442 extern fn someFunctionThatReturnsAValue() c_int;
443443 };
444 var fnPtr2: *const fn () callconv(.C) c_int = S2.someFunctionThatReturnsAValue;
444 var fnPtr2: *const fn () callconv(.c) c_int = S2.someFunctionThatReturnsAValue;
445445 _ = &fnPtr2;
446446 try expect(fnPtr2() == 123);
447447}
test/behavior/generics.zig+6-6
......@@ -324,7 +324,7 @@ test "generic function instantiation non-duplicates" {
324324 for (source, 0..) |s, i| dest[i] = s;
325325 }
326326
327 fn foo() callconv(.C) void {}
327 fn foo() callconv(.c) void {}
328328 };
329329 var buffer: [100]u8 = undefined;
330330 S.copy(u8, &buffer, "hello");
......@@ -471,13 +471,13 @@ test "coerced function body has inequal value with its uncoerced body" {
471471 try expect(S.A.do() == 1234);
472472}
473473
474test "generic function returns value from callconv(.C) function" {
474test "generic function returns value from callconv(.c) function" {
475475 const S = struct {
476 fn getU8() callconv(.C) u8 {
476 fn getU8() callconv(.c) u8 {
477477 return 123;
478478 }
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 {
481481 return supplier();
482482 }
483483 };
......@@ -521,11 +521,11 @@ test "function argument tuple used as struct field" {
521521 try expect(c.t[0] == null);
522522}
523523
524test "comptime callconv(.C) function ptr uses comptime type argument" {
524test "comptime callconv(.c) function ptr uses comptime type argument" {
525525 const S = struct {
526526 fn A(
527527 comptime T: type,
528 comptime destroycb: ?*const fn (?*T) callconv(.C) void,
528 comptime destroycb: ?*const fn (?*T) callconv(.c) void,
529529 ) !void {
530530 try expect(destroycb == null);
531531 }
test/behavior/import_c_keywords.zig+1-1
......@@ -80,7 +80,7 @@ test "import c keywords" {
8080 try std.testing.expect(ptr_id == &some_non_c_keyword_constant);
8181
8282 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;
8484 try std.testing.expect(ptr_fn == &float);
8585 ptr_fn = &an_alias_of_float;
8686 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" {
891891 }{ .x = z }).m();
892892}
893893
894test "packed struct passed to callconv(.C) function" {
894test "packed struct passed to callconv(.c) function" {
895895 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
896896 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
897897 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
......@@ -906,7 +906,7 @@ test "packed struct passed to callconv(.C) function" {
906906 d: u46 = 0,
907907 };
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 {
910910 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;
911911 }
912912 };
......@@ -1270,7 +1270,7 @@ test "2-byte packed struct argument in C calling convention" {
12701270 x: u15 = 0,
12711271 y: u1 = 0,
12721272
1273 fn foo(s: @This()) callconv(.C) i32 {
1273 fn foo(s: @This()) callconv(.c) i32 {
12741274 return s.x;
12751275 }
12761276 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" {
803803 handle: i32,
804804 };
805805
806 fn makeBar(t: i32) callconv(.C) ExternBar {
806 fn makeBar(t: i32) callconv(.c) ExternBar {
807807 return ExternBar{
808808 .handle = t,
809809 };
test/behavior/tuple.zig+3-3
......@@ -141,14 +141,14 @@ test "array-like initializer for tuple types" {
141141 .{
142142 .name = "0",
143143 .type = i32,
144 .default_value = null,
144 .default_value_ptr = null,
145145 .is_comptime = false,
146146 .alignment = @alignOf(i32),
147147 },
148148 .{
149149 .name = "1",
150150 .type = u8,
151 .default_value = null,
151 .default_value_ptr = null,
152152 .is_comptime = false,
153153 .alignment = @alignOf(u8),
154154 },
......@@ -330,7 +330,7 @@ test "zero sized struct in tuple handled correctly" {
330330 .fields = &.{.{
331331 .name = "0",
332332 .type = struct {},
333 .default_value = null,
333 .default_value_ptr = null,
334334 .is_comptime = false,
335335 .alignment = 0,
336336 }},
test/behavior/tuple_declarations.zig+2-2
......@@ -20,13 +20,13 @@ test "tuple declaration type info" {
2020
2121 try expectEqualStrings(info.fields[0].name, "0");
2222 try expect(info.fields[0].type == u32);
23 try expect(@as(*const u32, @ptrCast(@alignCast(info.fields[0].default_value))).* == 1);
23 try expect(info.fields[0].defaultValue() == 1);
2424 try expect(info.fields[0].is_comptime);
2525 try expect(info.fields[0].alignment == @alignOf(u32));
2626
2727 try expectEqualStrings(info.fields[1].name, "1");
2828 try expect(info.fields[1].type == []const u8);
29 try expect(info.fields[1].default_value == null);
29 try expect(info.fields[1].defaultValue() == null);
3030 try expect(!info.fields[1].is_comptime);
3131 try expect(info.fields[1].alignment == @alignOf([]const u8));
3232 }
test/behavior/type.zig+21-21
......@@ -118,21 +118,21 @@ test "Type.Array" {
118118 .array = .{
119119 .len = 123,
120120 .child = u8,
121 .sentinel = null,
121 .sentinel_ptr = null,
122122 },
123123 }));
124124 try testing.expect([2]u32 == @Type(.{
125125 .array = .{
126126 .len = 2,
127127 .child = u32,
128 .sentinel = null,
128 .sentinel_ptr = null,
129129 },
130130 }));
131131 try testing.expect([2:0]u32 == @Type(.{
132132 .array = .{
133133 .len = 2,
134134 .child = u32,
135 .sentinel = &@as(u32, 0),
135 .sentinel_ptr = &@as(u32, 0),
136136 },
137137 }));
138138 try testTypes(&[_]type{ [1]u8, [30]usize, [7]bool });
......@@ -141,14 +141,14 @@ test "Type.Array" {
141141test "@Type create slice with null sentinel" {
142142 const Slice = @Type(.{
143143 .pointer = .{
144 .size = .Slice,
144 .size = .slice,
145145 .is_const = true,
146146 .is_volatile = false,
147147 .is_allowzero = false,
148148 .alignment = 8,
149149 .address_space = .generic,
150150 .child = *i32,
151 .sentinel = null,
151 .sentinel_ptr = null,
152152 },
153153 });
154154 try testing.expect(Slice == []align(8) const *i32);
......@@ -266,10 +266,10 @@ test "Type.Struct" {
266266 try testing.expectEqual(Type.ContainerLayout.auto, infoA.layout);
267267 try testing.expectEqualSlices(u8, "x", infoA.fields[0].name);
268268 try testing.expectEqual(u8, infoA.fields[0].type);
269 try testing.expectEqual(@as(?*const anyopaque, null), infoA.fields[0].default_value);
269 try testing.expectEqual(@as(?*const anyopaque, null), infoA.fields[0].default_value_ptr);
270270 try testing.expectEqualSlices(u8, "y", infoA.fields[1].name);
271271 try testing.expectEqual(u32, infoA.fields[1].type);
272 try testing.expectEqual(@as(?*const anyopaque, null), infoA.fields[1].default_value);
272 try testing.expectEqual(@as(?*const anyopaque, null), infoA.fields[1].default_value_ptr);
273273 try testing.expectEqualSlices(Type.Declaration, &.{}, infoA.decls);
274274 try testing.expectEqual(@as(bool, false), infoA.is_tuple);
275275
......@@ -284,10 +284,10 @@ test "Type.Struct" {
284284 try testing.expectEqual(Type.ContainerLayout.@"extern", infoB.layout);
285285 try testing.expectEqualSlices(u8, "x", infoB.fields[0].name);
286286 try testing.expectEqual(u8, infoB.fields[0].type);
287 try testing.expectEqual(@as(?*const anyopaque, null), infoB.fields[0].default_value);
287 try testing.expectEqual(@as(?*const anyopaque, null), infoB.fields[0].default_value_ptr);
288288 try testing.expectEqualSlices(u8, "y", infoB.fields[1].name);
289289 try testing.expectEqual(u32, infoB.fields[1].type);
290 try testing.expectEqual(@as(u32, 5), @as(*align(1) const u32, @ptrCast(infoB.fields[1].default_value.?)).*);
290 try testing.expectEqual(@as(u32, 5), infoB.fields[1].defaultValue().?);
291291 try testing.expectEqual(@as(usize, 0), infoB.decls.len);
292292 try testing.expectEqual(@as(bool, false), infoB.is_tuple);
293293
......@@ -296,10 +296,10 @@ test "Type.Struct" {
296296 try testing.expectEqual(Type.ContainerLayout.@"packed", infoC.layout);
297297 try testing.expectEqualSlices(u8, "x", infoC.fields[0].name);
298298 try testing.expectEqual(u8, infoC.fields[0].type);
299 try testing.expectEqual(@as(u8, 3), @as(*const u8, @ptrCast(infoC.fields[0].default_value.?)).*);
299 try testing.expectEqual(@as(u8, 3), infoC.fields[0].defaultValue().?);
300300 try testing.expectEqualSlices(u8, "y", infoC.fields[1].name);
301301 try testing.expectEqual(u32, infoC.fields[1].type);
302 try testing.expectEqual(@as(u32, 5), @as(*align(1) const u32, @ptrCast(infoC.fields[1].default_value.?)).*);
302 try testing.expectEqual(@as(u32, 5), infoC.fields[1].defaultValue().?);
303303 try testing.expectEqual(@as(usize, 0), infoC.decls.len);
304304 try testing.expectEqual(@as(bool, false), infoC.is_tuple);
305305
......@@ -309,10 +309,10 @@ test "Type.Struct" {
309309 try testing.expectEqual(Type.ContainerLayout.auto, infoD.layout);
310310 try testing.expectEqualSlices(u8, "x", infoD.fields[0].name);
311311 try testing.expectEqual(comptime_int, infoD.fields[0].type);
312 try testing.expectEqual(@as(comptime_int, 3), @as(*const comptime_int, @ptrCast(infoD.fields[0].default_value.?)).*);
312 try testing.expectEqual(@as(comptime_int, 3), infoD.fields[0].defaultValue().?);
313313 try testing.expectEqualSlices(u8, "y", infoD.fields[1].name);
314314 try testing.expectEqual(comptime_int, infoD.fields[1].type);
315 try testing.expectEqual(@as(comptime_int, 5), @as(*const comptime_int, @ptrCast(infoD.fields[1].default_value.?)).*);
315 try testing.expectEqual(@as(comptime_int, 5), infoD.fields[1].defaultValue().?);
316316 try testing.expectEqual(@as(usize, 0), infoD.decls.len);
317317 try testing.expectEqual(@as(bool, false), infoD.is_tuple);
318318
......@@ -322,10 +322,10 @@ test "Type.Struct" {
322322 try testing.expectEqual(Type.ContainerLayout.auto, infoE.layout);
323323 try testing.expectEqualSlices(u8, "0", infoE.fields[0].name);
324324 try testing.expectEqual(comptime_int, infoE.fields[0].type);
325 try testing.expectEqual(@as(comptime_int, 1), @as(*const comptime_int, @ptrCast(infoE.fields[0].default_value.?)).*);
325 try testing.expectEqual(@as(comptime_int, 1), infoE.fields[0].defaultValue().?);
326326 try testing.expectEqualSlices(u8, "1", infoE.fields[1].name);
327327 try testing.expectEqual(comptime_int, infoE.fields[1].type);
328 try testing.expectEqual(@as(comptime_int, 2), @as(*const comptime_int, @ptrCast(infoE.fields[1].default_value.?)).*);
328 try testing.expectEqual(@as(comptime_int, 2), infoE.fields[1].defaultValue().?);
329329 try testing.expectEqual(@as(usize, 0), infoE.decls.len);
330330 try testing.expectEqual(@as(bool, true), infoE.is_tuple);
331331
......@@ -548,11 +548,11 @@ test "Type.Fn" {
548548
549549 const some_opaque = opaque {};
550550 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
553553 {
554554 const fn_info = std.builtin.Type{ .@"fn" = .{
555 .calling_convention = .C,
555 .calling_convention = .c,
556556 .is_generic = false,
557557 .is_var_args = false,
558558 .return_type = void,
......@@ -582,7 +582,7 @@ test "reified struct field name from optional payload" {
582582 .fields = &.{.{
583583 .name = name,
584584 .type = u8,
585 .default_value = null,
585 .default_value_ptr = null,
586586 .is_comptime = false,
587587 .alignment = 1,
588588 }},
......@@ -628,7 +628,7 @@ test "reified struct uses @alignOf" {
628628 .{
629629 .name = "globals",
630630 .type = modules.mach.globals,
631 .default_value = null,
631 .default_value_ptr = null,
632632 .is_comptime = false,
633633 .alignment = @alignOf(modules.mach.globals),
634634 },
......@@ -688,7 +688,7 @@ test "empty struct assigned to reified struct field" {
688688 .fields = &.{.{
689689 .name = "components",
690690 .type = @TypeOf(modules.components),
691 .default_value = null,
691 .default_value_ptr = null,
692692 .is_comptime = false,
693693 .alignment = @alignOf(@TypeOf(modules.components)),
694694 }},
......@@ -738,7 +738,7 @@ test "struct field names sliced at comptime from larger string" {
738738 .alignment = 0,
739739 .name = name ++ "",
740740 .type = usize,
741 .default_value = null,
741 .default_value_ptr = null,
742742 .is_comptime = false,
743743 }};
744744 }
test/behavior/type_info.zig+25-25
......@@ -44,7 +44,7 @@ test "type info: C pointer type info" {
4444fn testCPtr() !void {
4545 const ptr_info = @typeInfo([*c]align(4) const i8);
4646 try expect(ptr_info == .pointer);
47 try expect(ptr_info.pointer.size == .C);
47 try expect(ptr_info.pointer.size == .c);
4848 try expect(ptr_info.pointer.is_const);
4949 try expect(!ptr_info.pointer.is_volatile);
5050 try expect(ptr_info.pointer.alignment == 4);
......@@ -54,8 +54,8 @@ fn testCPtr() !void {
5454test "type info: value is correctly copied" {
5555 comptime {
5656 var ptrInfo = @typeInfo([]u32);
57 ptrInfo.pointer.size = .One;
58 try expect(@typeInfo([]u32).pointer.size == .Slice);
57 ptrInfo.pointer.size = .one;
58 try expect(@typeInfo([]u32).pointer.size == .slice);
5959 }
6060}
6161
......@@ -79,12 +79,12 @@ test "type info: pointer type info" {
7979fn testPointer() !void {
8080 const u32_ptr_info = @typeInfo(*u32);
8181 try expect(u32_ptr_info == .pointer);
82 try expect(u32_ptr_info.pointer.size == .One);
82 try expect(u32_ptr_info.pointer.size == .one);
8383 try expect(u32_ptr_info.pointer.is_const == false);
8484 try expect(u32_ptr_info.pointer.is_volatile == false);
8585 try expect(u32_ptr_info.pointer.alignment == @alignOf(u32));
8686 try expect(u32_ptr_info.pointer.child == u32);
87 try expect(u32_ptr_info.pointer.sentinel == null);
87 try expect(u32_ptr_info.pointer.sentinel() == null);
8888}
8989
9090test "type info: unknown length pointer type info" {
......@@ -95,10 +95,10 @@ test "type info: unknown length pointer type info" {
9595fn testUnknownLenPtr() !void {
9696 const u32_ptr_info = @typeInfo([*]const volatile f64);
9797 try expect(u32_ptr_info == .pointer);
98 try expect(u32_ptr_info.pointer.size == .Many);
98 try expect(u32_ptr_info.pointer.size == .many);
9999 try expect(u32_ptr_info.pointer.is_const == true);
100100 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);
102102 try expect(u32_ptr_info.pointer.alignment == @alignOf(f64));
103103 try expect(u32_ptr_info.pointer.child == f64);
104104}
......@@ -111,12 +111,12 @@ test "type info: null terminated pointer type info" {
111111fn testNullTerminatedPtr() !void {
112112 const ptr_info = @typeInfo([*:0]u8);
113113 try expect(ptr_info == .pointer);
114 try expect(ptr_info.pointer.size == .Many);
114 try expect(ptr_info.pointer.size == .many);
115115 try expect(ptr_info.pointer.is_const == false);
116116 try expect(ptr_info.pointer.is_volatile == false);
117 try expect(@as(*const u8, @ptrCast(ptr_info.pointer.sentinel.?)).* == 0);
117 try expect(ptr_info.pointer.sentinel().? == 0);
118118
119 try expect(@typeInfo([:0]u8).pointer.sentinel != null);
119 try expect(@typeInfo([:0]u8).pointer.sentinel() != null);
120120}
121121
122122test "type info: slice type info" {
......@@ -127,7 +127,7 @@ test "type info: slice type info" {
127127fn testSlice() !void {
128128 const u32_slice_info = @typeInfo([]u32);
129129 try expect(u32_slice_info == .pointer);
130 try expect(u32_slice_info.pointer.size == .Slice);
130 try expect(u32_slice_info.pointer.size == .slice);
131131 try expect(u32_slice_info.pointer.is_const == false);
132132 try expect(u32_slice_info.pointer.is_volatile == false);
133133 try expect(u32_slice_info.pointer.alignment == 4);
......@@ -145,14 +145,14 @@ fn testArray() !void {
145145 try expect(info == .array);
146146 try expect(info.array.len == 42);
147147 try expect(info.array.child == u8);
148 try expect(info.array.sentinel == null);
148 try expect(info.array.sentinel() == null);
149149 }
150150
151151 {
152152 const info = @typeInfo([10:0]u8);
153153 try expect(info.array.len == 10);
154154 try expect(info.array.child == u8);
155 try expect(@as(*const u8, @ptrCast(info.array.sentinel.?)).* == @as(u8, 0));
155 try expect(info.array.sentinel().? == @as(u8, 0));
156156 try expect(@sizeOf([10:0]u8) == info.array.len + 1);
157157 }
158158}
......@@ -292,8 +292,8 @@ fn testStruct() !void {
292292 try expect(unpacked_struct_info.@"struct".is_tuple == false);
293293 try expect(unpacked_struct_info.@"struct".backing_integer == null);
294294 try expect(unpacked_struct_info.@"struct".fields[0].alignment == @alignOf(u32));
295 try expect(@as(*align(1) const u32, @ptrCast(unpacked_struct_info.@"struct".fields[0].default_value.?)).* == 4);
296 try expect(mem.eql(u8, "foobar", @as(*align(1) const *const [6:0]u8, @ptrCast(unpacked_struct_info.@"struct".fields[1].default_value.?)).*));
295 try expect(unpacked_struct_info.@"struct".fields[0].defaultValue().? == 4);
296 try expect(mem.eql(u8, "foobar", unpacked_struct_info.@"struct".fields[1].defaultValue().?));
297297}
298298
299299const TestStruct = struct {
......@@ -315,8 +315,8 @@ fn testPackedStruct() !void {
315315 try expect(struct_info.@"struct".fields.len == 4);
316316 try expect(struct_info.@"struct".fields[0].alignment == 0);
317317 try expect(struct_info.@"struct".fields[2].type == f32);
318 try expect(struct_info.@"struct".fields[2].default_value == null);
319 try expect(@as(*align(1) const u32, @ptrCast(struct_info.@"struct".fields[3].default_value.?)).* == 4);
318 try expect(struct_info.@"struct".fields[2].defaultValue() == null);
319 try expect(struct_info.@"struct".fields[3].defaultValue().? == 4);
320320 try expect(struct_info.@"struct".fields[3].alignment == 0);
321321 try expect(struct_info.@"struct".decls.len == 1);
322322}
......@@ -374,13 +374,13 @@ fn testFunction() !void {
374374 try expect(foo_fn_info.@"fn".is_var_args);
375375 try expect(foo_fn_info.@"fn".return_type.? == usize);
376376 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);
378378 try expect(foo_ptr_fn_info.pointer.is_const);
379379 try expect(!foo_ptr_fn_info.pointer.is_volatile);
380380 try expect(foo_ptr_fn_info.pointer.address_space == .generic);
381381 try expect(foo_ptr_fn_info.pointer.child == foo_fn_type);
382382 try expect(!foo_ptr_fn_info.pointer.is_allowzero);
383 try expect(foo_ptr_fn_info.pointer.sentinel == null);
383 try expect(foo_ptr_fn_info.pointer.sentinel() == null);
384384
385385 // Avoid looking at `typeInfoFooAligned` on targets which don't support function alignment.
386386 switch (builtin.target.cpu.arch) {
......@@ -401,14 +401,14 @@ fn testFunction() !void {
401401 try expect(aligned_foo_fn_info.@"fn".is_var_args);
402402 try expect(aligned_foo_fn_info.@"fn".return_type.? == usize);
403403 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);
405405 try expect(aligned_foo_ptr_fn_info.pointer.is_const);
406406 try expect(!aligned_foo_ptr_fn_info.pointer.is_volatile);
407407 try expect(aligned_foo_ptr_fn_info.pointer.alignment == 4);
408408 try expect(aligned_foo_ptr_fn_info.pointer.address_space == .generic);
409409 try expect(aligned_foo_ptr_fn_info.pointer.child == aligned_foo_fn_type);
410410 try expect(!aligned_foo_ptr_fn_info.pointer.is_allowzero);
411 try expect(aligned_foo_ptr_fn_info.pointer.sentinel == null);
411 try expect(aligned_foo_ptr_fn_info.pointer.sentinel() == null);
412412}
413413
414414extern fn typeInfoFoo(a: usize, b: bool, ...) callconv(.c) usize;
......@@ -517,7 +517,7 @@ test "type info: TypeId -> Type impl cast" {
517517
518518test "sentinel of opaque pointer type" {
519519 const c_void_info = @typeInfo(*anyopaque);
520 try expect(c_void_info.pointer.sentinel == null);
520 try expect(c_void_info.pointer.sentinel_ptr == null);
521521}
522522
523523test "@typeInfo does not force declarations into existence" {
......@@ -601,9 +601,9 @@ test "typeInfo resolves usingnamespace declarations" {
601601 try expectEqualStrings(decls[1].name, "f1");
602602}
603603
604test "value from struct @typeInfo default_value can be loaded at comptime" {
604test "value from struct @typeInfo default_value_ptr can be loaded at comptime" {
605605 comptime {
606 const a = @typeInfo(@TypeOf(.{ .foo = @as(u8, 1) })).@"struct".fields[0].default_value;
606 const a = @typeInfo(@TypeOf(.{ .foo = @as(u8, 1) })).@"struct".fields[0].default_value_ptr;
607607 try expect(@as(*const u8, @ptrCast(a)).* == 1);
608608 }
609609}
......@@ -646,7 +646,7 @@ test "@typeInfo decls ignore dependency loops" {
646646
647647test "type info of tuple of string literal default value" {
648648 const struct_field = @typeInfo(@TypeOf(.{"hi"})).@"struct".fields[0];
649 const value = @as(*align(1) const *const [2:0]u8, @ptrCast(struct_field.default_value.?)).*;
649 const value = struct_field.defaultValue().?;
650650 comptime std.debug.assert(value[0] == 'h');
651651}
652652
test/behavior/union.zig+1-1
......@@ -1229,7 +1229,7 @@ test "return an extern union from C calling convention" {
12291229 s: S,
12301230 };
12311231
1232 fn bar(arg_u: U) callconv(.C) U {
1232 fn bar(arg_u: U) callconv(.c) U {
12331233 var u = arg_u;
12341234 _ = &u;
12351235 return u;
test/behavior/var_args.zig+8-8
......@@ -108,19 +108,19 @@ test "simple variadic function" {
108108 if (builtin.cpu.arch == .s390x and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21350
109109
110110 const S = struct {
111 fn simple(...) callconv(.C) c_int {
111 fn simple(...) callconv(.c) c_int {
112112 var ap = @cVaStart();
113113 defer @cVaEnd(&ap);
114114 return @cVaArg(&ap, c_int);
115115 }
116116
117 fn compatible(_: c_int, ...) callconv(.C) c_int {
117 fn compatible(_: c_int, ...) callconv(.c) c_int {
118118 var ap = @cVaStart();
119119 defer @cVaEnd(&ap);
120120 return @cVaArg(&ap, c_int);
121121 }
122122
123 fn add(count: c_int, ...) callconv(.C) c_int {
123 fn add(count: c_int, ...) callconv(.c) c_int {
124124 var ap = @cVaStart();
125125 defer @cVaEnd(&ap);
126126 var i: usize = 0;
......@@ -169,7 +169,7 @@ test "coerce reference to var arg" {
169169 if (builtin.cpu.arch == .s390x and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21350
170170
171171 const S = struct {
172 fn addPtr(count: c_int, ...) callconv(.C) c_int {
172 fn addPtr(count: c_int, ...) callconv(.c) c_int {
173173 var ap = @cVaStart();
174174 defer @cVaEnd(&ap);
175175 var i: usize = 0;
......@@ -202,7 +202,7 @@ test "variadic functions" {
202202 if (builtin.cpu.arch == .s390x and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21350
203203
204204 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 {
206206 var ap = @cVaStart();
207207 defer @cVaEnd(&ap);
208208 vprintf(list_ptr, format, &ap);
......@@ -212,7 +212,7 @@ test "variadic functions" {
212212 list: *std.ArrayList(u8),
213213 format: [*:0]const u8,
214214 ap: *std.builtin.VaList,
215 ) callconv(.C) void {
215 ) callconv(.c) void {
216216 for (std.mem.span(format)) |c| switch (c) {
217217 's' => {
218218 const arg = @cVaArg(ap, [*:0]const u8);
......@@ -247,7 +247,7 @@ test "copy VaList" {
247247 if (builtin.cpu.arch == .s390x and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21350
248248
249249 const S = struct {
250 fn add(count: c_int, ...) callconv(.C) c_int {
250 fn add(count: c_int, ...) callconv(.c) c_int {
251251 var ap = @cVaStart();
252252 defer @cVaEnd(&ap);
253253 var copy = @cVaCopy(&ap);
......@@ -284,7 +284,7 @@ test "unused VaList arg" {
284284 if (builtin.cpu.arch == .s390x and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21350
285285
286286 const S = struct {
287 fn thirdArg(dummy: c_int, ...) callconv(.C) c_int {
287 fn thirdArg(dummy: c_int, ...) callconv(.c) c_int {
288288 _ = dummy;
289289
290290 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 {
2121
2222pub fn isSingleItemPtr(comptime T: type) bool {
2323 if (comptime is(.pointer)(T)) {
24 return @typeInfo(T).pointer.size == .One;
24 return @typeInfo(T).pointer.size == .one;
2525 }
2626 return false;
2727}
test/cases/compile_errors/invalid_pointer_with_reify_type.zig+2-4
......@@ -1,18 +1,16 @@
11export fn entry() void {
22 _ = @Type(.{ .pointer = .{
3 .size = .One,
3 .size = .one,
44 .is_const = false,
55 .is_volatile = false,
66 .alignment = 1,
77 .address_space = .generic,
88 .child = u8,
99 .is_allowzero = false,
10 .sentinel = &@as(u8, 0),
10 .sentinel_ptr = &@as(u8, 0),
1111 } });
1212}
1313
1414// error
15// backend=stage2
16// target=native
1715//
1816// :2:9: error: sentinels are only allowed on slices and unknown-length pointers
test/cases/compile_errors/non_scalar_sentinel.zig+5-5
......@@ -12,30 +12,30 @@ comptime {
1212}
1313
1414comptime {
15 _ = @Type(.{ .array = .{ .child = S, .len = 0, .sentinel = &sentinel } });
15 _ = @Type(.{ .array = .{ .child = S, .len = 0, .sentinel_ptr = &sentinel } });
1616}
1717comptime {
1818 _ = @Type(.{ .pointer = .{
19 .size = .Many,
19 .size = .slice,
2020 .is_const = false,
2121 .is_volatile = false,
2222 .alignment = @alignOf(S),
2323 .address_space = .generic,
2424 .child = S,
2525 .is_allowzero = false,
26 .sentinel = &sentinel,
26 .sentinel_ptr = &sentinel,
2727 } });
2828}
2929comptime {
3030 _ = @Type(.{ .pointer = .{
31 .size = .Many,
31 .size = .many,
3232 .is_const = false,
3333 .is_volatile = false,
3434 .alignment = @alignOf(S),
3535 .address_space = .generic,
3636 .child = S,
3737 .is_allowzero = false,
38 .sentinel = &sentinel,
38 .sentinel_ptr = &sentinel,
3939 } });
4040}
4141
test/cases/compile_errors/packed_struct_field_alignment_unavailable_for_reify_type.zig+1-3
......@@ -1,11 +1,9 @@
11export fn entry() void {
22 _ = @Type(.{ .@"struct" = .{ .layout = .@"packed", .fields = &.{
3 .{ .name = "one", .type = u4, .default_value = null, .is_comptime = false, .alignment = 2 },
3 .{ .name = "one", .type = u4, .default_value_ptr = null, .is_comptime = false, .alignment = 2 },
44 }, .decls = &.{}, .is_tuple = false } });
55}
66
77// error
8// backend=stage2
9// target=native
108//
119// :2:9: error: alignment in a packed struct field must be set to 0
test/cases/compile_errors/reify_struct.zig+5-7
......@@ -4,7 +4,7 @@ comptime {
44 .fields = &.{.{
55 .name = "foo",
66 .type = u32,
7 .default_value = null,
7 .default_value_ptr = null,
88 .is_comptime = false,
99 .alignment = 4,
1010 }},
......@@ -18,7 +18,7 @@ comptime {
1818 .fields = &.{.{
1919 .name = "3",
2020 .type = u32,
21 .default_value = null,
21 .default_value_ptr = null,
2222 .is_comptime = false,
2323 .alignment = 4,
2424 }},
......@@ -32,7 +32,7 @@ comptime {
3232 .fields = &.{.{
3333 .name = "0",
3434 .type = u32,
35 .default_value = null,
35 .default_value_ptr = null,
3636 .is_comptime = true,
3737 .alignment = 4,
3838 }},
......@@ -46,7 +46,7 @@ comptime {
4646 .fields = &.{.{
4747 .name = "0",
4848 .type = u32,
49 .default_value = null,
49 .default_value_ptr = null,
5050 .is_comptime = true,
5151 .alignment = 4,
5252 }},
......@@ -60,7 +60,7 @@ comptime {
6060 .fields = &.{.{
6161 .name = "0",
6262 .type = u32,
63 .default_value = null,
63 .default_value_ptr = null,
6464 .is_comptime = true,
6565 .alignment = 4,
6666 }},
......@@ -70,8 +70,6 @@ comptime {
7070}
7171
7272// error
73// backend=stage2
74// target=native
7573//
7674// :2:5: error: tuple cannot have non-numeric field 'foo'
7775// :16:5: error: tuple field name '3' does not match field index 0
test/cases/compile_errors/reify_type_with_invalid_field_alignment.zig+3-5
......@@ -17,7 +17,7 @@ comptime {
1717 .fields = &.{.{
1818 .name = "0",
1919 .type = u32,
20 .default_value = null,
20 .default_value_ptr = null,
2121 .is_comptime = true,
2222 .alignment = 5,
2323 }},
......@@ -29,21 +29,19 @@ comptime {
2929comptime {
3030 _ = @Type(.{
3131 .pointer = .{
32 .size = .Many,
32 .size = .many,
3333 .is_const = true,
3434 .is_volatile = false,
3535 .alignment = 7,
3636 .address_space = .generic,
3737 .child = u8,
3838 .is_allowzero = false,
39 .sentinel = null,
39 .sentinel_ptr = null,
4040 },
4141 });
4242}
4343
4444// error
45// backend=stage2
46// target=native
4745//
4846// :2:9: error: alignment value '3' is not a power of two or zero
4947// :14:9: error: alignment value '5' is not a power of two or zero
test/cases/compile_errors/reify_type_with_undefined.zig+1-1
......@@ -1,5 +1,5 @@
11comptime {
2 _ = @Type(.{ .array = .{ .len = 0, .child = u8, .sentinel = undefined } });
2 _ = @Type(.{ .array = .{ .len = 0, .child = u8, .sentinel_ptr = undefined } });
33}
44comptime {
55 _ = @Type(.{