aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorLemonBoy <thatlemon@gmail.com>2020-01-02 12:56:46 +0100
committerAndrew Kelley <andrew@ziglang.org>2020-01-02 10:41:11 -0500
commit1e61e5f4041859859dc5b6f1936cccfd32e9c3a5 (patch)
tree2e9f59b449f11ba743c9c81ab3880ec0c6a591a7 /src/ir.cpp
parentf35a963ac5a2ea053801c37be1271153f35b7df1 (diff)
downloadzig-1e61e5f4041859859dc5b6f1936cccfd32e9c3a5.tar.gz
zig-1e61e5f4041859859dc5b6f1936cccfd32e9c3a5.zip
Don't ptrCast a result-location assignment to _
After #4010 doing `_ = @bitCast(...)` triggered a nonsensical compiler error.
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index fbd9ba7ac0..08efdbd6e4 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -17394,11 +17394,23 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe
}
ZigType *parent_ptr_type = parent_result_loc->value->type;
assert(parent_ptr_type->id == ZigTypeIdPointer);
- if ((err = type_resolve(ira->codegen, parent_ptr_type->data.pointer.child_type,
- ResolveStatusAlignmentKnown)))
- {
+ ZigType *child_type = parent_ptr_type->data.pointer.child_type;
+
+ bool has_bits;
+ if ((err = type_has_bits2(ira->codegen, child_type, &has_bits))) {
+ return ira->codegen->invalid_instruction;
+ }
+
+ // This happens when the bitCast result is assigned to _
+ if (!has_bits) {
+ assert(allow_discard);
+ return parent_result_loc;
+ }
+
+ if ((err = type_resolve(ira->codegen, child_type, ResolveStatusAlignmentKnown))) {
return ira->codegen->invalid_instruction;
}
+
uint64_t parent_ptr_align = get_ptr_align(ira->codegen, parent_ptr_type);
if ((err = type_resolve(ira->codegen, value_type, ResolveStatusAlignmentKnown))) {
return ira->codegen->invalid_instruction;