diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-01-13 17:33:19 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-01-13 17:33:19 -0500 |
| commit | 0c1800a9c9507dd1b06c70cb8950b13afe09f758 (patch) | |
| tree | ad3f30397b6d83be6b8eb7ad6d62bab2e626f1dd /src | |
| parent | 83f1a6fae24b9fa74ced6f8022f38be08d27a0c0 (diff) | |
| download | zig-0c1800a9c9507dd1b06c70cb8950b13afe09f758.tar.gz zig-0c1800a9c9507dd1b06c70cb8950b13afe09f758.zip | |
fix some stuff when llvm has assertions on
Diffstat (limited to 'src')
| -rw-r--r-- | src/analyze.cpp | 47 | ||||
| -rw-r--r-- | src/analyze.hpp | 1 | ||||
| -rw-r--r-- | src/parseh.cpp | 2 | ||||
| -rw-r--r-- | src/parser.cpp | 9 |
4 files changed, 18 insertions, 41 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp index 58e6ec5498..b8fa326ca0 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -1082,7 +1082,7 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c return get_fn_type(g, &fn_type_id); } -static bool type_is_invalid(TypeTableEntry *type_entry) { +bool type_is_invalid(TypeTableEntry *type_entry) { switch (type_entry->id) { case TypeTableEntryIdInvalid: return true; @@ -1118,6 +1118,9 @@ static void resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type) { // if you change this logic you likely must also change similar logic in parseh.cpp assert(enum_type->id == TypeTableEntryIdEnum); + if (enum_type->data.enumeration.complete) + return; + resolve_enum_zero_bits(g, enum_type); if (enum_type->data.enumeration.is_invalid) return; @@ -1298,6 +1301,9 @@ static void resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) { // parseh.cpp assert(struct_type->id == TypeTableEntryIdStruct); + if (struct_type->data.structure.complete) + return; + resolve_struct_zero_bits(g, struct_type); if (struct_type->data.structure.is_invalid) return; @@ -2045,45 +2051,6 @@ void resolve_top_level_decl(CodeGen *g, Tld *tld, bool pointer_only) { tld->dep_loop_flag = false; } -static bool type_has_codegen_value(TypeTableEntry *type_entry) { - switch (type_entry->id) { - case TypeTableEntryIdInvalid: - case TypeTableEntryIdMetaType: - case TypeTableEntryIdVoid: - case TypeTableEntryIdUnreachable: - case TypeTableEntryIdNumLitFloat: - case TypeTableEntryIdNumLitInt: - case TypeTableEntryIdUndefLit: - case TypeTableEntryIdNullLit: - case TypeTableEntryIdNamespace: - case TypeTableEntryIdBlock: - case TypeTableEntryIdBoundFn: - return false; - - case TypeTableEntryIdBool: - case TypeTableEntryIdInt: - case TypeTableEntryIdFloat: - case TypeTableEntryIdPointer: - case TypeTableEntryIdArray: - case TypeTableEntryIdStruct: - case TypeTableEntryIdMaybe: - case TypeTableEntryIdErrorUnion: - case TypeTableEntryIdPureError: - case TypeTableEntryIdEnum: - case TypeTableEntryIdUnion: - case TypeTableEntryIdFn: - case TypeTableEntryIdEnumTag: - return true; - - case TypeTableEntryIdTypeDecl: - return type_has_codegen_value(type_entry->data.type_decl.canonical_type); - - case TypeTableEntryIdVar: - zig_unreachable(); - } - zig_unreachable(); -} - bool types_match_const_cast_only(TypeTableEntry *expected_type, TypeTableEntry *actual_type) { if (expected_type == actual_type) return true; diff --git a/src/analyze.hpp b/src/analyze.hpp index 2fef9cc0d8..50b16e67b1 100644 --- a/src/analyze.hpp +++ b/src/analyze.hpp @@ -54,6 +54,7 @@ bool type_is_codegen_pointer(TypeTableEntry *type); TypeTableEntry *validate_var_type(CodeGen *g, AstNode *source_node, TypeTableEntry *type_entry); TypeTableEntry *container_ref_type(TypeTableEntry *type_entry); bool type_is_complete(TypeTableEntry *type_entry); +bool type_is_invalid(TypeTableEntry *type_entry); bool type_has_zero_bits_known(TypeTableEntry *type_entry); void resolve_container_type(CodeGen *g, TypeTableEntry *type_entry); TypeStructField *find_struct_type_field(TypeTableEntry *type_entry, Buf *name); diff --git a/src/parseh.cpp b/src/parseh.cpp index 7e04a78d36..94f430cdfa 100644 --- a/src/parseh.cpp +++ b/src/parseh.cpp @@ -934,7 +934,7 @@ static TypeTableEntry *resolve_record_decl(Context *c, const RecordDecl *record_ TypeTableEntry *field_type = resolve_qual_type(c, field_decl->getType(), field_decl); type_struct_field->type_entry = field_type; - if (field_type->id == TypeTableEntryIdInvalid) { + if (type_is_invalid(field_type) || !type_is_complete(field_type)) { emit_warning(c, field_decl, "struct %s demoted to typedef - unresolved type\n", buf_ptr(bare_name)); replace_with_fwd_decl(c, struct_type, full_type_name); return struct_type; diff --git a/src/parser.cpp b/src/parser.cpp index a27927cb05..6b602c122f 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -598,6 +598,7 @@ static AstNode *ast_parse_goto_expr(ParseContext *pc, size_t *token_index, bool *token_index += 2; } else if (mandatory) { ast_expect_token(pc, first_token, TokenIdKeywordGoto); + zig_unreachable(); } else { return nullptr; } @@ -607,6 +608,7 @@ static AstNode *ast_parse_goto_expr(ParseContext *pc, size_t *token_index, bool *token_index += 1; } else if (mandatory) { ast_expect_token(pc, first_token, TokenIdKeywordGoto); + zig_unreachable(); } else { return nullptr; } @@ -1605,6 +1607,7 @@ static AstNode *ast_parse_while_expr(ParseContext *pc, size_t *token_index, bool *token_index += 2; } else if (mandatory) { ast_expect_token(pc, while_token, TokenIdKeywordWhile); + zig_unreachable(); } else { return nullptr; } @@ -1614,6 +1617,7 @@ static AstNode *ast_parse_while_expr(ParseContext *pc, size_t *token_index, bool *token_index += 1; } else if (mandatory) { ast_expect_token(pc, first_token, TokenIdKeywordWhile); + zig_unreachable(); } else { return nullptr; } @@ -1663,6 +1667,7 @@ static AstNode *ast_parse_for_expr(ParseContext *pc, size_t *token_index, bool m *token_index += 2; } else if (mandatory) { ast_expect_token(pc, first_token, TokenIdKeywordFor); + zig_unreachable(); } else { return nullptr; } @@ -1672,6 +1677,7 @@ static AstNode *ast_parse_for_expr(ParseContext *pc, size_t *token_index, bool m *token_index += 1; } else if (mandatory) { ast_expect_token(pc, first_token, TokenIdKeywordFor); + zig_unreachable(); } else { return nullptr; } @@ -1726,6 +1732,7 @@ static AstNode *ast_parse_switch_expr(ParseContext *pc, size_t *token_index, boo *token_index += 2; } else if (mandatory) { ast_expect_token(pc, first_token, TokenIdKeywordSwitch); + zig_unreachable(); } else { return nullptr; } @@ -1735,6 +1742,7 @@ static AstNode *ast_parse_switch_expr(ParseContext *pc, size_t *token_index, boo *token_index += 1; } else if (mandatory) { ast_expect_token(pc, first_token, TokenIdKeywordSwitch); + zig_unreachable(); } else { return nullptr; } @@ -2112,6 +2120,7 @@ static AstNode *ast_parse_fn_proto(ParseContext *pc, size_t *token_index, bool m *token_index += 1; } else if (mandatory) { ast_expect_token(pc, first_token, TokenIdKeywordFn); + zig_unreachable(); } else { return nullptr; } |
