authorgravatar for exonorid@gmail.comExonorid <exonorid@gmail.com> 2021-06-10 13:56:55-07:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2021-06-12 19:16:01+03:00
logf63338195da893bf3f50326fc69c1801182ebe80
tree4664ad2a53c23be168462cb0364e2ac0f72e2f45
parent2ba68f9f4c1de8677db35851cf9e019be132d65b

Renamed @byteOffsetOf to @offsetOf


19 files changed, 114 insertions(+), 114 deletions(-)

doc/langref.html.in+7-7
...@@ -2715,7 +2715,7 @@ test "pointer to non-bit-aligned field" {...@@ -2715,7 +2715,7 @@ test "pointer to non-bit-aligned field" {
2715}2715}
2716 {#code_end#}2716 {#code_end#}
2717 <p>2717 <p>
2718 This can be observed with {#link|@bitOffsetOf#} and {#link|byteOffsetOf#}:2718 This can be observed with {#link|@bitOffsetOf#} and {#link|offsetOf#}:
2719 </p>2719 </p>
2720 {#code_begin|test#}2720 {#code_begin|test#}
2721const std = @import("std");2721const std = @import("std");
...@@ -2733,9 +2733,9 @@ test "pointer to non-bit-aligned field" {...@@ -2733,9 +2733,9 @@ test "pointer to non-bit-aligned field" {
2733 try expect(@bitOffsetOf(BitField, "b") == 3);2733 try expect(@bitOffsetOf(BitField, "b") == 3);
2734 try expect(@bitOffsetOf(BitField, "c") == 6);2734 try expect(@bitOffsetOf(BitField, "c") == 6);
27352735
2736 try expect(@byteOffsetOf(BitField, "a") == 0);2736 try expect(@offsetOf(BitField, "a") == 0);
2737 try expect(@byteOffsetOf(BitField, "b") == 0);2737 try expect(@offsetOf(BitField, "b") == 0);
2738 try expect(@byteOffsetOf(BitField, "c") == 0);2738 try expect(@offsetOf(BitField, "c") == 0);
2739 }2739 }
2740}2740}
2741 {#code_end#}2741 {#code_end#}
...@@ -7026,7 +7026,7 @@ fn func(y: *i32) void {...@@ -7026,7 +7026,7 @@ fn func(y: *i32) void {
7026 For packed structs, non-byte-aligned fields will share a byte offset, but they will have different7026 For packed structs, non-byte-aligned fields will share a byte offset, but they will have different
7027 bit offsets.7027 bit offsets.
7028 </p>7028 </p>
7029 {#see_also|@byteOffsetOf#}7029 {#see_also|@offsetOf#}
7030 {#header_close#}7030 {#header_close#}
70317031
7032 {#header_open|@boolToInt#}7032 {#header_open|@boolToInt#}
...@@ -7106,8 +7106,8 @@ fn func(y: *i32) void {...@@ -7106,8 +7106,8 @@ fn func(y: *i32) void {
7106 </p>7106 </p>
7107 {#header_close#}7107 {#header_close#}
71087108
7109 {#header_open|@byteOffsetOf#}7109 {#header_open|@offsetOf#}
7110 <pre>{#syntax#}@byteOffsetOf(comptime T: type, comptime field_name: []const u8) comptime_int{#endsyntax#}</pre>7110 <pre>{#syntax#}@offsetOf(comptime T: type, comptime field_name: []const u8) comptime_int{#endsyntax#}</pre>
7111 <p>7111 <p>
7112 Returns the byte offset of a field relative to its containing struct.7112 Returns the byte offset of a field relative to its containing struct.
7113 </p>7113 </p>
lib/std/os/bits/darwin.zig+13-13
...@@ -188,12 +188,12 @@ pub const Kevent = extern struct {...@@ -188,12 +188,12 @@ pub const Kevent = extern struct {
188// to make sure the struct is laid out the same. These values were188// to make sure the struct is laid out the same. These values were
189// produced from C code using the offsetof macro.189// produced from C code using the offsetof macro.
190comptime {190comptime {
191 assert(@byteOffsetOf(Kevent, "ident") == 0);191 assert(@offsetOf(Kevent, "ident") == 0);
192 assert(@byteOffsetOf(Kevent, "filter") == 8);192 assert(@offsetOf(Kevent, "filter") == 8);
193 assert(@byteOffsetOf(Kevent, "flags") == 10);193 assert(@offsetOf(Kevent, "flags") == 10);
194 assert(@byteOffsetOf(Kevent, "fflags") == 12);194 assert(@offsetOf(Kevent, "fflags") == 12);
195 assert(@byteOffsetOf(Kevent, "data") == 16);195 assert(@offsetOf(Kevent, "data") == 16);
196 assert(@byteOffsetOf(Kevent, "udata") == 24);196 assert(@offsetOf(Kevent, "udata") == 24);
197}197}
198198
199pub const kevent64_s = extern struct {199pub const kevent64_s = extern struct {
...@@ -210,13 +210,13 @@ pub const kevent64_s = extern struct {...@@ -210,13 +210,13 @@ pub const kevent64_s = extern struct {
210// to make sure the struct is laid out the same. These values were210// to make sure the struct is laid out the same. These values were
211// produced from C code using the offsetof macro.211// produced from C code using the offsetof macro.
212comptime {212comptime {
213 assert(@byteOffsetOf(kevent64_s, "ident") == 0);213 assert(@offsetOf(kevent64_s, "ident") == 0);
214 assert(@byteOffsetOf(kevent64_s, "filter") == 8);214 assert(@offsetOf(kevent64_s, "filter") == 8);
215 assert(@byteOffsetOf(kevent64_s, "flags") == 10);215 assert(@offsetOf(kevent64_s, "flags") == 10);
216 assert(@byteOffsetOf(kevent64_s, "fflags") == 12);216 assert(@offsetOf(kevent64_s, "fflags") == 12);
217 assert(@byteOffsetOf(kevent64_s, "data") == 16);217 assert(@offsetOf(kevent64_s, "data") == 16);
218 assert(@byteOffsetOf(kevent64_s, "udata") == 24);218 assert(@offsetOf(kevent64_s, "udata") == 24);
219 assert(@byteOffsetOf(kevent64_s, "ext") == 32);219 assert(@offsetOf(kevent64_s, "ext") == 32);
220}220}
221221
222pub const mach_port_t = c_uint;222pub const mach_port_t = c_uint;
lib/std/os/bits/dragonfly.zig+1-1
...@@ -360,7 +360,7 @@ pub const dirent = extern struct {...@@ -360,7 +360,7 @@ pub const dirent = extern struct {
360 d_name: [256]u8,360 d_name: [256]u8,
361361
362 pub fn reclen(self: dirent) u16 {362 pub fn reclen(self: dirent) u16 {
363 return (@byteOffsetOf(dirent, "d_name") + self.d_namlen + 1 + 7) & ~@as(u16, 7);363 return (@offsetOf(dirent, "d_name") + self.d_namlen + 1 + 7) & ~@as(u16, 7);
364 }364 }
365};365};
366366
src/AstGen.zig+2-2
...@@ -2027,7 +2027,7 @@ fn unusedResultExpr(gz: *GenZir, scope: *Scope, statement: ast.Node.Index) Inner...@@ -2027,7 +2027,7 @@ fn unusedResultExpr(gz: *GenZir, scope: *Scope, statement: ast.Node.Index) Inner
2027 .shl_exact,2027 .shl_exact,
2028 .shr_exact,2028 .shr_exact,
2029 .bit_offset_of,2029 .bit_offset_of,
2030 .byte_offset_of,2030 .offset_of,
2031 .cmpxchg_strong,2031 .cmpxchg_strong,
2032 .cmpxchg_weak,2032 .cmpxchg_weak,
2033 .splat,2033 .splat,
...@@ -6816,7 +6816,7 @@ fn builtinCall(...@@ -6816,7 +6816,7 @@ fn builtinCall(
6816 .shr_exact => return shiftOp(gz, scope, rl, node, params[0], params[1], .shr_exact),6816 .shr_exact => return shiftOp(gz, scope, rl, node, params[0], params[1], .shr_exact),
68176817
6818 .bit_offset_of => return offsetOf(gz, scope, rl, node, params[0], params[1], .bit_offset_of),6818 .bit_offset_of => return offsetOf(gz, scope, rl, node, params[0], params[1], .bit_offset_of),
6819 .byte_offset_of => return offsetOf(gz, scope, rl, node, params[0], params[1], .byte_offset_of),6819 .offset_of => return offsetOf(gz, scope, rl, node, params[0], params[1], .offset_of),
68206820
6821 .c_undef => return simpleCBuiltin(gz, scope, rl, node, params[0], .c_undef),6821 .c_undef => return simpleCBuiltin(gz, scope, rl, node, params[0], .c_undef),
6822 .c_include => return simpleCBuiltin(gz, scope, rl, node, params[0], .c_include),6822 .c_include => return simpleCBuiltin(gz, scope, rl, node, params[0], .c_include),
src/BuiltinFn.zig+3-3
...@@ -17,7 +17,7 @@ pub const Tag = enum {...@@ -17,7 +17,7 @@ pub const Tag = enum {
17 mul_add,17 mul_add,
18 byte_swap,18 byte_swap,
19 bit_reverse,19 bit_reverse,
20 byte_offset_of,20 offset_of,
21 call,21 call,
22 c_define,22 c_define,
23 c_import,23 c_import,
...@@ -235,9 +235,9 @@ pub const list = list: {...@@ -235,9 +235,9 @@ pub const list = list: {
235 },235 },
236 },236 },
237 .{237 .{
238 "@byteOffsetOf",238 "@offsetOf",
239 .{239 .{
240 .tag = .byte_offset_of,240 .tag = .offset_of,
241 .param_count = 2,241 .param_count = 2,
242 },242 },
243 },243 },
src/Sema.zig+3-3
...@@ -322,7 +322,7 @@ pub fn analyzeBody(...@@ -322,7 +322,7 @@ pub fn analyzeBody(
322 .shl_exact => try sema.zirShlExact(block, inst),322 .shl_exact => try sema.zirShlExact(block, inst),
323 .shr_exact => try sema.zirShrExact(block, inst),323 .shr_exact => try sema.zirShrExact(block, inst),
324 .bit_offset_of => try sema.zirBitOffsetOf(block, inst),324 .bit_offset_of => try sema.zirBitOffsetOf(block, inst),
325 .byte_offset_of => try sema.zirByteOffsetOf(block, inst),325 .offset_of => try sema.zirOffsetOf(block, inst),
326 .cmpxchg_strong => try sema.zirCmpxchg(block, inst),326 .cmpxchg_strong => try sema.zirCmpxchg(block, inst),
327 .cmpxchg_weak => try sema.zirCmpxchg(block, inst),327 .cmpxchg_weak => try sema.zirCmpxchg(block, inst),
328 .splat => try sema.zirSplat(block, inst),328 .splat => try sema.zirSplat(block, inst),
...@@ -5860,10 +5860,10 @@ fn zirBitOffsetOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerE...@@ -5860,10 +5860,10 @@ fn zirBitOffsetOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerE
5860 return sema.mod.fail(&block.base, src, "TODO: Sema.zirBitOffsetOf", .{});5860 return sema.mod.fail(&block.base, src, "TODO: Sema.zirBitOffsetOf", .{});
5861}5861}
58625862
5863fn zirByteOffsetOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {5863fn zirOffsetOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
5864 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;5864 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
5865 const src = inst_data.src();5865 const src = inst_data.src();
5866 return sema.mod.fail(&block.base, src, "TODO: Sema.zirByteOffsetOf", .{});5866 return sema.mod.fail(&block.base, src, "TODO: Sema.zirOffsetOf", .{});
5867}5867}
58685868
5869fn zirCmpxchg(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {5869fn zirCmpxchg(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
src/Zir.zig+5-5
...@@ -859,9 +859,9 @@ pub const Inst = struct {...@@ -859,9 +859,9 @@ pub const Inst = struct {
859 /// Implements the `@bitOffsetOf` builtin.859 /// Implements the `@bitOffsetOf` builtin.
860 /// Uses the `pl_node` union field with payload `Bin`.860 /// Uses the `pl_node` union field with payload `Bin`.
861 bit_offset_of,861 bit_offset_of,
862 /// Implements the `@byteOffsetOf` builtin.862 /// Implements the `@offsetOf` builtin.
863 /// Uses the `pl_node` union field with payload `Bin`.863 /// Uses the `pl_node` union field with payload `Bin`.
864 byte_offset_of,864 offset_of,
865 /// Implements the `@cmpxchgStrong` builtin.865 /// Implements the `@cmpxchgStrong` builtin.
866 /// Uses the `pl_node` union field with payload `Cmpxchg`.866 /// Uses the `pl_node` union field with payload `Cmpxchg`.
867 cmpxchg_strong,867 cmpxchg_strong,
...@@ -1166,7 +1166,7 @@ pub const Inst = struct {...@@ -1166,7 +1166,7 @@ pub const Inst = struct {
1166 .shl_exact,1166 .shl_exact,
1167 .shr_exact,1167 .shr_exact,
1168 .bit_offset_of,1168 .bit_offset_of,
1169 .byte_offset_of,1169 .offset_of,
1170 .cmpxchg_strong,1170 .cmpxchg_strong,
1171 .cmpxchg_weak,1171 .cmpxchg_weak,
1172 .splat,1172 .splat,
...@@ -1436,7 +1436,7 @@ pub const Inst = struct {...@@ -1436,7 +1436,7 @@ pub const Inst = struct {
1436 .shr_exact = .pl_node,1436 .shr_exact = .pl_node,
14371437
1438 .bit_offset_of = .pl_node,1438 .bit_offset_of = .pl_node,
1439 .byte_offset_of = .pl_node,1439 .offset_of = .pl_node,
1440 .cmpxchg_strong = .pl_node,1440 .cmpxchg_strong = .pl_node,
1441 .cmpxchg_weak = .pl_node,1441 .cmpxchg_weak = .pl_node,
1442 .splat = .pl_node,1442 .splat = .pl_node,
...@@ -2992,7 +2992,7 @@ const Writer = struct {...@@ -2992,7 +2992,7 @@ const Writer = struct {
2992 .mod,2992 .mod,
2993 .rem,2993 .rem,
2994 .bit_offset_of,2994 .bit_offset_of,
2995 .byte_offset_of,2995 .offset_of,
2996 .splat,2996 .splat,
2997 .reduce,2997 .reduce,
2998 .atomic_load,2998 .atomic_load,
src/air.zig+1-1
...@@ -407,7 +407,7 @@ pub const Inst = struct {...@@ -407,7 +407,7 @@ pub const Inst = struct {
407 pub const convertable_br_size = std.math.max(@sizeOf(BrBlockFlat), @sizeOf(Br));407 pub const convertable_br_size = std.math.max(@sizeOf(BrBlockFlat), @sizeOf(Br));
408 pub const convertable_br_align = std.math.max(@alignOf(BrBlockFlat), @alignOf(Br));408 pub const convertable_br_align = std.math.max(@alignOf(BrBlockFlat), @alignOf(Br));
409 comptime {409 comptime {
410 assert(@byteOffsetOf(BrBlockFlat, "base") == @byteOffsetOf(Br, "base"));410 assert(@offsetOf(BrBlockFlat, "base") == @offsetOf(Br, "base"));
411 }411 }
412412
413 pub const BrBlockFlat = struct {413 pub const BrBlockFlat = struct {
src/stage1/all_types.hpp+3-3
...@@ -1768,7 +1768,7 @@ enum BuiltinFnId {...@@ -1768,7 +1768,7 @@ enum BuiltinFnId {
1768 BuiltinFnIdPtrToInt,1768 BuiltinFnIdPtrToInt,
1769 BuiltinFnIdTagName,1769 BuiltinFnIdTagName,
1770 BuiltinFnIdFieldParentPtr,1770 BuiltinFnIdFieldParentPtr,
1771 BuiltinFnIdByteOffsetOf,1771 BuiltinFnIdOffsetOf,
1772 BuiltinFnIdBitOffsetOf,1772 BuiltinFnIdBitOffsetOf,
1773 BuiltinFnIdAsyncCall,1773 BuiltinFnIdAsyncCall,
1774 BuiltinFnIdShlExact,1774 BuiltinFnIdShlExact,
...@@ -2576,7 +2576,7 @@ enum IrInstSrcId {...@@ -2576,7 +2576,7 @@ enum IrInstSrcId {
2576 IrInstSrcIdPanic,2576 IrInstSrcIdPanic,
2577 IrInstSrcIdTagName,2577 IrInstSrcIdTagName,
2578 IrInstSrcIdFieldParentPtr,2578 IrInstSrcIdFieldParentPtr,
2579 IrInstSrcIdByteOffsetOf,2579 IrInstSrcIdOffsetOf,
2580 IrInstSrcIdBitOffsetOf,2580 IrInstSrcIdBitOffsetOf,
2581 IrInstSrcIdTypeInfo,2581 IrInstSrcIdTypeInfo,
2582 IrInstSrcIdType,2582 IrInstSrcIdType,
...@@ -4047,7 +4047,7 @@ struct IrInstGenFieldParentPtr {...@@ -4047,7 +4047,7 @@ struct IrInstGenFieldParentPtr {
4047 TypeStructField *field;4047 TypeStructField *field;
4048};4048};
40494049
4050struct IrInstSrcByteOffsetOf {4050struct IrInstSrcOffsetOf {
4051 IrInstSrc base;4051 IrInstSrc base;
40524052
4053 IrInstSrc *type_value;4053 IrInstSrc *type_value;
src/stage1/astgen.cpp+8-8
...@@ -256,8 +256,8 @@ void destroy_instruction_src(IrInstSrc *inst) {...@@ -256,8 +256,8 @@ void destroy_instruction_src(IrInstSrc *inst) {
256 return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcPanic *>(inst));256 return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcPanic *>(inst));
257 case IrInstSrcIdFieldParentPtr:257 case IrInstSrcIdFieldParentPtr:
258 return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcFieldParentPtr *>(inst));258 return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcFieldParentPtr *>(inst));
259 case IrInstSrcIdByteOffsetOf:259 case IrInstSrcIdOffsetOf:
260 return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcByteOffsetOf *>(inst));260 return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcOffsetOf *>(inst));
261 case IrInstSrcIdBitOffsetOf:261 case IrInstSrcIdBitOffsetOf:
262 return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcBitOffsetOf *>(inst));262 return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcBitOffsetOf *>(inst));
263 case IrInstSrcIdTypeInfo:263 case IrInstSrcIdTypeInfo:
...@@ -777,8 +777,8 @@ static constexpr IrInstSrcId ir_inst_id(IrInstSrcFieldParentPtr *) {...@@ -777,8 +777,8 @@ static constexpr IrInstSrcId ir_inst_id(IrInstSrcFieldParentPtr *) {
777 return IrInstSrcIdFieldParentPtr;777 return IrInstSrcIdFieldParentPtr;
778}778}
779779
780static constexpr IrInstSrcId ir_inst_id(IrInstSrcByteOffsetOf *) {780static constexpr IrInstSrcId ir_inst_id(IrInstSrcOffsetOf *) {
781 return IrInstSrcIdByteOffsetOf;781 return IrInstSrcIdOffsetOf;
782}782}
783783
784static constexpr IrInstSrcId ir_inst_id(IrInstSrcBitOffsetOf *) {784static constexpr IrInstSrcId ir_inst_id(IrInstSrcBitOffsetOf *) {
...@@ -2472,10 +2472,10 @@ static IrInstSrc *ir_build_field_parent_ptr_src(Stage1AstGen *ag, Scope *scope,...@@ -2472,10 +2472,10 @@ static IrInstSrc *ir_build_field_parent_ptr_src(Stage1AstGen *ag, Scope *scope,
2472 return &inst->base;2472 return &inst->base;
2473}2473}
24742474
2475static IrInstSrc *ir_build_byte_offset_of(Stage1AstGen *ag, Scope *scope, AstNode *source_node,2475static IrInstSrc *ir_build_offset_of(Stage1AstGen *ag, Scope *scope, AstNode *source_node,
2476 IrInstSrc *type_value, IrInstSrc *field_name)2476 IrInstSrc *type_value, IrInstSrc *field_name)
2477{2477{
2478 IrInstSrcByteOffsetOf *instruction = ir_build_instruction<IrInstSrcByteOffsetOf>(ag, scope, source_node);2478 IrInstSrcOffsetOf *instruction = ir_build_instruction<IrInstSrcOffsetOf>(ag, scope, source_node);
2479 instruction->type_value = type_value;2479 instruction->type_value = type_value;
2480 instruction->field_name = field_name;2480 instruction->field_name = field_name;
24812481
...@@ -4945,7 +4945,7 @@ static IrInstSrc *astgen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode...@@ -4945,7 +4945,7 @@ static IrInstSrc *astgen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
4945 arg0_value, arg1_value, arg2_value);4945 arg0_value, arg1_value, arg2_value);
4946 return ir_lval_wrap(ag, scope, field_parent_ptr, lval, result_loc);4946 return ir_lval_wrap(ag, scope, field_parent_ptr, lval, result_loc);
4947 }4947 }
4948 case BuiltinFnIdByteOffsetOf:4948 case BuiltinFnIdOffsetOf:
4949 {4949 {
4950 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);4950 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4951 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);4951 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
...@@ -4957,7 +4957,7 @@ static IrInstSrc *astgen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode...@@ -4957,7 +4957,7 @@ static IrInstSrc *astgen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
4957 if (arg1_value == ag->codegen->invalid_inst_src)4957 if (arg1_value == ag->codegen->invalid_inst_src)
4958 return arg1_value;4958 return arg1_value;
49594959
4960 IrInstSrc *offset_of = ir_build_byte_offset_of(ag, scope, node, arg0_value, arg1_value);4960 IrInstSrc *offset_of = ir_build_offset_of(ag, scope, node, arg0_value, arg1_value);
4961 return ir_lval_wrap(ag, scope, offset_of, lval, result_loc);4961 return ir_lval_wrap(ag, scope, offset_of, lval, result_loc);
4962 }4962 }
4963 case BuiltinFnIdBitOffsetOf:4963 case BuiltinFnIdBitOffsetOf:
src/stage1/codegen.cpp+1-1
...@@ -8902,7 +8902,7 @@ static void define_builtin_fns(CodeGen *g) {...@@ -8902,7 +8902,7 @@ static void define_builtin_fns(CodeGen *g) {
8902 create_builtin_fn(g, BuiltinFnIdPtrToInt, "ptrToInt", 1);8902 create_builtin_fn(g, BuiltinFnIdPtrToInt, "ptrToInt", 1);
8903 create_builtin_fn(g, BuiltinFnIdTagName, "tagName", 1);8903 create_builtin_fn(g, BuiltinFnIdTagName, "tagName", 1);
8904 create_builtin_fn(g, BuiltinFnIdFieldParentPtr, "fieldParentPtr", 3);8904 create_builtin_fn(g, BuiltinFnIdFieldParentPtr, "fieldParentPtr", 3);
8905 create_builtin_fn(g, BuiltinFnIdByteOffsetOf, "byteOffsetOf", 2);8905 create_builtin_fn(g, BuiltinFnIdOffsetOf, "offsetOf", 2);
8906 create_builtin_fn(g, BuiltinFnIdBitOffsetOf, "bitOffsetOf", 2);8906 create_builtin_fn(g, BuiltinFnIdBitOffsetOf, "bitOffsetOf", 2);
8907 create_builtin_fn(g, BuiltinFnIdDivExact, "divExact", 2);8907 create_builtin_fn(g, BuiltinFnIdDivExact, "divExact", 2);
8908 create_builtin_fn(g, BuiltinFnIdDivTrunc, "divTrunc", 2);8908 create_builtin_fn(g, BuiltinFnIdDivTrunc, "divTrunc", 2);
src/stage1/ir.cpp+4-4
...@@ -17082,7 +17082,7 @@ static TypeStructField *validate_host_int_byte_offset(IrAnalyze *ira,...@@ -17082,7 +17082,7 @@ static TypeStructField *validate_host_int_byte_offset(IrAnalyze *ira,
17082 return field;17082 return field;
17083}17083}
1708417084
17085static IrInstGen *ir_analyze_instruction_byte_offset_of(IrAnalyze *ira, IrInstSrcByteOffsetOf *instruction) {17085static IrInstGen *ir_analyze_instruction_offset_of(IrAnalyze *ira, IrInstSrcOffsetOf *instruction) {
17086 IrInstGen *type_value = instruction->type_value->child;17086 IrInstGen *type_value = instruction->type_value->child;
17087 if (type_is_invalid(type_value->value->type))17087 if (type_is_invalid(type_value->value->type))
17088 return ira->codegen->invalid_inst_gen;17088 return ira->codegen->invalid_inst_gen;
...@@ -24368,8 +24368,8 @@ static IrInstGen *ir_analyze_instruction_base(IrAnalyze *ira, IrInstSrc *instruc...@@ -24368,8 +24368,8 @@ static IrInstGen *ir_analyze_instruction_base(IrAnalyze *ira, IrInstSrc *instruc
24368 return ir_analyze_instruction_enum_tag_name(ira, (IrInstSrcTagName *)instruction);24368 return ir_analyze_instruction_enum_tag_name(ira, (IrInstSrcTagName *)instruction);
24369 case IrInstSrcIdFieldParentPtr:24369 case IrInstSrcIdFieldParentPtr:
24370 return ir_analyze_instruction_field_parent_ptr(ira, (IrInstSrcFieldParentPtr *)instruction);24370 return ir_analyze_instruction_field_parent_ptr(ira, (IrInstSrcFieldParentPtr *)instruction);
24371 case IrInstSrcIdByteOffsetOf:24371 case IrInstSrcIdOffsetOf:
24372 return ir_analyze_instruction_byte_offset_of(ira, (IrInstSrcByteOffsetOf *)instruction);24372 return ir_analyze_instruction_offset_of(ira, (IrInstSrcOffsetOf *)instruction);
24373 case IrInstSrcIdBitOffsetOf:24373 case IrInstSrcIdBitOffsetOf:
24374 return ir_analyze_instruction_bit_offset_of(ira, (IrInstSrcBitOffsetOf *)instruction);24374 return ir_analyze_instruction_bit_offset_of(ira, (IrInstSrcBitOffsetOf *)instruction);
24375 case IrInstSrcIdTypeInfo:24375 case IrInstSrcIdTypeInfo:
...@@ -24824,7 +24824,7 @@ bool ir_inst_src_has_side_effects(IrInstSrc *instruction) {...@@ -24824,7 +24824,7 @@ bool ir_inst_src_has_side_effects(IrInstSrc *instruction) {
24824 case IrInstSrcIdTypeName:24824 case IrInstSrcIdTypeName:
24825 case IrInstSrcIdTagName:24825 case IrInstSrcIdTagName:
24826 case IrInstSrcIdFieldParentPtr:24826 case IrInstSrcIdFieldParentPtr:
24827 case IrInstSrcIdByteOffsetOf:24827 case IrInstSrcIdOffsetOf:
24828 case IrInstSrcIdBitOffsetOf:24828 case IrInstSrcIdBitOffsetOf:
24829 case IrInstSrcIdTypeInfo:24829 case IrInstSrcIdTypeInfo:
24830 case IrInstSrcIdType:24830 case IrInstSrcIdType:
src/stage1/ir_print.cpp+6-6
...@@ -287,8 +287,8 @@ const char* ir_inst_src_type_str(IrInstSrcId id) {...@@ -287,8 +287,8 @@ const char* ir_inst_src_type_str(IrInstSrcId id) {
287 return "SrcTagName";287 return "SrcTagName";
288 case IrInstSrcIdFieldParentPtr:288 case IrInstSrcIdFieldParentPtr:
289 return "SrcFieldParentPtr";289 return "SrcFieldParentPtr";
290 case IrInstSrcIdByteOffsetOf:290 case IrInstSrcIdOffsetOf:
291 return "SrcByteOffsetOf";291 return "SrcOffsetOf";
292 case IrInstSrcIdBitOffsetOf:292 case IrInstSrcIdBitOffsetOf:
293 return "SrcBitOffsetOf";293 return "SrcBitOffsetOf";
294 case IrInstSrcIdTypeInfo:294 case IrInstSrcIdTypeInfo:
...@@ -2292,8 +2292,8 @@ static void ir_print_field_parent_ptr(IrPrintGen *irp, IrInstGenFieldParentPtr *...@@ -2292,8 +2292,8 @@ static void ir_print_field_parent_ptr(IrPrintGen *irp, IrInstGenFieldParentPtr *
2292 fprintf(irp->f, ")");2292 fprintf(irp->f, ")");
2293}2293}
22942294
2295static void ir_print_byte_offset_of(IrPrintSrc *irp, IrInstSrcByteOffsetOf *instruction) {2295static void ir_print_offset_of(IrPrintSrc *irp, IrInstSrcOffsetOf *instruction) {
2296 fprintf(irp->f, "@byte_offset_of(");2296 fprintf(irp->f, "@offset_of(");
2297 ir_print_other_inst_src(irp, instruction->type_value);2297 ir_print_other_inst_src(irp, instruction->type_value);
2298 fprintf(irp->f, ",");2298 fprintf(irp->f, ",");
2299 ir_print_other_inst_src(irp, instruction->field_name);2299 ir_print_other_inst_src(irp, instruction->field_name);
...@@ -2946,8 +2946,8 @@ static void ir_print_inst_src(IrPrintSrc *irp, IrInstSrc *instruction, bool trai...@@ -2946,8 +2946,8 @@ static void ir_print_inst_src(IrPrintSrc *irp, IrInstSrc *instruction, bool trai
2946 case IrInstSrcIdFieldParentPtr:2946 case IrInstSrcIdFieldParentPtr:
2947 ir_print_field_parent_ptr(irp, (IrInstSrcFieldParentPtr *)instruction);2947 ir_print_field_parent_ptr(irp, (IrInstSrcFieldParentPtr *)instruction);
2948 break;2948 break;
2949 case IrInstSrcIdByteOffsetOf:2949 case IrInstSrcIdOffsetOf:
2950 ir_print_byte_offset_of(irp, (IrInstSrcByteOffsetOf *)instruction);2950 ir_print_offset_of(irp, (IrInstSrcOffsetOf *)instruction);
2951 break;2951 break;
2952 case IrInstSrcIdBitOffsetOf:2952 case IrInstSrcIdBitOffsetOf:
2953 ir_print_bit_offset_of(irp, (IrInstSrcBitOffsetOf *)instruction);2953 ir_print_bit_offset_of(irp, (IrInstSrcBitOffsetOf *)instruction);
src/translate_c.zig+1-1
...@@ -1426,7 +1426,7 @@ fn transSimpleOffsetOfExpr(...@@ -1426,7 +1426,7 @@ fn transSimpleOffsetOfExpr(
1426 const quoted_field_name = try std.fmt.allocPrint(c.arena, "\"{s}\"", .{raw_field_name});1426 const quoted_field_name = try std.fmt.allocPrint(c.arena, "\"{s}\"", .{raw_field_name});
1427 const field_name_node = try Tag.string_literal.create(c.arena, quoted_field_name);1427 const field_name_node = try Tag.string_literal.create(c.arena, quoted_field_name);
14281428
1429 return Tag.byte_offset_of.create(c.arena, .{1429 return Tag.offset_of.create(c.arena, .{
1430 .lhs = type_node,1430 .lhs = type_node,
1431 .rhs = field_name_node,1431 .rhs = field_name_node,
1432 });1432 });
src/translate_c/ast.zig+7-7
...@@ -158,8 +158,8 @@ pub const Node = extern union {...@@ -158,8 +158,8 @@ pub const Node = extern union {
158 ptr_cast,158 ptr_cast,
159 /// @divExact(lhs, rhs)159 /// @divExact(lhs, rhs)
160 div_exact,160 div_exact,
161 /// @byteOffsetOf(lhs, rhs)161 /// @offsetOf(lhs, rhs)
162 byte_offset_of,162 offset_of,
163 /// @shuffle(type, a, b, mask)163 /// @shuffle(type, a, b, mask)
164 shuffle,164 shuffle,
165165
...@@ -335,7 +335,7 @@ pub const Node = extern union {...@@ -335,7 +335,7 @@ pub const Node = extern union {
335 .std_meta_vector,335 .std_meta_vector,
336 .ptr_cast,336 .ptr_cast,
337 .div_exact,337 .div_exact,
338 .byte_offset_of,338 .offset_of,
339 .std_meta_cast,339 .std_meta_cast,
340 => Payload.BinOp,340 => Payload.BinOp,
341341
...@@ -1304,9 +1304,9 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex {...@@ -1304,9 +1304,9 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex {
1304 const payload = node.castTag(.div_exact).?.data;1304 const payload = node.castTag(.div_exact).?.data;
1305 return renderBuiltinCall(c, "@divExact", &.{ payload.lhs, payload.rhs });1305 return renderBuiltinCall(c, "@divExact", &.{ payload.lhs, payload.rhs });
1306 },1306 },
1307 .byte_offset_of => {1307 .offset_of => {
1308 const payload = node.castTag(.byte_offset_of).?.data;1308 const payload = node.castTag(.offset_of).?.data;
1309 return renderBuiltinCall(c, "@byteOffsetOf", &.{ payload.lhs, payload.rhs });1309 return renderBuiltinCall(c, "@offsetOf", &.{ payload.lhs, payload.rhs });
1310 },1310 },
1311 .sizeof => {1311 .sizeof => {
1312 const payload = node.castTag(.sizeof).?.data;1312 const payload = node.castTag(.sizeof).?.data;
...@@ -2274,7 +2274,7 @@ fn renderNodeGrouped(c: *Context, node: Node) !NodeIndex {...@@ -2274,7 +2274,7 @@ fn renderNodeGrouped(c: *Context, node: Node) !NodeIndex {
2274 .null_sentinel_array_type,2274 .null_sentinel_array_type,
2275 .bool_to_int,2275 .bool_to_int,
2276 .div_exact,2276 .div_exact,
2277 .byte_offset_of,2277 .offset_of,
2278 .shuffle,2278 .shuffle,
2279 => {2279 => {
2280 // no grouping needed2280 // no grouping needed
test/behavior/bugs/6781.zig+3-3
...@@ -15,7 +15,7 @@ pub const JournalHeader = packed struct {...@@ -15,7 +15,7 @@ pub const JournalHeader = packed struct {
15 assert(entry.len >= @sizeOf(JournalHeader));15 assert(entry.len >= @sizeOf(JournalHeader));
16 assert(entry.len == self.size);16 assert(entry.len == self.size);
1717
18 const checksum_offset = @byteOffsetOf(JournalHeader, "checksum");18 const checksum_offset = @offsetOf(JournalHeader, "checksum");
19 const checksum_size = @sizeOf(@TypeOf(self.checksum));19 const checksum_size = @sizeOf(@TypeOf(self.checksum));
20 assert(checksum_offset == 0 + 16 + 16);20 assert(checksum_offset == 0 + 16 + 16);
21 assert(checksum_size == 16);21 assert(checksum_size == 16);
...@@ -29,12 +29,12 @@ pub const JournalHeader = packed struct {...@@ -29,12 +29,12 @@ pub const JournalHeader = packed struct {
29 const hash_chain_root_size = @sizeOf(@TypeOf(self.hash_chain_root));29 const hash_chain_root_size = @sizeOf(@TypeOf(self.hash_chain_root));
30 assert(hash_chain_root_size == 16);30 assert(hash_chain_root_size == 16);
3131
32 const prev_hash_chain_root_offset = @byteOffsetOf(JournalHeader, "prev_hash_chain_root");32 const prev_hash_chain_root_offset = @offsetOf(JournalHeader, "prev_hash_chain_root");
33 const prev_hash_chain_root_size = @sizeOf(@TypeOf(self.prev_hash_chain_root));33 const prev_hash_chain_root_size = @sizeOf(@TypeOf(self.prev_hash_chain_root));
34 assert(prev_hash_chain_root_offset == 0 + 16);34 assert(prev_hash_chain_root_offset == 0 + 16);
35 assert(prev_hash_chain_root_size == 16);35 assert(prev_hash_chain_root_size == 16);
3636
37 const checksum_offset = @byteOffsetOf(JournalHeader, "checksum");37 const checksum_offset = @offsetOf(JournalHeader, "checksum");
38 const checksum_size = @sizeOf(@TypeOf(self.checksum));38 const checksum_size = @sizeOf(@TypeOf(self.checksum));
39 assert(checksum_offset == 0 + 16 + 16);39 assert(checksum_offset == 0 + 16 + 16);
40 assert(checksum_size == 16);40 assert(checksum_size == 16);
test/behavior/sizeof_and_typeof.zig+37-37
...@@ -34,71 +34,71 @@ const P = packed struct {...@@ -34,71 +34,71 @@ const P = packed struct {
34 i: u7,34 i: u7,
35};35};
3636
37test "@byteOffsetOf" {37test "@offsetOf" {
38 // Packed structs have fixed memory layout38 // Packed structs have fixed memory layout
39 try expect(@byteOffsetOf(P, "a") == 0);39 try expect(@offsetOf(P, "a") == 0);
40 try expect(@byteOffsetOf(P, "b") == 1);40 try expect(@offsetOf(P, "b") == 1);
41 try expect(@byteOffsetOf(P, "c") == 5);41 try expect(@offsetOf(P, "c") == 5);
42 try expect(@byteOffsetOf(P, "d") == 6);42 try expect(@offsetOf(P, "d") == 6);
43 try expect(@byteOffsetOf(P, "e") == 6);43 try expect(@offsetOf(P, "e") == 6);
44 try expect(@byteOffsetOf(P, "f") == 7);44 try expect(@offsetOf(P, "f") == 7);
45 try expect(@byteOffsetOf(P, "g") == 9);45 try expect(@offsetOf(P, "g") == 9);
46 try expect(@byteOffsetOf(P, "h") == 11);46 try expect(@offsetOf(P, "h") == 11);
47 try expect(@byteOffsetOf(P, "i") == 12);47 try expect(@offsetOf(P, "i") == 12);
4848
49 // Normal struct fields can be moved/padded49 // Normal struct fields can be moved/padded
50 var a: A = undefined;50 var a: A = undefined;
51 try expect(@ptrToInt(&a.a) - @ptrToInt(&a) == @byteOffsetOf(A, "a"));51 try expect(@ptrToInt(&a.a) - @ptrToInt(&a) == @offsetOf(A, "a"));
52 try expect(@ptrToInt(&a.b) - @ptrToInt(&a) == @byteOffsetOf(A, "b"));52 try expect(@ptrToInt(&a.b) - @ptrToInt(&a) == @offsetOf(A, "b"));
53 try expect(@ptrToInt(&a.c) - @ptrToInt(&a) == @byteOffsetOf(A, "c"));53 try expect(@ptrToInt(&a.c) - @ptrToInt(&a) == @offsetOf(A, "c"));
54 try expect(@ptrToInt(&a.d) - @ptrToInt(&a) == @byteOffsetOf(A, "d"));54 try expect(@ptrToInt(&a.d) - @ptrToInt(&a) == @offsetOf(A, "d"));
55 try expect(@ptrToInt(&a.e) - @ptrToInt(&a) == @byteOffsetOf(A, "e"));55 try expect(@ptrToInt(&a.e) - @ptrToInt(&a) == @offsetOf(A, "e"));
56 try expect(@ptrToInt(&a.f) - @ptrToInt(&a) == @byteOffsetOf(A, "f"));56 try expect(@ptrToInt(&a.f) - @ptrToInt(&a) == @offsetOf(A, "f"));
57 try expect(@ptrToInt(&a.g) - @ptrToInt(&a) == @byteOffsetOf(A, "g"));57 try expect(@ptrToInt(&a.g) - @ptrToInt(&a) == @offsetOf(A, "g"));
58 try expect(@ptrToInt(&a.h) - @ptrToInt(&a) == @byteOffsetOf(A, "h"));58 try expect(@ptrToInt(&a.h) - @ptrToInt(&a) == @offsetOf(A, "h"));
59 try expect(@ptrToInt(&a.i) - @ptrToInt(&a) == @byteOffsetOf(A, "i"));59 try expect(@ptrToInt(&a.i) - @ptrToInt(&a) == @offsetOf(A, "i"));
60}60}
6161
62test "@byteOffsetOf packed struct, array length not power of 2 or multiple of native pointer width in bytes" {62test "@offsetOf packed struct, array length not power of 2 or multiple of native pointer width in bytes" {
63 const p3a_len = 3;63 const p3a_len = 3;
64 const P3 = packed struct {64 const P3 = packed struct {
65 a: [p3a_len]u8,65 a: [p3a_len]u8,
66 b: usize,66 b: usize,
67 };67 };
68 try std.testing.expectEqual(0, @byteOffsetOf(P3, "a"));68 try std.testing.expectEqual(0, @offsetOf(P3, "a"));
69 try std.testing.expectEqual(p3a_len, @byteOffsetOf(P3, "b"));69 try std.testing.expectEqual(p3a_len, @offsetOf(P3, "b"));
7070
71 const p5a_len = 5;71 const p5a_len = 5;
72 const P5 = packed struct {72 const P5 = packed struct {
73 a: [p5a_len]u8,73 a: [p5a_len]u8,
74 b: usize,74 b: usize,
75 };75 };
76 try std.testing.expectEqual(0, @byteOffsetOf(P5, "a"));76 try std.testing.expectEqual(0, @offsetOf(P5, "a"));
77 try std.testing.expectEqual(p5a_len, @byteOffsetOf(P5, "b"));77 try std.testing.expectEqual(p5a_len, @offsetOf(P5, "b"));
7878
79 const p6a_len = 6;79 const p6a_len = 6;
80 const P6 = packed struct {80 const P6 = packed struct {
81 a: [p6a_len]u8,81 a: [p6a_len]u8,
82 b: usize,82 b: usize,
83 };83 };
84 try std.testing.expectEqual(0, @byteOffsetOf(P6, "a"));84 try std.testing.expectEqual(0, @offsetOf(P6, "a"));
85 try std.testing.expectEqual(p6a_len, @byteOffsetOf(P6, "b"));85 try std.testing.expectEqual(p6a_len, @offsetOf(P6, "b"));
8686
87 const p7a_len = 7;87 const p7a_len = 7;
88 const P7 = packed struct {88 const P7 = packed struct {
89 a: [p7a_len]u8,89 a: [p7a_len]u8,
90 b: usize,90 b: usize,
91 };91 };
92 try std.testing.expectEqual(0, @byteOffsetOf(P7, "a"));92 try std.testing.expectEqual(0, @offsetOf(P7, "a"));
93 try std.testing.expectEqual(p7a_len, @byteOffsetOf(P7, "b"));93 try std.testing.expectEqual(p7a_len, @offsetOf(P7, "b"));
9494
95 const p9a_len = 9;95 const p9a_len = 9;
96 const P9 = packed struct {96 const P9 = packed struct {
97 a: [p9a_len]u8,97 a: [p9a_len]u8,
98 b: usize,98 b: usize,
99 };99 };
100 try std.testing.expectEqual(0, @byteOffsetOf(P9, "a"));100 try std.testing.expectEqual(0, @offsetOf(P9, "a"));
101 try std.testing.expectEqual(p9a_len, @byteOffsetOf(P9, "b"));101 try std.testing.expectEqual(p9a_len, @offsetOf(P9, "b"));
102102
103 // 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 25 etc. are further cases103 // 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 25 etc. are further cases
104}104}
...@@ -113,13 +113,13 @@ test "@bitOffsetOf" {...@@ -113,13 +113,13 @@ test "@bitOffsetOf" {
113 try expect(@bitOffsetOf(P, "f") == 56);113 try expect(@bitOffsetOf(P, "f") == 56);
114 try expect(@bitOffsetOf(P, "g") == 72);114 try expect(@bitOffsetOf(P, "g") == 72);
115115
116 try expect(@byteOffsetOf(A, "a") * 8 == @bitOffsetOf(A, "a"));116 try expect(@offsetOf(A, "a") * 8 == @bitOffsetOf(A, "a"));
117 try expect(@byteOffsetOf(A, "b") * 8 == @bitOffsetOf(A, "b"));117 try expect(@offsetOf(A, "b") * 8 == @bitOffsetOf(A, "b"));
118 try expect(@byteOffsetOf(A, "c") * 8 == @bitOffsetOf(A, "c"));118 try expect(@offsetOf(A, "c") * 8 == @bitOffsetOf(A, "c"));
119 try expect(@byteOffsetOf(A, "d") * 8 == @bitOffsetOf(A, "d"));119 try expect(@offsetOf(A, "d") * 8 == @bitOffsetOf(A, "d"));
120 try expect(@byteOffsetOf(A, "e") * 8 == @bitOffsetOf(A, "e"));120 try expect(@offsetOf(A, "e") * 8 == @bitOffsetOf(A, "e"));
121 try expect(@byteOffsetOf(A, "f") * 8 == @bitOffsetOf(A, "f"));121 try expect(@offsetOf(A, "f") * 8 == @bitOffsetOf(A, "f"));
122 try expect(@byteOffsetOf(A, "g") * 8 == @bitOffsetOf(A, "g"));122 try expect(@offsetOf(A, "g") * 8 == @bitOffsetOf(A, "g"));
123}123}
124124
125test "@sizeOf on compile-time types" {125test "@sizeOf on compile-time types" {
test/behavior/struct.zig+1-1
...@@ -699,7 +699,7 @@ test "non-packed struct with u128 entry in union" {...@@ -699,7 +699,7 @@ test "non-packed struct with u128 entry in union" {
699699
700 var sx: S = undefined;700 var sx: S = undefined;
701 var s = &sx;701 var s = &sx;
702 try std.testing.expect(@ptrToInt(&s.f2) - @ptrToInt(&s.f1) == @byteOffsetOf(S, "f2"));702 try std.testing.expect(@ptrToInt(&s.f2) - @ptrToInt(&s.f1) == @offsetOf(S, "f2"));
703 var v2 = U{ .Num = 123 };703 var v2 = U{ .Num = 123 };
704 s.f2 = v2;704 s.f2 = v2;
705 try std.testing.expect(s.f2.Num == 123);705 try std.testing.expect(s.f2.Num == 123);
test/compile_errors.zig+8-8
...@@ -6669,24 +6669,24 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -6669,24 +6669,24 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
6669 "tmp.zig:8:29: error: field 'b' has index 1 but pointer value is index 0 of struct 'Foo'",6669 "tmp.zig:8:29: error: field 'b' has index 1 but pointer value is index 0 of struct 'Foo'",
6670 });6670 });
66716671
6672 cases.add("@byteOffsetOf - non struct",6672 cases.add("@offsetOf - non struct",
6673 \\const Foo = i32;6673 \\const Foo = i32;
6674 \\export fn foo() usize {6674 \\export fn foo() usize {
6675 \\ return @byteOffsetOf(Foo, "a",);6675 \\ return @offsetOf(Foo, "a",);
6676 \\}6676 \\}
6677 , &[_][]const u8{6677 , &[_][]const u8{
6678 "tmp.zig:3:26: error: expected struct type, found 'i32'",6678 "tmp.zig:3:22: error: expected struct type, found 'i32'",
6679 });6679 });
66806680
6681 cases.add("@byteOffsetOf - bad field name",6681 cases.add("@offsetOf - bad field name",
6682 \\const Foo = struct {6682 \\const Foo = struct {
6683 \\ derp: i32,6683 \\ derp: i32,
6684 \\};6684 \\};
6685 \\export fn foo() usize {6685 \\export fn foo() usize {
6686 \\ return @byteOffsetOf(Foo, "a",);6686 \\ return @offsetOf(Foo, "a",);
6687 \\}6687 \\}
6688 , &[_][]const u8{6688 , &[_][]const u8{
6689 "tmp.zig:5:31: error: struct 'Foo' has no field 'a'",6689 "tmp.zig:5:27: error: struct 'Foo' has no field 'a'",
6690 });6690 });
66916691
6692 cases.addExe("missing main fn in executable",6692 cases.addExe("missing main fn in executable",
...@@ -7693,10 +7693,10 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -7693,10 +7693,10 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
7693 \\ val: void,7693 \\ val: void,
7694 \\};7694 \\};
7695 \\export fn foo() void {7695 \\export fn foo() void {
7696 \\ const fieldOffset = @byteOffsetOf(Empty, "val",);7696 \\ const fieldOffset = @offsetOf(Empty, "val",);
7697 \\}7697 \\}
7698 , &[_][]const u8{7698 , &[_][]const u8{
7699 "tmp.zig:5:46: error: zero-bit field 'val' in struct 'Empty' has no offset",7699 "tmp.zig:5:42: error: zero-bit field 'val' in struct 'Empty' has no offset",
7700 });7700 });
77017701
7702 cases.add("taking bit offset of void field in struct",7702 cases.add("taking bit offset of void field in struct",