aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-06-12 19:43:24 -0400
committerAndrew Kelley <andrew@ziglang.org>2019-06-12 19:43:24 -0400
commit0d62c929470458e30b888f76d029fff48d31fd3b (patch)
tree0b8b0e54681df1cd8068504ce61eac260f010c08 /src/ir.cpp
parente6fa2ee70632ef1efbe3ebc54214abf30d6d40c1 (diff)
downloadzig-0d62c929470458e30b888f76d029fff48d31fd3b.tar.gz
zig-0d62c929470458e30b888f76d029fff48d31fd3b.zip
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; } ```
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index 42e5b23ce0..b9bd3a9d5d 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -4166,8 +4166,14 @@ static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node,
}
Tld *tld = find_decl(irb->codegen, scope, variable_name);
- if (tld)
- return ir_build_decl_ref(irb, scope, node, tld, lval);
+ if (tld) {
+ IrInstruction *decl_ref = ir_build_decl_ref(irb, scope, node, tld, lval);
+ if (lval == LValPtr) {
+ return decl_ref;
+ } else {
+ return ir_expr_wrap(irb, scope, decl_ref, result_loc);
+ }
+ }
if (get_container_scope(node->owner)->any_imports_failed) {
// 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
IrInstruction *branch_instruction = predecessor->instruction_list.pop();
ir_set_cursor_at_end(&ira->new_irb, predecessor);
IrInstruction *casted_value = ir_implicit_cast(ira, new_value, resolved_type);
- if (casted_value == ira->codegen->invalid_instruction) {
+ if (type_is_invalid(casted_value->value.type)) {
return ira->codegen->invalid_instruction;
}
new_incoming_values.items[i] = casted_value;