aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-03-24 18:51:24 -0400
committerAndrew Kelley <andrew@ziglang.org>2019-03-24 18:51:24 -0400
commit3306e43984a8b17472ecc4b13a2f2815d6630eef (patch)
tree02a0a482a9887c5d439d0e2ec3e442da58a3f89c /src/ir.cpp
parentda9d8a6ecfb0428ce3d6575905f96fa1661c9b80 (diff)
downloadzig-3306e43984a8b17472ecc4b13a2f2815d6630eef.tar.gz
zig-3306e43984a8b17472ecc4b13a2f2815d6630eef.zip
add compile error test for invalid enum literal implicit cast
See #683
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index 58db315665..46fb86e33f 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -11601,8 +11601,10 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
TypeEnumField *field = find_enum_type_field(wanted_type, value->value.data.x_enum_literal);
if (field == nullptr) {
- ir_add_error(ira, source_instr, buf_sprintf("enum '%s' has no field named '%s'",
+ ErrorMsg *msg = ir_add_error(ira, source_instr, buf_sprintf("enum '%s' has no field named '%s'",
buf_ptr(&wanted_type->name), buf_ptr(value->value.data.x_enum_literal)));
+ add_error_note(ira->codegen, msg, wanted_type->data.enumeration.decl_node,
+ buf_sprintf("'%s' declared here", buf_ptr(&wanted_type->name)));
return ira->codegen->invalid_instruction;
}
IrInstruction *result = ir_const(ira, source_instr, wanted_type);