authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-06-12 19:43:24-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-06-12 19:43:24-04:00
log0d62c929470458e30b888f76d029fff48d31fd3b
tree0b8b0e54681df1cd8068504ce61eac260f010c08
parente6fa2ee70632ef1efbe3ebc54214abf30d6d40c1
signature Commit is signed but in an unrecognized format.

fix declref not writing to result loc

```zig const a: i32 = 0; const b: i32 = 1; const c: i32 = 2; const d: i32 = 3; export fn entry(x: bool) i32 { return if (x) if (x) a else if (x) b else c else d; } ```

3 files changed, 10 insertions(+), 6 deletions(-)

BRANCH_TODO-2
...@@ -10,5 +10,3 @@ get an empty file compiling successfully (with no panic fn override)...@@ -10,5 +10,3 @@ get an empty file compiling successfully (with no panic fn override)
1010
11uncomment all the behavior tests11uncomment all the behavior tests
1212
13look at all the ir_gen_node ir_gen_node_extra calls and make sure result locations are properly propagated
14 return ir_gen_comptime(irb, scope, node, lval);
src/all_types.hpp+1-1
...@@ -3247,8 +3247,8 @@ struct IrInstructionTypeName {...@@ -3247,8 +3247,8 @@ struct IrInstructionTypeName {
3247struct IrInstructionDeclRef {3247struct IrInstructionDeclRef {
3248 IrInstruction base;3248 IrInstruction base;
32493249
3250 Tld *tld;
3251 LVal lval;3250 LVal lval;
3251 Tld *tld;
3252};3252};
32533253
3254struct IrInstructionPanic {3254struct IrInstructionPanic {
src/ir.cpp+9-3
...@@ -4166,8 +4166,14 @@ static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node,...@@ -4166,8 +4166,14 @@ static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node,
4166 }4166 }
41674167
4168 Tld *tld = find_decl(irb->codegen, scope, variable_name);4168 Tld *tld = find_decl(irb->codegen, scope, variable_name);
4169 if (tld)4169 if (tld) {
4170 return ir_build_decl_ref(irb, scope, node, tld, lval);4170 IrInstruction *decl_ref = ir_build_decl_ref(irb, scope, node, tld, lval);
4171 if (lval == LValPtr) {
4172 return decl_ref;
4173 } else {
4174 return ir_expr_wrap(irb, scope, decl_ref, result_loc);
4175 }
4176 }
41714177
4172 if (get_container_scope(node->owner)->any_imports_failed) {4178 if (get_container_scope(node->owner)->any_imports_failed) {
4173 // skip the error message since we had a failing import in this file4179 // skip the error message since we had a failing import in this file
...@@ -16503,7 +16509,7 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh...@@ -16503,7 +16509,7 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh
16503 IrInstruction *branch_instruction = predecessor->instruction_list.pop();16509 IrInstruction *branch_instruction = predecessor->instruction_list.pop();
16504 ir_set_cursor_at_end(&ira->new_irb, predecessor);16510 ir_set_cursor_at_end(&ira->new_irb, predecessor);
16505 IrInstruction *casted_value = ir_implicit_cast(ira, new_value, resolved_type);16511 IrInstruction *casted_value = ir_implicit_cast(ira, new_value, resolved_type);
16506 if (casted_value == ira->codegen->invalid_instruction) {16512 if (type_is_invalid(casted_value->value.type)) {
16507 return ira->codegen->invalid_instruction;16513 return ira->codegen->invalid_instruction;
16508 }16514 }
16509 new_incoming_values.items[i] = casted_value;16515 new_incoming_values.items[i] = casted_value;