diff --git a/src/AstGen.zig b/src/AstGen.zig index f7b81765b87ceec3c0205ea283c3bfea9ad5fdb1..3a3dfa81603f2753b42fd31eb2d84e6c53b92341 100644 --- a/src/AstGen.zig +++ b/src/AstGen.zig @@ -4687,6 +4687,13 @@ fn structDeclInner( const container_field = tree.fullContainerField(member_node) orelse continue; if (container_field.ast.tuple_like) break true; } else false; + + if (is_tuple) switch (layout) { + .Auto => {}, + .Extern => return astgen.failNode(node, "extern tuples are not supported", .{}), + .Packed => return astgen.failNode(node, "packed tuples are not supported", .{}), + }; + if (is_tuple) for (container_decl.ast.members) |member_node| { switch (node_tags[member_node]) { .container_field_init, diff --git a/src/Sema.zig b/src/Sema.zig index 2f068bd98fa16a7709a2b6d16378370e04a87f7c..3ae2ab96bd73bdd8d34a5d73c84b2748f29f5945 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -20391,6 +20391,12 @@ fn reifyStruct( const gpa = sema.gpa; const ip = &mod.intern_pool; + if (is_tuple) switch (layout) { + .Extern => return sema.fail(block, src, "extern tuples are not supported", .{}), + .Packed => return sema.fail(block, src, "packed tuples are not supported", .{}), + .Auto => {}, + }; + // Because these three things each reference each other, `undefined` // placeholders are used before being set after the struct type gains an // InternPool index. diff --git a/src/codegen/llvm/Builder.zig b/src/codegen/llvm/Builder.zig index 4abe7902efc58e0db8c773ce9c676ab0ac2bda7c..3e6cf31d69cf29d904cb0b3f5137edb6c3718a44 100644 --- a/src/codegen/llvm/Builder.zig +++ b/src/codegen/llvm/Builder.zig @@ -4164,8 +4164,8 @@ pub const WipFunction = struct { @memcpy(extra.trail.nextMut(incoming_len, Block.Index, wip), blocks); if (wip.builder.useLibLlvm()) { const ExpectedContents = extern struct { - [expected_incoming_len]*llvm.Value, - [expected_incoming_len]*llvm.BasicBlock, + values: [expected_incoming_len]*llvm.Value, + blocks: [expected_incoming_len]*llvm.BasicBlock, }; var stack align(@alignOf(ExpectedContents)) = std.heap.stackFallback(@sizeOf(ExpectedContents), wip.builder.gpa); diff --git a/test/behavior/tuple_declarations.zig b/test/behavior/tuple_declarations.zig index 84b04d3e5391ee3bd9ddd8864b4c9b75b79e8066..1936d770432defc7ed603aba67a85982076cf272 100644 --- a/test/behavior/tuple_declarations.zig +++ b/test/behavior/tuple_declarations.zig @@ -31,27 +31,6 @@ test "tuple declaration type info" { try expect(!info.fields[1].is_comptime); try expect(info.fields[1].alignment == @alignOf([]const u8)); } - { - const T = packed struct(u32) { u1, u30, u1 }; - const info = @typeInfo(T).Struct; - - try expect(std.mem.endsWith(u8, @typeName(T), "test.tuple declaration type info.T")); - - try expect(info.layout == .Packed); - try expect(info.backing_integer == u32); - try expect(info.fields.len == 3); - try expect(info.decls.len == 0); - try expect(info.is_tuple); - - try expectEqualStrings(info.fields[0].name, "0"); - try expect(info.fields[0].type == u1); - - try expectEqualStrings(info.fields[1].name, "1"); - try expect(info.fields[1].type == u30); - - try expectEqualStrings(info.fields[2].name, "2"); - try expect(info.fields[2].type == u1); - } } test "Tuple declaration usage" { diff --git a/test/cases/compile_errors/reify_struct.zig b/test/cases/compile_errors/reify_struct.zig index 42b8e42af5c792c629a5617e8a719ab94f88030b..f20ea15048e65801fdbc83ceae2b79436d0fe3a3 100644 --- a/test/cases/compile_errors/reify_struct.zig +++ b/test/cases/compile_errors/reify_struct.zig @@ -51,7 +51,7 @@ comptime { .alignment = 4, }}, .decls = &.{}, - .is_tuple = true, + .is_tuple = false, } }); } comptime { @@ -65,7 +65,7 @@ comptime { .alignment = 4, }}, .decls = &.{}, - .is_tuple = true, + .is_tuple = false, } }); }