authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-01-13 17:33:19-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-01-13 17:33:19-05:00
log0c1800a9c9507dd1b06c70cb8950b13afe09f758
treead3f30397b6d83be6b8eb7ad6d62bab2e626f1dd
parent83f1a6fae24b9fa74ced6f8022f38be08d27a0c0

fix some stuff when llvm has assertions on


5 files changed, 19 insertions(+), 42 deletions(-)

CMakeLists.txt+1-1
......@@ -178,7 +178,7 @@ if(MINGW)
178178 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wno-error=format= -Wno-error=format -Wno-error=format-extra-args")
179179endif()
180180
181set(EXE_CFLAGS "-std=c++11 -fno-exceptions -fno-rtti -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__USE_MINGW_ANSI_STDIO -Werror=strict-prototypes -Werror=old-style-definition -Werror=type-limits")
181set(EXE_CFLAGS "-std=c++11 -fno-exceptions -fno-rtti -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__USE_MINGW_ANSI_STDIO -Werror=strict-prototypes -Werror=old-style-definition -Werror=type-limits -Wno-missing-braces")
182182set(EXE_LDFLAGS " ")
183183if(ZIG_TEST_COVERAGE)
184184 set(EXE_CFLAGS "${EXE_CFLAGS} -fprofile-arcs -ftest-coverage")
src/analyze.cpp+7-40
......@@ -1082,7 +1082,7 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c
10821082 return get_fn_type(g, &fn_type_id);
10831083}
10841084
1085static bool type_is_invalid(TypeTableEntry *type_entry) {
1085bool type_is_invalid(TypeTableEntry *type_entry) {
10861086 switch (type_entry->id) {
10871087 case TypeTableEntryIdInvalid:
10881088 return true;
......@@ -1118,6 +1118,9 @@ static void resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type) {
11181118 // if you change this logic you likely must also change similar logic in parseh.cpp
11191119 assert(enum_type->id == TypeTableEntryIdEnum);
11201120
1121 if (enum_type->data.enumeration.complete)
1122 return;
1123
11211124 resolve_enum_zero_bits(g, enum_type);
11221125 if (enum_type->data.enumeration.is_invalid)
11231126 return;
......@@ -1298,6 +1301,9 @@ static void resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) {
12981301 // parseh.cpp
12991302 assert(struct_type->id == TypeTableEntryIdStruct);
13001303
1304 if (struct_type->data.structure.complete)
1305 return;
1306
13011307 resolve_struct_zero_bits(g, struct_type);
13021308 if (struct_type->data.structure.is_invalid)
13031309 return;
......@@ -2045,45 +2051,6 @@ void resolve_top_level_decl(CodeGen *g, Tld *tld, bool pointer_only) {
20452051 tld->dep_loop_flag = false;
20462052}
20472053
2048static bool type_has_codegen_value(TypeTableEntry *type_entry) {
2049 switch (type_entry->id) {
2050 case TypeTableEntryIdInvalid:
2051 case TypeTableEntryIdMetaType:
2052 case TypeTableEntryIdVoid:
2053 case TypeTableEntryIdUnreachable:
2054 case TypeTableEntryIdNumLitFloat:
2055 case TypeTableEntryIdNumLitInt:
2056 case TypeTableEntryIdUndefLit:
2057 case TypeTableEntryIdNullLit:
2058 case TypeTableEntryIdNamespace:
2059 case TypeTableEntryIdBlock:
2060 case TypeTableEntryIdBoundFn:
2061 return false;
2062
2063 case TypeTableEntryIdBool:
2064 case TypeTableEntryIdInt:
2065 case TypeTableEntryIdFloat:
2066 case TypeTableEntryIdPointer:
2067 case TypeTableEntryIdArray:
2068 case TypeTableEntryIdStruct:
2069 case TypeTableEntryIdMaybe:
2070 case TypeTableEntryIdErrorUnion:
2071 case TypeTableEntryIdPureError:
2072 case TypeTableEntryIdEnum:
2073 case TypeTableEntryIdUnion:
2074 case TypeTableEntryIdFn:
2075 case TypeTableEntryIdEnumTag:
2076 return true;
2077
2078 case TypeTableEntryIdTypeDecl:
2079 return type_has_codegen_value(type_entry->data.type_decl.canonical_type);
2080
2081 case TypeTableEntryIdVar:
2082 zig_unreachable();
2083 }
2084 zig_unreachable();
2085}
2086
20872054bool types_match_const_cast_only(TypeTableEntry *expected_type, TypeTableEntry *actual_type) {
20882055 if (expected_type == actual_type)
20892056 return true;
src/analyze.hpp+1
......@@ -54,6 +54,7 @@ bool type_is_codegen_pointer(TypeTableEntry *type);
5454TypeTableEntry *validate_var_type(CodeGen *g, AstNode *source_node, TypeTableEntry *type_entry);
5555TypeTableEntry *container_ref_type(TypeTableEntry *type_entry);
5656bool type_is_complete(TypeTableEntry *type_entry);
57bool type_is_invalid(TypeTableEntry *type_entry);
5758bool type_has_zero_bits_known(TypeTableEntry *type_entry);
5859void resolve_container_type(CodeGen *g, TypeTableEntry *type_entry);
5960TypeStructField *find_struct_type_field(TypeTableEntry *type_entry, Buf *name);
src/parseh.cpp+1-1
......@@ -934,7 +934,7 @@ static TypeTableEntry *resolve_record_decl(Context *c, const RecordDecl *record_
934934 TypeTableEntry *field_type = resolve_qual_type(c, field_decl->getType(), field_decl);
935935 type_struct_field->type_entry = field_type;
936936
937 if (field_type->id == TypeTableEntryIdInvalid) {
937 if (type_is_invalid(field_type) || !type_is_complete(field_type)) {
938938 emit_warning(c, field_decl, "struct %s demoted to typedef - unresolved type\n", buf_ptr(bare_name));
939939 replace_with_fwd_decl(c, struct_type, full_type_name);
940940 return struct_type;
src/parser.cpp+9
......@@ -598,6 +598,7 @@ static AstNode *ast_parse_goto_expr(ParseContext *pc, size_t *token_index, bool
598598 *token_index += 2;
599599 } else if (mandatory) {
600600 ast_expect_token(pc, first_token, TokenIdKeywordGoto);
601 zig_unreachable();
601602 } else {
602603 return nullptr;
603604 }
......@@ -607,6 +608,7 @@ static AstNode *ast_parse_goto_expr(ParseContext *pc, size_t *token_index, bool
607608 *token_index += 1;
608609 } else if (mandatory) {
609610 ast_expect_token(pc, first_token, TokenIdKeywordGoto);
611 zig_unreachable();
610612 } else {
611613 return nullptr;
612614 }
......@@ -1605,6 +1607,7 @@ static AstNode *ast_parse_while_expr(ParseContext *pc, size_t *token_index, bool
16051607 *token_index += 2;
16061608 } else if (mandatory) {
16071609 ast_expect_token(pc, while_token, TokenIdKeywordWhile);
1610 zig_unreachable();
16081611 } else {
16091612 return nullptr;
16101613 }
......@@ -1614,6 +1617,7 @@ static AstNode *ast_parse_while_expr(ParseContext *pc, size_t *token_index, bool
16141617 *token_index += 1;
16151618 } else if (mandatory) {
16161619 ast_expect_token(pc, first_token, TokenIdKeywordWhile);
1620 zig_unreachable();
16171621 } else {
16181622 return nullptr;
16191623 }
......@@ -1663,6 +1667,7 @@ static AstNode *ast_parse_for_expr(ParseContext *pc, size_t *token_index, bool m
16631667 *token_index += 2;
16641668 } else if (mandatory) {
16651669 ast_expect_token(pc, first_token, TokenIdKeywordFor);
1670 zig_unreachable();
16661671 } else {
16671672 return nullptr;
16681673 }
......@@ -1672,6 +1677,7 @@ static AstNode *ast_parse_for_expr(ParseContext *pc, size_t *token_index, bool m
16721677 *token_index += 1;
16731678 } else if (mandatory) {
16741679 ast_expect_token(pc, first_token, TokenIdKeywordFor);
1680 zig_unreachable();
16751681 } else {
16761682 return nullptr;
16771683 }
......@@ -1726,6 +1732,7 @@ static AstNode *ast_parse_switch_expr(ParseContext *pc, size_t *token_index, boo
17261732 *token_index += 2;
17271733 } else if (mandatory) {
17281734 ast_expect_token(pc, first_token, TokenIdKeywordSwitch);
1735 zig_unreachable();
17291736 } else {
17301737 return nullptr;
17311738 }
......@@ -1735,6 +1742,7 @@ static AstNode *ast_parse_switch_expr(ParseContext *pc, size_t *token_index, boo
17351742 *token_index += 1;
17361743 } else if (mandatory) {
17371744 ast_expect_token(pc, first_token, TokenIdKeywordSwitch);
1745 zig_unreachable();
17381746 } else {
17391747 return nullptr;
17401748 }
......@@ -2112,6 +2120,7 @@ static AstNode *ast_parse_fn_proto(ParseContext *pc, size_t *token_index, bool m
21122120 *token_index += 1;
21132121 } else if (mandatory) {
21142122 ast_expect_token(pc, first_token, TokenIdKeywordFn);
2123 zig_unreachable();
21152124 } else {
21162125 return nullptr;
21172126 }