authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2023-01-05 13:09:07+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2023-01-05 13:11:36+02:00
log352c71873b1c018fed8821d275b490be8c881792
tree1692cba2ea0a2d5f0d2f2c97de0fe37b9ac1bcc6
parent2d617c482ca24563a27125d626ac51e194d49eff

Sema: improve struct/union field error locations

Closes #14206

12 files changed, 194 insertions(+), 94 deletions(-)

src/Sema.zig+142-59
......@@ -30662,14 +30662,19 @@ fn semaStructFields(mod: *Module, struct_obj: *Module.Struct) CompileError!void
3066230662 const gop = struct_obj.fields.getOrPutAssumeCapacity(field_name);
3066330663 if (gop.found_existing) {
3066430664 const msg = msg: {
30665 const tree = try sema.getAstTree(&block_scope);
30666 const field_src = enumFieldSrcLoc(decl, tree.*, 0, field_i);
30665 const field_src = struct_obj.fieldSrcLoc(sema.mod, .{
30666 .index = field_i,
30667 .range = .name,
30668 }).lazy;
3066730669 const msg = try sema.errMsg(&block_scope, field_src, "duplicate struct field: '{s}'", .{field_name});
3066830670 errdefer msg.destroy(gpa);
3066930671
3067030672 const prev_field_index = struct_obj.fields.getIndex(field_name).?;
30671 const prev_field_src = enumFieldSrcLoc(decl, tree.*, 0, prev_field_index);
30672 try sema.mod.errNoteNonLazy(prev_field_src.toSrcLoc(decl), msg, "other field here", .{});
30673 const prev_field_src = struct_obj.fieldSrcLoc(sema.mod, .{
30674 .index = prev_field_index,
30675 .range = .name,
30676 });
30677 try sema.mod.errNoteNonLazy(prev_field_src, msg, "other field here", .{});
3067330678 try sema.errNote(&block_scope, src, msg, "struct declared here", .{});
3067430679 break :msg msg;
3067530680 };
......@@ -30699,34 +30704,51 @@ fn semaStructFields(mod: *Module, struct_obj: *Module.Struct) CompileError!void
3069930704 // so that init values may depend on type layout.
3070030705 const bodies_index = extra_index;
3070130706
30702 for (fields) |zir_field, i| {
30703 // TODO emit compile errors for invalid field types
30704 // such as arrays and pointers inside packed structs.
30707 for (fields) |zir_field, field_i| {
3070530708 const field_ty: Type = ty: {
3070630709 if (zir_field.type_ref != .none) {
30707 // TODO: if we need to report an error here, use a source location
30708 // that points to this type expression rather than the struct.
30709 // But only resolve the source location if we need to emit a compile error.
30710 break :ty try sema.resolveType(&block_scope, src, zir_field.type_ref);
30710 break :ty sema.resolveType(&block_scope, .unneeded, zir_field.type_ref) catch |err| switch (err) {
30711 error.NeededSourceLocation => {
30712 const ty_src = struct_obj.fieldSrcLoc(sema.mod, .{
30713 .index = field_i,
30714 .range = .type,
30715 }).lazy;
30716 _ = try sema.resolveType(&block_scope, ty_src, zir_field.type_ref);
30717 unreachable;
30718 },
30719 else => |e| return e,
30720 };
3071130721 }
3071230722 assert(zir_field.type_body_len != 0);
3071330723 const body = zir.extra[extra_index..][0..zir_field.type_body_len];
3071430724 extra_index += body.len;
3071530725 const ty_ref = try sema.resolveBody(&block_scope, body, struct_obj.zir_index);
30716 break :ty try sema.analyzeAsType(&block_scope, src, ty_ref);
30726 break :ty sema.analyzeAsType(&block_scope, .unneeded, ty_ref) catch |err| switch (err) {
30727 error.NeededSourceLocation => {
30728 const ty_src = struct_obj.fieldSrcLoc(sema.mod, .{
30729 .index = field_i,
30730 .range = .type,
30731 }).lazy;
30732 _ = try sema.analyzeAsType(&block_scope, ty_src, ty_ref);
30733 unreachable;
30734 },
30735 else => |e| return e,
30736 };
3071730737 };
3071830738 if (field_ty.tag() == .generic_poison) {
3071930739 return error.GenericPoison;
3072030740 }
3072130741
30722 const field = &struct_obj.fields.values()[i];
30742 const field = &struct_obj.fields.values()[field_i];
3072330743 field.ty = try field_ty.copy(decl_arena_allocator);
3072430744
3072530745 if (field_ty.zigTypeTag() == .Opaque) {
3072630746 const msg = msg: {
30727 const tree = try sema.getAstTree(&block_scope);
30728 const field_src = enumFieldSrcLoc(decl, tree.*, 0, i);
30729 const msg = try sema.errMsg(&block_scope, field_src, "opaque types have unknown size and therefore cannot be directly embedded in structs", .{});
30747 const ty_src = struct_obj.fieldSrcLoc(sema.mod, .{
30748 .index = field_i,
30749 .range = .type,
30750 }).lazy;
30751 const msg = try sema.errMsg(&block_scope, ty_src, "opaque types have unknown size and therefore cannot be directly embedded in structs", .{});
3073030752 errdefer msg.destroy(sema.gpa);
3073130753
3073230754 try sema.addDeclaredHereNote(msg, field_ty);
......@@ -30736,9 +30758,11 @@ fn semaStructFields(mod: *Module, struct_obj: *Module.Struct) CompileError!void
3073630758 }
3073730759 if (field_ty.zigTypeTag() == .NoReturn) {
3073830760 const msg = msg: {
30739 const tree = try sema.getAstTree(&block_scope);
30740 const field_src = enumFieldSrcLoc(decl, tree.*, 0, i);
30741 const msg = try sema.errMsg(&block_scope, field_src, "struct fields cannot be 'noreturn'", .{});
30761 const ty_src = struct_obj.fieldSrcLoc(sema.mod, .{
30762 .index = field_i,
30763 .range = .type,
30764 }).lazy;
30765 const msg = try sema.errMsg(&block_scope, ty_src, "struct fields cannot be 'noreturn'", .{});
3074230766 errdefer msg.destroy(sema.gpa);
3074330767
3074430768 try sema.addDeclaredHereNote(msg, field_ty);
......@@ -30748,12 +30772,14 @@ fn semaStructFields(mod: *Module, struct_obj: *Module.Struct) CompileError!void
3074830772 }
3074930773 if (struct_obj.layout == .Extern and !try sema.validateExternType(field.ty, .struct_field)) {
3075030774 const msg = msg: {
30751 const tree = try sema.getAstTree(&block_scope);
30752 const fields_src = enumFieldSrcLoc(decl, tree.*, 0, i);
30753 const msg = try sema.errMsg(&block_scope, fields_src, "extern structs cannot contain fields of type '{}'", .{field.ty.fmt(sema.mod)});
30775 const ty_src = struct_obj.fieldSrcLoc(sema.mod, .{
30776 .index = field_i,
30777 .range = .type,
30778 });
30779 const msg = try sema.errMsg(&block_scope, ty_src.lazy, "extern structs cannot contain fields of type '{}'", .{field.ty.fmt(sema.mod)});
3075430780 errdefer msg.destroy(sema.gpa);
3075530781
30756 try sema.explainWhyTypeIsNotExtern(msg, fields_src.toSrcLoc(decl), field.ty, .struct_field);
30782 try sema.explainWhyTypeIsNotExtern(msg, ty_src, field.ty, .struct_field);
3075730783
3075830784 try sema.addDeclaredHereNote(msg, field.ty);
3075930785 break :msg msg;
......@@ -30761,12 +30787,14 @@ fn semaStructFields(mod: *Module, struct_obj: *Module.Struct) CompileError!void
3076130787 return sema.failWithOwnedErrorMsg(msg);
3076230788 } else if (struct_obj.layout == .Packed and !(validatePackedType(field.ty))) {
3076330789 const msg = msg: {
30764 const tree = try sema.getAstTree(&block_scope);
30765 const fields_src = enumFieldSrcLoc(decl, tree.*, 0, i);
30766 const msg = try sema.errMsg(&block_scope, fields_src, "packed structs cannot contain fields of type '{}'", .{field.ty.fmt(sema.mod)});
30790 const ty_src = struct_obj.fieldSrcLoc(sema.mod, .{
30791 .index = field_i,
30792 .range = .type,
30793 });
30794 const msg = try sema.errMsg(&block_scope, ty_src.lazy, "packed structs cannot contain fields of type '{}'", .{field.ty.fmt(sema.mod)});
3076730795 errdefer msg.destroy(sema.gpa);
3076830796
30769 try sema.explainWhyTypeIsNotPacked(msg, fields_src.toSrcLoc(decl), field.ty);
30797 try sema.explainWhyTypeIsNotPacked(msg, ty_src, field.ty);
3077030798
3077130799 try sema.addDeclaredHereNote(msg, field.ty);
3077230800 break :msg msg;
......@@ -30778,7 +30806,17 @@ fn semaStructFields(mod: *Module, struct_obj: *Module.Struct) CompileError!void
3077830806 const body = zir.extra[extra_index..][0..zir_field.align_body_len];
3077930807 extra_index += body.len;
3078030808 const align_ref = try sema.resolveBody(&block_scope, body, struct_obj.zir_index);
30781 field.abi_align = try sema.analyzeAsAlign(&block_scope, src, align_ref);
30809 field.abi_align = sema.analyzeAsAlign(&block_scope, .unneeded, align_ref) catch |err| switch (err) {
30810 error.NeededSourceLocation => {
30811 const align_src = struct_obj.fieldSrcLoc(sema.mod, .{
30812 .index = field_i,
30813 .range = .alignment,
30814 }).lazy;
30815 _ = try sema.analyzeAsAlign(&block_scope, align_src, align_ref);
30816 unreachable;
30817 },
30818 else => |e| return e,
30819 };
3078230820 }
3078330821
3078430822 extra_index += zir_field.init_body_len;
......@@ -31023,9 +31061,17 @@ fn semaUnionFields(mod: *Module, union_obj: *Module.Union) CompileError!void {
3102331061
3102431062 if (enum_value_map) |map| {
3102531063 const copied_val = if (tag_ref != .none) blk: {
31026 const tag_src = src; // TODO better source location
31027 const coerced = try sema.coerce(&block_scope, int_tag_ty, tag_ref, tag_src);
31028 const val = try sema.resolveConstValue(&block_scope, tag_src, coerced, "enum tag value must be comptime-known");
31064 const val = sema.semaUnionFieldVal(&block_scope, .unneeded, int_tag_ty, tag_ref) catch |err| switch (err) {
31065 error.NeededSourceLocation => {
31066 const val_src = union_obj.fieldSrcLoc(sema.mod, .{
31067 .index = field_i,
31068 .range = .value,
31069 }).lazy;
31070 _ = try sema.semaUnionFieldVal(&block_scope, val_src, int_tag_ty, tag_ref);
31071 unreachable;
31072 },
31073 else => |e| return e,
31074 };
3102931075 last_tag_val = val;
3103031076
3103131077 // This puts the memory into the union arena, not the enum arena, but
......@@ -31045,9 +31091,14 @@ fn semaUnionFields(mod: *Module, union_obj: *Module.Union) CompileError!void {
3104531091 .mod = mod,
3104631092 });
3104731093 if (gop.found_existing) {
31048 const tree = try sema.getAstTree(&block_scope);
31049 const field_src = enumFieldSrcLoc(sema.mod.declPtr(block_scope.src_decl), tree.*, src.node_offset.x, field_i);
31050 const other_field_src = enumFieldSrcLoc(sema.mod.declPtr(block_scope.src_decl), tree.*, src.node_offset.x, gop.index);
31094 const field_src = union_obj.fieldSrcLoc(sema.mod, .{
31095 .index = field_i,
31096 .range = .name,
31097 }).lazy;
31098 const other_field_src = union_obj.fieldSrcLoc(sema.mod, .{
31099 .index = gop.index,
31100 .range = .name,
31101 }).lazy;
3105131102 const msg = msg: {
3105231103 const msg = try sema.errMsg(&block_scope, field_src, "enum tag value {} already taken", .{copied_val.fmtValue(int_tag_ty, sema.mod)});
3105331104 errdefer msg.destroy(gpa);
......@@ -31069,10 +31120,17 @@ fn semaUnionFields(mod: *Module, union_obj: *Module.Union) CompileError!void {
3106931120 else if (field_type_ref == .none)
3107031121 Type.initTag(.noreturn)
3107131122 else
31072 // TODO: if we need to report an error here, use a source location
31073 // that points to this type expression rather than the union.
31074 // But only resolve the source location if we need to emit a compile error.
31075 try sema.resolveType(&block_scope, src, field_type_ref);
31123 sema.resolveType(&block_scope, .unneeded, field_type_ref) catch |err| switch (err) {
31124 error.NeededSourceLocation => {
31125 const ty_src = union_obj.fieldSrcLoc(sema.mod, .{
31126 .index = field_i,
31127 .range = .type,
31128 }).lazy;
31129 _ = try sema.resolveType(&block_scope, ty_src, field_type_ref);
31130 unreachable;
31131 },
31132 else => |e| return e,
31133 };
3107631134
3107731135 if (field_ty.tag() == .generic_poison) {
3107831136 return error.GenericPoison;
......@@ -31081,13 +31139,18 @@ fn semaUnionFields(mod: *Module, union_obj: *Module.Union) CompileError!void {
3108131139 const gop = union_obj.fields.getOrPutAssumeCapacity(field_name);
3108231140 if (gop.found_existing) {
3108331141 const msg = msg: {
31084 const tree = try sema.getAstTree(&block_scope);
31085 const field_src = enumFieldSrcLoc(decl, tree.*, 0, field_i);
31142 const field_src = union_obj.fieldSrcLoc(sema.mod, .{
31143 .index = field_i,
31144 .range = .name,
31145 }).lazy;
3108631146 const msg = try sema.errMsg(&block_scope, field_src, "duplicate union field: '{s}'", .{field_name});
3108731147 errdefer msg.destroy(gpa);
3108831148
3108931149 const prev_field_index = union_obj.fields.getIndex(field_name).?;
31090 const prev_field_src = enumFieldSrcLoc(decl, tree.*, 0, prev_field_index);
31150 const prev_field_src = union_obj.fieldSrcLoc(sema.mod, .{
31151 .index = prev_field_index,
31152 .range = .name,
31153 }).lazy;
3109131154 try sema.mod.errNoteNonLazy(prev_field_src.toSrcLoc(decl), msg, "other field here", .{});
3109231155 try sema.errNote(&block_scope, src, msg, "union declared here", .{});
3109331156 break :msg msg;
......@@ -31099,9 +31162,11 @@ fn semaUnionFields(mod: *Module, union_obj: *Module.Union) CompileError!void {
3109931162 const enum_has_field = names.orderedRemove(field_name);
3110031163 if (!enum_has_field) {
3110131164 const msg = msg: {
31102 const tree = try sema.getAstTree(&block_scope);
31103 const field_src = enumFieldSrcLoc(decl, tree.*, 0, field_i);
31104 const msg = try sema.errMsg(&block_scope, field_src, "no field named '{s}' in enum '{}'", .{ field_name, union_obj.tag_ty.fmt(sema.mod) });
31165 const ty_src = union_obj.fieldSrcLoc(sema.mod, .{
31166 .index = field_i,
31167 .range = .type,
31168 }).lazy;
31169 const msg = try sema.errMsg(&block_scope, ty_src, "no field named '{s}' in enum '{}'", .{ field_name, union_obj.tag_ty.fmt(sema.mod) });
3110531170 errdefer msg.destroy(sema.gpa);
3110631171 try sema.addDeclaredHereNote(msg, union_obj.tag_ty);
3110731172 break :msg msg;
......@@ -31112,9 +31177,11 @@ fn semaUnionFields(mod: *Module, union_obj: *Module.Union) CompileError!void {
3111231177
3111331178 if (field_ty.zigTypeTag() == .Opaque) {
3111431179 const msg = msg: {
31115 const tree = try sema.getAstTree(&block_scope);
31116 const field_src = enumFieldSrcLoc(decl, tree.*, 0, field_i);
31117 const msg = try sema.errMsg(&block_scope, field_src, "opaque types have unknown size and therefore cannot be directly embedded in unions", .{});
31180 const ty_src = union_obj.fieldSrcLoc(sema.mod, .{
31181 .index = field_i,
31182 .range = .type,
31183 }).lazy;
31184 const msg = try sema.errMsg(&block_scope, ty_src, "opaque types have unknown size and therefore cannot be directly embedded in unions", .{});
3111831185 errdefer msg.destroy(sema.gpa);
3111931186
3112031187 try sema.addDeclaredHereNote(msg, field_ty);
......@@ -31124,12 +31191,14 @@ fn semaUnionFields(mod: *Module, union_obj: *Module.Union) CompileError!void {
3112431191 }
3112531192 if (union_obj.layout == .Extern and !try sema.validateExternType(field_ty, .union_field)) {
3112631193 const msg = msg: {
31127 const tree = try sema.getAstTree(&block_scope);
31128 const field_src = enumFieldSrcLoc(decl, tree.*, 0, field_i);
31129 const msg = try sema.errMsg(&block_scope, field_src, "extern unions cannot contain fields of type '{}'", .{field_ty.fmt(sema.mod)});
31194 const ty_src = union_obj.fieldSrcLoc(sema.mod, .{
31195 .index = field_i,
31196 .range = .type,
31197 });
31198 const msg = try sema.errMsg(&block_scope, ty_src.lazy, "extern unions cannot contain fields of type '{}'", .{field_ty.fmt(sema.mod)});
3113031199 errdefer msg.destroy(sema.gpa);
3113131200
31132 try sema.explainWhyTypeIsNotExtern(msg, field_src.toSrcLoc(decl), field_ty, .union_field);
31201 try sema.explainWhyTypeIsNotExtern(msg, ty_src, field_ty, .union_field);
3113331202
3113431203 try sema.addDeclaredHereNote(msg, field_ty);
3113531204 break :msg msg;
......@@ -31137,12 +31206,14 @@ fn semaUnionFields(mod: *Module, union_obj: *Module.Union) CompileError!void {
3113731206 return sema.failWithOwnedErrorMsg(msg);
3113831207 } else if (union_obj.layout == .Packed and !(validatePackedType(field_ty))) {
3113931208 const msg = msg: {
31140 const tree = try sema.getAstTree(&block_scope);
31141 const fields_src = enumFieldSrcLoc(decl, tree.*, 0, field_i);
31142 const msg = try sema.errMsg(&block_scope, fields_src, "packed unions cannot contain fields of type '{}'", .{field_ty.fmt(sema.mod)});
31209 const ty_src = union_obj.fieldSrcLoc(sema.mod, .{
31210 .index = field_i,
31211 .range = .type,
31212 });
31213 const msg = try sema.errMsg(&block_scope, ty_src.lazy, "packed unions cannot contain fields of type '{}'", .{field_ty.fmt(sema.mod)});
3114331214 errdefer msg.destroy(sema.gpa);
3114431215
31145 try sema.explainWhyTypeIsNotPacked(msg, fields_src.toSrcLoc(decl), field_ty);
31216 try sema.explainWhyTypeIsNotPacked(msg, ty_src, field_ty);
3114631217
3114731218 try sema.addDeclaredHereNote(msg, field_ty);
3114831219 break :msg msg;
......@@ -31156,10 +31227,17 @@ fn semaUnionFields(mod: *Module, union_obj: *Module.Union) CompileError!void {
3115631227 };
3115731228
3115831229 if (align_ref != .none) {
31159 // TODO: if we need to report an error here, use a source location
31160 // that points to this alignment expression rather than the struct.
31161 // But only resolve the source location if we need to emit a compile error.
31162 gop.value_ptr.abi_align = try sema.resolveAlign(&block_scope, src, align_ref);
31230 gop.value_ptr.abi_align = sema.resolveAlign(&block_scope, .unneeded, align_ref) catch |err| switch (err) {
31231 error.NeededSourceLocation => {
31232 const align_src = union_obj.fieldSrcLoc(sema.mod, .{
31233 .index = field_i,
31234 .range = .alignment,
31235 }).lazy;
31236 _ = try sema.resolveAlign(&block_scope, align_src, align_ref);
31237 unreachable;
31238 },
31239 else => |e| return e,
31240 };
3116331241 } else {
3116431242 gop.value_ptr.abi_align = 0;
3116531243 }
......@@ -31184,6 +31262,11 @@ fn semaUnionFields(mod: *Module, union_obj: *Module.Union) CompileError!void {
3118431262 }
3118531263}
3118631264
31265fn semaUnionFieldVal(sema: *Sema, block: *Block, src: LazySrcLoc, int_tag_ty: Type, tag_ref: Air.Inst.Ref) CompileError!Value {
31266 const coerced = try sema.coerce(block, int_tag_ty, tag_ref, src);
31267 return sema.resolveConstValue(block, src, coerced, "enum tag value must be comptime-known");
31268}
31269
3118731270fn generateUnionTagTypeNumbered(
3118831271 sema: *Sema,
3118931272 block: *Block,
test/cases/compile_errors/directly_embedding_opaque_type_in_struct_and_union.zig+2-2
......@@ -29,9 +29,9 @@ export fn d() void {
2929// backend=stage2
3030// target=native
3131//
32// :3:5: error: opaque types have unknown size and therefore cannot be directly embedded in structs
32// :3:8: error: opaque types have unknown size and therefore cannot be directly embedded in structs
3333// :1:11: note: opaque declared here
34// :7:5: error: opaque types have unknown size and therefore cannot be directly embedded in unions
34// :7:10: error: opaque types have unknown size and therefore cannot be directly embedded in unions
3535// :19:18: error: opaque types have unknown size and therefore cannot be directly embedded in structs
3636// :18:22: note: opaque declared here
3737// :24:23: error: opaque types have unknown size and therefore cannot be directly embedded in structs
test/cases/compile_errors/extern_struct_with_extern-compatible_but_inferred_integer_tag_type.zig+3-3
......@@ -39,7 +39,7 @@ export fn entry() void {
3939// backend=stage2
4040// target=native
4141//
42// :31:5: error: extern structs cannot contain fields of type 'tmp.E'
43// :31:5: note: enum tag type 'u9' is not extern compatible
44// :31:5: note: only integers with power of two bits are extern compatible
42// :31:8: error: extern structs cannot contain fields of type 'tmp.E'
43// :31:8: note: enum tag type 'u9' is not extern compatible
44// :31:8: note: only integers with power of two bits are extern compatible
4545// :1:15: note: enum declared here
test/cases/compile_errors/extern_struct_with_non-extern-compatible_integer_tag_type.zig+3-3
......@@ -11,7 +11,7 @@ export fn entry() void {
1111// backend=stage2
1212// target=native
1313//
14// :3:5: error: extern structs cannot contain fields of type 'tmp.E'
15// :3:5: note: enum tag type 'u31' is not extern compatible
16// :3:5: note: only integers with power of two bits are extern compatible
14// :3:8: error: extern structs cannot contain fields of type 'tmp.E'
15// :3:8: note: enum tag type 'u31' is not extern compatible
16// :3:8: note: only integers with power of two bits are extern compatible
1717// :1:15: note: enum declared here
test/cases/compile_errors/file_level_struct_invalid_field_type.zig created+17
......@@ -0,0 +1,17 @@
1const Parser = @This();
2fn Chunk() type {
3 return struct {
4 const Self = @This();
5 };
6}
7parser_chunk: Chunk,
8
9comptime {
10 _ = @sizeOf(@This()) + 1;
11}
12
13// error
14// backend=stage2
15// target=native
16//
17// :7:15: error: expected type 'type', found 'fn() type'
test/cases/compile_errors/invalid_optional_type_in_extern_struct.zig+2-2
......@@ -7,5 +7,5 @@ export fn testf(fluff: *stroo) void { _ = fluff; }
77// backend=stage2
88// target=native
99//
10// :2:5: error: extern structs cannot contain fields of type '?[*c]u8'
11// :2:5: note: only pointer like optionals are extern compatible
10// :2:10: error: extern structs cannot contain fields of type '?[*c]u8'
11// :2:10: note: only pointer like optionals are extern compatible
test/cases/compile_errors/noreturn_struct_field.zig+1-1
......@@ -9,4 +9,4 @@ comptime {
99// backend=stage2
1010// target=native
1111//
12// :2:5: error: struct fields cannot be 'noreturn'
12// :2:8: error: struct fields cannot be 'noreturn'
test/cases/compile_errors/old_fn_ptr_in_extern_context.zig+3-3
......@@ -12,9 +12,9 @@ comptime {
1212// backend=stage2
1313// target=native
1414//
15// :2:5: error: extern structs cannot contain fields of type 'fn() callconv(.C) void'
16// :2:5: note: type has no guaranteed in-memory representation
17// :2:5: note: use '*const ' to make a function pointer type
15// :2:8: error: extern structs cannot contain fields of type 'fn() callconv(.C) void'
16// :2:8: note: type has no guaranteed in-memory representation
17// :2:8: note: use '*const ' to make a function pointer type
1818// :8:13: error: C pointers cannot point to non-C-ABI-compatible type '[4]fn() callconv(.C) void'
1919// :8:13: note: type has no guaranteed in-memory representation
2020// :8:13: note: use '*const ' to make a function pointer type
test/cases/compile_errors/packed_struct_with_fields_of_not_allowed_types.zig+17-17
......@@ -70,22 +70,22 @@ export fn entry12() void {
7070// backend=llvm
7171// target=native
7272//
73// :3:9: error: packed structs cannot contain fields of type 'anyerror'
74// :3:9: note: type has no guaranteed in-memory representation
75// :8:9: error: packed structs cannot contain fields of type '[2]u24'
76// :8:9: note: type has no guaranteed in-memory representation
77// :13:9: error: packed structs cannot contain fields of type 'anyerror!u32'
78// :13:9: note: type has no guaranteed in-memory representation
79// :18:9: error: packed structs cannot contain fields of type 'tmp.S'
80// :18:9: note: only packed structs layout are allowed in packed types
73// :3:12: error: packed structs cannot contain fields of type 'anyerror'
74// :3:12: note: type has no guaranteed in-memory representation
75// :8:12: error: packed structs cannot contain fields of type '[2]u24'
76// :8:12: note: type has no guaranteed in-memory representation
77// :13:20: error: packed structs cannot contain fields of type 'anyerror!u32'
78// :13:20: note: type has no guaranteed in-memory representation
79// :18:12: error: packed structs cannot contain fields of type 'tmp.S'
80// :18:12: note: only packed structs layout are allowed in packed types
8181// :56:11: note: struct declared here
82// :23:9: error: packed structs cannot contain fields of type 'tmp.U'
83// :23:9: note: only packed unions layout are allowed in packed types
82// :23:12: error: packed structs cannot contain fields of type 'tmp.U'
83// :23:12: note: only packed unions layout are allowed in packed types
8484// :59:18: note: union declared here
85// :28:9: error: packed structs cannot contain fields of type '?anyerror'
86// :28:9: note: type has no guaranteed in-memory representation
87// :38:9: error: packed structs cannot contain fields of type 'fn() void'
88// :38:9: note: type has no guaranteed in-memory representation
89// :38:9: note: use '*const ' to make a function pointer type
90// :65:28: error: packed structs cannot contain fields of type '[]u8'
91// :65:28: note: slices have no guaranteed in-memory representation
85// :28:12: error: packed structs cannot contain fields of type '?anyerror'
86// :28:12: note: type has no guaranteed in-memory representation
87// :38:12: error: packed structs cannot contain fields of type 'fn() void'
88// :38:12: note: type has no guaranteed in-memory representation
89// :38:12: note: use '*const ' to make a function pointer type
90// :65:31: error: packed structs cannot contain fields of type '[]u8'
91// :65:31: note: slices have no guaranteed in-memory representation
test/cases/compile_errors/packed_union_with_automatic_layout_field.zig+2-2
......@@ -15,6 +15,6 @@ export fn entry() void {
1515// backend=stage2
1616// target=native
1717//
18// :6:5: error: packed unions cannot contain fields of type 'tmp.Foo'
19// :6:5: note: only packed structs layout are allowed in packed types
18// :6:8: error: packed unions cannot contain fields of type 'tmp.Foo'
19// :6:8: note: only packed structs layout are allowed in packed types
2020// :1:13: note: struct declared here
test/cases/compile_errors/union_enum_field_does_not_match_enum.zig+1-1
......@@ -18,5 +18,5 @@ export fn entry() void {
1818// backend=stage2
1919// target=native
2020//
21// :10:5: error: no field named 'D' in enum 'tmp.Letter'
21// :10:8: error: no field named 'D' in enum 'tmp.Letter'
2222// :1:16: note: enum declared here
test/cases/compile_errors/union_extra_field.zig+1-1
......@@ -16,5 +16,5 @@ export fn entry() usize {
1616// error
1717// target=native
1818//
19// :10:5: error: no field named 'd' in enum 'tmp.E'
19// :10:8: error: no field named 'd' in enum 'tmp.E'
2020// :1:11: note: enum declared here