aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorLemonBoy <thatlemon@gmail.com>2019-12-17 00:31:32 +0100
committerAndrew Kelley <andrew@ziglang.org>2019-12-17 15:45:22 -0500
commitd8499f7abe43ec641027eb7f94b41906c9bf5cca (patch)
tree913014c0990e942c569fad7e67b2f9a701e1be09 /src/ir.cpp
parentf389e5e61fcbc92423c16ccd2d0c79878d1589e4 (diff)
downloadzig-d8499f7abe43ec641027eb7f94b41906c9bf5cca.tar.gz
zig-d8499f7abe43ec641027eb7f94b41906c9bf5cca.zip
Make sure the fields array is always non-null
Fixes #3497
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index a5dee25645..bc16cef561 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -14018,7 +14018,8 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc
case OnePossibleValueInvalid:
return ira->codegen->invalid_instruction;
case OnePossibleValueYes:
- return ir_const(ira, source_instruction, child_type);
+ return ir_const_move(ira, source_instruction,
+ get_the_one_possible_value(ira->codegen, child_type));
case OnePossibleValueNo:
break;
}
@@ -19226,7 +19227,8 @@ skip_resolve_peer_types:
case OnePossibleValueInvalid:
return ira->codegen->invalid_instruction;
case OnePossibleValueYes:
- return ir_const(ira, &phi_instruction->base, resolved_type);
+ return ir_const_move(ira, &phi_instruction->base,
+ get_the_one_possible_value(ira->codegen, resolved_type));
case OnePossibleValueNo:
break;
}
@@ -19862,7 +19864,8 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction
case OnePossibleValueInvalid:
return ira->codegen->invalid_instruction;
case OnePossibleValueYes: {
- IrInstruction *elem = ir_const(ira, source_instr, field_type);
+ IrInstruction *elem = ir_const_move(ira, source_instr,
+ get_the_one_possible_value(ira->codegen, field_type));
return ir_get_ref(ira, source_instr, elem, false, false);
}
case OnePossibleValueNo:
@@ -21933,7 +21936,8 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira,
case OnePossibleValueInvalid:
return ira->codegen->invalid_instruction;
case OnePossibleValueYes:
- return ir_const(ira, &instruction->base, container_type);
+ return ir_const_move(ira, &instruction->base,
+ get_the_one_possible_value(ira->codegen, container_type));
case OnePossibleValueNo:
break;
}