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...@@ -3853,6 +3853,9 @@ static LLVMValueRef ir_render_struct_field_ptr(CodeGen *g, IrExecutable *executa
3853static LLVMValueRef ir_render_union_field_ptr(CodeGen *g, IrExecutable *executable,3853static LLVMValueRef ir_render_union_field_ptr(CodeGen *g, IrExecutable *executable,
3854 IrInstructionUnionFieldPtr *instruction)3854 IrInstructionUnionFieldPtr *instruction)
3855{3855{
3856 if (instruction->base.value.special != ConstValSpecialRuntime)
3857 return nullptr;
3858
3856 ZigType *union_ptr_type = instruction->union_ptr->value.type;3859 ZigType *union_ptr_type = instruction->union_ptr->value.type;
3857 assert(union_ptr_type->id == ZigTypeIdPointer);3860 assert(union_ptr_type->id == ZigTypeIdPointer);
3858 ZigType *union_type = union_ptr_type->data.pointer.child_type;3861 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...@@ -4077,6 +4080,9 @@ static LLVMValueRef ir_render_test_non_null(CodeGen *g, IrExecutable *executable
4077static LLVMValueRef ir_render_optional_unwrap_ptr(CodeGen *g, IrExecutable *executable,4080static LLVMValueRef ir_render_optional_unwrap_ptr(CodeGen *g, IrExecutable *executable,
4078 IrInstructionOptionalUnwrapPtr *instruction)4081 IrInstructionOptionalUnwrapPtr *instruction)
4079{4082{
4083 if (instruction->base.value.special != ConstValSpecialRuntime)
4084 return nullptr;
4085
4080 ZigType *ptr_type = instruction->base_ptr->value.type;4086 ZigType *ptr_type = instruction->base_ptr->value.type;
4081 assert(ptr_type->id == ZigTypeIdPointer);4087 assert(ptr_type->id == ZigTypeIdPointer);
4082 ZigType *maybe_type = ptr_type->data.pointer.child_type;4088 ZigType *maybe_type = ptr_type->data.pointer.child_type;
...@@ -5750,7 +5756,6 @@ static void ir_render(CodeGen *g, ZigFn *fn_entry) {...@@ -5750,7 +5756,6 @@ static void ir_render(CodeGen *g, ZigFn *fn_entry) {
5750 assert(executable->basic_block_list.length > 0);5756 assert(executable->basic_block_list.length > 0);
5751 for (size_t block_i = 0; block_i < executable->basic_block_list.length; block_i += 1) {5757 for (size_t block_i = 0; block_i < executable->basic_block_list.length; block_i += 1) {
5752 IrBasicBlock *current_block = executable->basic_block_list.at(block_i);5758 IrBasicBlock *current_block = executable->basic_block_list.at(block_i);
5753 //assert(current_block->ref_count > 0);
5754 assert(current_block->llvm_block);5759 assert(current_block->llvm_block);
5755 LLVMPositionBuilderAtEnd(g->builder, current_block->llvm_block);5760 LLVMPositionBuilderAtEnd(g->builder, current_block->llvm_block);
5756 for (size_t instr_i = 0; instr_i < current_block->instruction_list.length; instr_i += 1) {5761 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 {...@@ -45,7 +45,7 @@ comptime {
45 //_ = @import("behavior/coroutine_await_struct.zig");45 //_ = @import("behavior/coroutine_await_struct.zig");
46 //_ = @import("behavior/coroutines.zig");46 //_ = @import("behavior/coroutines.zig");
47 _ = @import("behavior/defer.zig");47 _ = @import("behavior/defer.zig");
48 _ = @import("behavior/enum.zig"); // TODO48 _ = @import("behavior/enum.zig");
49 _ = @import("behavior/enum_with_members.zig");49 _ = @import("behavior/enum_with_members.zig");
50 _ = @import("behavior/error.zig"); // TODO50 _ = @import("behavior/error.zig"); // TODO
51 _ = @import("behavior/eval.zig");51 _ = @import("behavior/eval.zig");
test/stage1/behavior/enum.zig+16-16
...@@ -1,22 +1,22 @@...@@ -1,22 +1,22 @@
1const expect = @import("std").testing.expect;1const expect = @import("std").testing.expect;
2const mem = @import("std").mem;2const mem = @import("std").mem;
33
4//test "enum type" {4test "enum type" {
5// const foo1 = Foo{ .One = 13 };5 const foo1 = Foo{ .One = 13 };
6// const foo2 = Foo{6 const foo2 = Foo{
7// .Two = Point{7 .Two = Point{
8// .x = 1234,8 .x = 1234,
9// .y = 5678,9 .y = 5678,
10// },10 },
11// };11 };
12// const bar = Bar.B;12 const bar = Bar.B;
13//13
14// expect(bar == Bar.B);14 expect(bar == Bar.B);
15// expect(@memberCount(Foo) == 3);15 expect(@memberCount(Foo) == 3);
16// expect(@memberCount(Bar) == 4);16 expect(@memberCount(Bar) == 4);
17// expect(@sizeOf(Foo) == @sizeOf(FooNoVoid));17 expect(@sizeOf(Foo) == @sizeOf(FooNoVoid));
18// expect(@sizeOf(Bar) == 1);18 expect(@sizeOf(Bar) == 1);
19//}19}
2020
21test "enum as return value" {21test "enum as return value" {
22 switch (returnAnInt(13)) {22 switch (returnAnInt(13)) {