aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-03-07 14:35:48 -0500
committerAndrew Kelley <superjoe30@gmail.com>2018-03-07 14:35:48 -0500
commit790aaeacaea88782987c4145bc7ae47a401563f1 (patch)
tree0aad6bf2e1c29b0dab883a2633b4d380f68dfc51 /src/ir.cpp
parentbb80daf509b7afd84fe3076347e69e8f39f586d6 (diff)
downloadzig-790aaeacaea88782987c4145bc7ae47a401563f1.tar.gz
zig-790aaeacaea88782987c4145bc7ae47a401563f1.zip
add compile error for using @tagName on extern union
closes #742
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index cdb8201b2b..811744e9d0 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -14137,6 +14137,14 @@ static IrInstruction *ir_analyze_union_tag(IrAnalyze *ira, IrInstruction *source
buf_sprintf("expected enum or union type, found '%s'", buf_ptr(&value->value.type->name)));
return ira->codegen->invalid_instruction;
}
+ if (!value->value.type->data.unionation.have_explicit_tag_type && !source_instr->is_gen) {
+ ErrorMsg *msg = ir_add_error(ira, source_instr, buf_sprintf("union has no associated enum"));
+ if (value->value.type->data.unionation.decl_node != nullptr) {
+ add_error_note(ira->codegen, msg, value->value.type->data.unionation.decl_node,
+ buf_sprintf("declared here"));
+ }
+ return ira->codegen->invalid_instruction;
+ }
TypeTableEntry *tag_type = value->value.type->data.unionation.tag_type;
assert(tag_type->id == TypeTableEntryIdEnum);