authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-02-28 00:22:53-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-02-28 00:22:53-05:00
log1b8a241f6fd1ac8d42965c6aaaf4934de565b2b2
treefe663d430faa66ee31ccd815cc370cd25d1ac9ca
parent0f449a3ec180f710f8b54023d2c3b3dffcce5ec8
parent90598b4631e3b68565c7d62102a9e4615514a721

Merge branch 'fix795' of https://github.com/bnoordhuis/zig into bnoordhuis-fix795


2 files changed, 15 insertions(+), 1 deletions(-)

src/analyze.cpp+3-1
...@@ -1670,6 +1670,9 @@ static void resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) {...@@ -1670,6 +1670,9 @@ static void resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) {
1670 if (struct_type->data.structure.is_invalid)1670 if (struct_type->data.structure.is_invalid)
1671 return;1671 return;
16721672
1673 if (struct_type->data.structure.zero_bits_loop_flag)
1674 return;
1675
1673 AstNode *decl_node = struct_type->data.structure.decl_node;1676 AstNode *decl_node = struct_type->data.structure.decl_node;
16741677
1675 if (struct_type->data.structure.embedded_in_current) {1678 if (struct_type->data.structure.embedded_in_current) {
...@@ -1682,7 +1685,6 @@ static void resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) {...@@ -1682,7 +1685,6 @@ static void resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) {
1682 return;1685 return;
1683 }1686 }
16841687
1685 assert(!struct_type->data.structure.zero_bits_loop_flag);
1686 assert(struct_type->data.structure.fields);1688 assert(struct_type->data.structure.fields);
1687 assert(decl_node->type == NodeTypeContainerDecl);1689 assert(decl_node->type == NodeTypeContainerDecl);
16881690
test/compile_errors.zig+12
...@@ -3090,4 +3090,16 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {...@@ -3090,4 +3090,16 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
3090 ,3090 ,
3091 ".tmp_source.zig:11:20: error: runtime cast to union 'Value' which has non-void fields",3091 ".tmp_source.zig:11:20: error: runtime cast to union 'Value' which has non-void fields",
3092 ".tmp_source.zig:3:5: note: field 'A' has type 'i32'");3092 ".tmp_source.zig:3:5: note: field 'A' has type 'i32'");
3093
3094 cases.add("self-referencing function pointer field",
3095 \\const S = struct {
3096 \\ f: fn(_: S) void,
3097 \\};
3098 \\fn f(_: S) void {
3099 \\}
3100 \\export fn entry() void {
3101 \\ var _ = S { .f = f };
3102 \\}
3103 ,
3104 ".tmp_source.zig:4:9: error: type 'S' is not copyable; cannot pass by value");
3093}3105}