aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorxackus <14938807+xackus@users.noreply.github.com>2020-06-08 19:06:37 +0200
committerAndrew Kelley <andrew@ziglang.org>2020-06-08 17:19:06 -0400
commit0d40cb625564ca83f1b3d15202e02af656710c4a (patch)
treeffc35c6ac5b7892cf0083711a069aa48479fc7d4 /src/ir.cpp
parentc405844b0a039e6f2ba766d80644e06c1438654c (diff)
downloadzig-0d40cb625564ca83f1b3d15202e02af656710c4a.tar.gz
zig-0d40cb625564ca83f1b3d15202e02af656710c4a.zip
stage1: fix crash on slice byte reinterpretation
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index 54442861ca..3583f6ff05 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -29043,11 +29043,24 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou
case ZigTypeIdStruct:
switch (val->type->data.structure.layout) {
case ContainerLayoutAuto: {
- ErrorMsg *msg = opt_ir_add_error_node(ira, codegen, source_node,
- buf_sprintf("non-extern, non-packed struct '%s' cannot have its bytes reinterpreted",
- buf_ptr(&val->type->name)));
- add_error_note(codegen, msg, val->type->data.structure.decl_node,
- buf_sprintf("declared here"));
+ switch(val->type->data.structure.special){
+ case StructSpecialNone:
+ case StructSpecialInferredTuple:
+ case StructSpecialInferredStruct: {
+ ErrorMsg *msg = opt_ir_add_error_node(ira, codegen, source_node,
+ buf_sprintf("non-extern, non-packed struct '%s' cannot have its bytes reinterpreted",
+ buf_ptr(&val->type->name)));
+ add_error_note(codegen, msg, val->type->data.structure.decl_node,
+ buf_sprintf("declared here"));
+ break;
+ }
+ case StructSpecialSlice: {
+ opt_ir_add_error_node(ira, codegen, source_node,
+ buf_sprintf("slice '%s' cannot have its bytes reinterpreted",
+ buf_ptr(&val->type->name)));
+ break;
+ }
+ }
return ErrorSemanticAnalyzeFail;
}
case ContainerLayoutExtern: {