authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-06-19 16:16:47-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-06-19 16:16:47-04:00
log974db231a08731f642dbf72d716f669fed2bd2ab
tree209e1a0766c98f1a1a471fbd0eab97d3bbb093dc
parente36680d3bd08fceb3e976edeafae60ce6d577342
signaturelock-open Commit is signed but in an unrecognized format.

fix extraneous nested union field instruction


3 files changed, 23 insertions(+), 18 deletions(-)

src/codegen.cpp+6-1
......@@ -3853,6 +3853,9 @@ static LLVMValueRef ir_render_struct_field_ptr(CodeGen *g, IrExecutable *executa
38533853static LLVMValueRef ir_render_union_field_ptr(CodeGen *g, IrExecutable *executable,
38543854 IrInstructionUnionFieldPtr *instruction)
38553855{
3856 if (instruction->base.value.special != ConstValSpecialRuntime)
3857 return nullptr;
3858
38563859 ZigType *union_ptr_type = instruction->union_ptr->value.type;
38573860 assert(union_ptr_type->id == ZigTypeIdPointer);
38583861 ZigType *union_type = union_ptr_type->data.pointer.child_type;
......@@ -4077,6 +4080,9 @@ static LLVMValueRef ir_render_test_non_null(CodeGen *g, IrExecutable *executable
40774080static LLVMValueRef ir_render_optional_unwrap_ptr(CodeGen *g, IrExecutable *executable,
40784081 IrInstructionOptionalUnwrapPtr *instruction)
40794082{
4083 if (instruction->base.value.special != ConstValSpecialRuntime)
4084 return nullptr;
4085
40804086 ZigType *ptr_type = instruction->base_ptr->value.type;
40814087 assert(ptr_type->id == ZigTypeIdPointer);
40824088 ZigType *maybe_type = ptr_type->data.pointer.child_type;
......@@ -5750,7 +5756,6 @@ static void ir_render(CodeGen *g, ZigFn *fn_entry) {
57505756 assert(executable->basic_block_list.length > 0);
57515757 for (size_t block_i = 0; block_i < executable->basic_block_list.length; block_i += 1) {
57525758 IrBasicBlock *current_block = executable->basic_block_list.at(block_i);
5753 //assert(current_block->ref_count > 0);
57545759 assert(current_block->llvm_block);
57555760 LLVMPositionBuilderAtEnd(g->builder, current_block->llvm_block);
57565761 for (size_t instr_i = 0; instr_i < current_block->instruction_list.length; instr_i += 1) {
test/stage1/behavior.zig+1-1
......@@ -45,7 +45,7 @@ comptime {
4545 //_ = @import("behavior/coroutine_await_struct.zig");
4646 //_ = @import("behavior/coroutines.zig");
4747 _ = @import("behavior/defer.zig");
48 _ = @import("behavior/enum.zig"); // TODO
48 _ = @import("behavior/enum.zig");
4949 _ = @import("behavior/enum_with_members.zig");
5050 _ = @import("behavior/error.zig"); // TODO
5151 _ = @import("behavior/eval.zig");
test/stage1/behavior/enum.zig+16-16
......@@ -1,22 +1,22 @@
11const expect = @import("std").testing.expect;
22const mem = @import("std").mem;
33
4//test "enum type" {
5// const foo1 = Foo{ .One = 13 };
6// const foo2 = Foo{
7// .Two = Point{
8// .x = 1234,
9// .y = 5678,
10// },
11// };
12// const bar = Bar.B;
13//
14// expect(bar == Bar.B);
15// expect(@memberCount(Foo) == 3);
16// expect(@memberCount(Bar) == 4);
17// expect(@sizeOf(Foo) == @sizeOf(FooNoVoid));
18// expect(@sizeOf(Bar) == 1);
19//}
4test "enum type" {
5 const foo1 = Foo{ .One = 13 };
6 const foo2 = Foo{
7 .Two = Point{
8 .x = 1234,
9 .y = 5678,
10 },
11 };
12 const bar = Bar.B;
13
14 expect(bar == Bar.B);
15 expect(@memberCount(Foo) == 3);
16 expect(@memberCount(Bar) == 4);
17 expect(@sizeOf(Foo) == @sizeOf(FooNoVoid));
18 expect(@sizeOf(Bar) == 1);
19}
2020
2121test "enum as return value" {
2222 switch (returnAnInt(13)) {