aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-11-25 18:20:39 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-11-25 18:20:39 -0700
commit67b201982bb1a0b4650b7ff222ef22875c32c810 (patch)
tree76fb74ec68c16955073552e437fc413fdb68b7f1 /src
parent7b78b4fff02e5f59da3034ee739c0eae99a01de5 (diff)
downloadzig-67b201982bb1a0b4650b7ff222ef22875c32c810.tar.gz
zig-67b201982bb1a0b4650b7ff222ef22875c32c810.zip
stage1: fix exporting enums
After extern enums were removed, stage1 was left in an incorrect state of checking for `extern enum` for exported enums. This commit fixes it to look for an explicit integer tag type instead, and adds test coverage for the compile error case as well as the success case. closes #9498
Diffstat (limited to 'src')
-rw-r--r--src/stage1/ir.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/stage1/ir.cpp b/src/stage1/ir.cpp
index 9a3b938dbd..0684b7bce1 100644
--- a/src/stage1/ir.cpp
+++ b/src/stage1/ir.cpp
@@ -11380,9 +11380,11 @@ static Stage1AirInst *ir_analyze_instruction_export(IrAnalyze *ira, Stage1ZirIns
}
break;
case ZigTypeIdEnum:
- if (target->value->type->data.enumeration.layout != ContainerLayoutExtern) {
+ if ((err = type_resolve(ira->codegen, target->value->type, ResolveStatusZeroBitsKnown)))
+ return ira->codegen->invalid_inst_gen;
+ if (!target->value->type->data.enumeration.has_explicit_tag_type) {
ErrorMsg *msg = ir_add_error(ira, target,
- buf_sprintf("exported enum value must be declared extern"));
+ buf_sprintf("exported enum value without explicit integer tag type"));
add_error_note(ira->codegen, msg, target->value->type->data.enumeration.decl_node, buf_sprintf("declared here"));
} else {
want_var_export = true;
@@ -11425,9 +11427,11 @@ static Stage1AirInst *ir_analyze_instruction_export(IrAnalyze *ira, Stage1ZirIns
}
break;
case ZigTypeIdEnum:
- if (type_value->data.enumeration.layout != ContainerLayoutExtern) {
+ if ((err = type_resolve(ira->codegen, type_value, ResolveStatusZeroBitsKnown)))
+ return ira->codegen->invalid_inst_gen;
+ if (!type_value->data.enumeration.has_explicit_tag_type) {
ErrorMsg *msg = ir_add_error(ira, target,
- buf_sprintf("exported enum must be declared extern"));
+ buf_sprintf("exported enum without explicit integer tag type"));
add_error_note(ira->codegen, msg, type_value->data.enumeration.decl_node, buf_sprintf("declared here"));
}
break;