authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-08-26 12:23:12-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-08-26 12:23:12-04:00
log2b8f98a52c64301ae5bfc83936434af6c88d77d7
tree4ffbaad805fe8c4f4d66958a09b1c56a57043252
parent6aa04c422bae89c50e1289e1ca51cd4d414debb7

fix wrong switch target type with enum from .h file

fixes crash when else => unreachable is missing

1 files changed, 4 insertions(+), 3 deletions(-)

src/parseh.cpp+4-3
...@@ -729,11 +729,12 @@ static TypeTableEntry *resolve_enum_decl(Context *c, const EnumDecl *enum_decl)...@@ -729,11 +729,12 @@ static TypeTableEntry *resolve_enum_decl(Context *c, const EnumDecl *enum_decl)
729 }729 }
730 }730 }
731731
732 TypeTableEntry *tag_type_entry = resolve_qual_type(c, enum_decl->getIntegerType(), enum_decl);732 TypeTableEntry *tag_int_type = resolve_qual_type(c, enum_decl->getIntegerType(), enum_decl);
733733
734 if (pure_enum) {734 if (pure_enum) {
735 TypeTableEntry *enum_type = get_partial_container_type(c->codegen, &c->import->decls_scope->base,735 TypeTableEntry *enum_type = get_partial_container_type(c->codegen, &c->import->decls_scope->base,
736 ContainerKindEnum, c->source_node, buf_ptr(full_type_name), ContainerLayoutExtern);736 ContainerKindEnum, c->source_node, buf_ptr(full_type_name), ContainerLayoutExtern);
737 TypeTableEntry *tag_type_entry = create_enum_tag_type(c->codegen, enum_type, tag_int_type);
737 c->enum_type_table.put(bare_name, enum_type);738 c->enum_type_table.put(bare_name, enum_type);
738 c->decl_table.put(enum_decl, enum_type);739 c->decl_table.put(enum_decl, enum_type);
739740
...@@ -793,9 +794,9 @@ static TypeTableEntry *resolve_enum_decl(Context *c, const EnumDecl *enum_decl)...@@ -793,9 +794,9 @@ static TypeTableEntry *resolve_enum_decl(Context *c, const EnumDecl *enum_decl)
793794
794 return enum_type;795 return enum_type;
795 } else {796 } else {
796 // TODO after issue #305 is solved, make this be an enum with tag_type_entry797 // TODO after issue #305 is solved, make this be an enum with tag_int_type
797 // as the integer type and set the custom enum values798 // as the integer type and set the custom enum values
798 TypeTableEntry *enum_type = tag_type_entry;799 TypeTableEntry *enum_type = tag_int_type;
799 c->enum_type_table.put(bare_name, enum_type);800 c->enum_type_table.put(bare_name, enum_type);
800 c->decl_table.put(enum_decl, enum_type);801 c->decl_table.put(enum_decl, enum_type);
801802