aboutsummaryrefslogtreecommitdiff
path: root/src/analyze.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-05-04 13:39:27 -0400
committerAndrew Kelley <superjoe30@gmail.com>2018-05-04 13:39:27 -0400
commit7e37d268c86ccc823c4a381a42029722d36c3975 (patch)
tree1600a184f03fedd91131bcbaea2c5ee85dfa06a3 /src/analyze.cpp
parent6309121f70ff88cf64267f2bf1d9e452090ca277 (diff)
parentef3111be236fc389a696562d31bccd3a9b6d1c56 (diff)
downloadzig-7e37d268c86ccc823c4a381a42029722d36c3975.tar.gz
zig-7e37d268c86ccc823c4a381a42029722d36c3975.zip
Merge remote-tracking branch 'origin/master' into llvm7
Diffstat (limited to 'src/analyze.cpp')
-rw-r--r--src/analyze.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp
index 1ecfe32f4c..0f2fdf15de 100644
--- a/src/analyze.cpp
+++ b/src/analyze.cpp
@@ -2325,8 +2325,14 @@ static void resolve_enum_zero_bits(CodeGen *g, TypeTableEntry *enum_type) {
HashMap<BigInt, AstNode *, bigint_hash, bigint_eql> occupied_tag_values = {};
occupied_tag_values.init(field_count);
- TypeTableEntry *tag_int_type = get_smallest_unsigned_int_type(g, field_count - 1);
+ TypeTableEntry *tag_int_type;
+ if (enum_type->data.enumeration.layout == ContainerLayoutExtern) {
+ tag_int_type = get_c_int_type(g, CIntTypeInt);
+ } else {
+ tag_int_type = get_smallest_unsigned_int_type(g, field_count - 1);
+ }
+ // TODO: Are extern enums allowed to have an init_arg_expr?
if (decl_node->data.container_decl.init_arg_expr != nullptr) {
TypeTableEntry *wanted_tag_int_type = analyze_type_expr(g, scope, decl_node->data.container_decl.init_arg_expr);
if (type_is_invalid(wanted_tag_int_type)) {