authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-02-28 00:29:20-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-02-28 00:29:20-05:00
log6568be575cb87c2f54aad2dfa20d1f35471d2224
tree88d5964a4281f5c814717023024676539576751d
parent0f449a3ec180f710f8b54023d2c3b3dffcce5ec8
parent556f22a751e47d572404992befe15c09c0f2eb0b

Merge branch 'bnoordhuis-fix795'


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

src/analyze.cpp+3-1
......@@ -997,7 +997,7 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
997997 gen_param_info->src_index = i;
998998 gen_param_info->gen_index = SIZE_MAX;
999999
1000 ensure_complete_type(g, type_entry);
1000 type_ensure_zero_bits_known(g, type_entry);
10011001 if (type_has_bits(type_entry)) {
10021002 TypeTableEntry *gen_type;
10031003 if (handle_is_ptr(type_entry)) {
......@@ -2129,6 +2129,7 @@ static void resolve_enum_zero_bits(CodeGen *g, TypeTableEntry *enum_type) {
21292129
21302130 if (enum_type->data.enumeration.zero_bits_loop_flag) {
21312131 enum_type->data.enumeration.zero_bits_known = true;
2132 enum_type->data.enumeration.zero_bits_loop_flag = false;
21322133 return;
21332134 }
21342135
......@@ -2283,6 +2284,7 @@ static void resolve_struct_zero_bits(CodeGen *g, TypeTableEntry *struct_type) {
22832284 // the alignment is pointer width, then assert that the first field is within that
22842285 // alignment
22852286 struct_type->data.structure.zero_bits_known = true;
2287 struct_type->data.structure.zero_bits_loop_flag = false;
22862288 if (struct_type->data.structure.abi_alignment == 0) {
22872289 if (struct_type->data.structure.layout == ContainerLayoutPacked) {
22882290 struct_type->data.structure.abi_alignment = 1;
test/compile_errors.zig+12
......@@ -3090,4 +3090,16 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
30903090 ,
30913091 ".tmp_source.zig:11:20: error: runtime cast to union 'Value' which has non-void fields",
30923092 ".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");
30933105}