| author | |
| committer | |
| log | 0c1800a9c9507dd1b06c70cb8950b13afe09f758 |
| tree | ad3f30397b6d83be6b8eb7ad6d62bab2e626f1dd |
| parent | 83f1a6fae24b9fa74ced6f8022f38be08d27a0c0 |
5 files changed, 19 insertions(+), 42 deletions(-)
CMakeLists.txt+1-1| ... | @@ -178,7 +178,7 @@ if(MINGW) | ... | @@ -178,7 +178,7 @@ if(MINGW) |
| 178 | set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wno-error=format= -Wno-error=format -Wno-error=format-extra-args") | 178 | set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wno-error=format= -Wno-error=format -Wno-error=format-extra-args") |
| 179 | endif() | 179 | endif() |
| 180 | 180 | ||
| 181 | set(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") | 181 | set(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") |
| 182 | set(EXE_LDFLAGS " ") | 182 | set(EXE_LDFLAGS " ") |
| 183 | if(ZIG_TEST_COVERAGE) | 183 | if(ZIG_TEST_COVERAGE) |
| 184 | set(EXE_CFLAGS "${EXE_CFLAGS} -fprofile-arcs -ftest-coverage") | 184 | 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 | ... | @@ -1082,7 +1082,7 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c |
| 1082 | return get_fn_type(g, &fn_type_id); | 1082 | return get_fn_type(g, &fn_type_id); |
| 1083 | } | 1083 | } |
| 1084 | 1084 | ||
| 1085 | static bool type_is_invalid(TypeTableEntry *type_entry) { | 1085 | bool type_is_invalid(TypeTableEntry *type_entry) { |
| 1086 | switch (type_entry->id) { | 1086 | switch (type_entry->id) { |
| 1087 | case TypeTableEntryIdInvalid: | 1087 | case TypeTableEntryIdInvalid: |
| 1088 | return true; | 1088 | return true; |
| ... | @@ -1118,6 +1118,9 @@ static void resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type) { | ... | @@ -1118,6 +1118,9 @@ static void resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type) { |
| 1118 | // if you change this logic you likely must also change similar logic in parseh.cpp | 1118 | // if you change this logic you likely must also change similar logic in parseh.cpp |
| 1119 | assert(enum_type->id == TypeTableEntryIdEnum); | 1119 | assert(enum_type->id == TypeTableEntryIdEnum); |
| 1120 | 1120 | ||
| 1121 | if (enum_type->data.enumeration.complete) | ||
| 1122 | return; | ||
| 1123 | |||
| 1121 | resolve_enum_zero_bits(g, enum_type); | 1124 | resolve_enum_zero_bits(g, enum_type); |
| 1122 | if (enum_type->data.enumeration.is_invalid) | 1125 | if (enum_type->data.enumeration.is_invalid) |
| 1123 | return; | 1126 | return; |
| ... | @@ -1298,6 +1301,9 @@ static void resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) { | ... | @@ -1298,6 +1301,9 @@ static void resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) { |
| 1298 | // parseh.cpp | 1301 | // parseh.cpp |
| 1299 | assert(struct_type->id == TypeTableEntryIdStruct); | 1302 | assert(struct_type->id == TypeTableEntryIdStruct); |
| 1300 | 1303 | ||
| 1304 | if (struct_type->data.structure.complete) | ||
| 1305 | return; | ||
| 1306 | |||
| 1301 | resolve_struct_zero_bits(g, struct_type); | 1307 | resolve_struct_zero_bits(g, struct_type); |
| 1302 | if (struct_type->data.structure.is_invalid) | 1308 | if (struct_type->data.structure.is_invalid) |
| 1303 | return; | 1309 | return; |
| ... | @@ -2045,45 +2051,6 @@ void resolve_top_level_decl(CodeGen *g, Tld *tld, bool pointer_only) { | ... | @@ -2045,45 +2051,6 @@ void resolve_top_level_decl(CodeGen *g, Tld *tld, bool pointer_only) { |
| 2045 | tld->dep_loop_flag = false; | 2051 | tld->dep_loop_flag = false; |
| 2046 | } | 2052 | } |
| 2047 | 2053 | ||
| 2048 | static 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 | |||
| 2087 | bool types_match_const_cast_only(TypeTableEntry *expected_type, TypeTableEntry *actual_type) { | 2054 | bool types_match_const_cast_only(TypeTableEntry *expected_type, TypeTableEntry *actual_type) { |
| 2088 | if (expected_type == actual_type) | 2055 | if (expected_type == actual_type) |
| 2089 | return true; | 2056 | return true; |
src/analyze.hpp+1| ... | @@ -54,6 +54,7 @@ bool type_is_codegen_pointer(TypeTableEntry *type); | ... | @@ -54,6 +54,7 @@ bool type_is_codegen_pointer(TypeTableEntry *type); |
| 54 | TypeTableEntry *validate_var_type(CodeGen *g, AstNode *source_node, TypeTableEntry *type_entry); | 54 | TypeTableEntry *validate_var_type(CodeGen *g, AstNode *source_node, TypeTableEntry *type_entry); |
| 55 | TypeTableEntry *container_ref_type(TypeTableEntry *type_entry); | 55 | TypeTableEntry *container_ref_type(TypeTableEntry *type_entry); |
| 56 | bool type_is_complete(TypeTableEntry *type_entry); | 56 | bool type_is_complete(TypeTableEntry *type_entry); |
| 57 | bool type_is_invalid(TypeTableEntry *type_entry); | ||
| 57 | bool type_has_zero_bits_known(TypeTableEntry *type_entry); | 58 | bool type_has_zero_bits_known(TypeTableEntry *type_entry); |
| 58 | void resolve_container_type(CodeGen *g, TypeTableEntry *type_entry); | 59 | void resolve_container_type(CodeGen *g, TypeTableEntry *type_entry); |
| 59 | TypeStructField *find_struct_type_field(TypeTableEntry *type_entry, Buf *name); | 60 | TypeStructField *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_ | ... | @@ -934,7 +934,7 @@ static TypeTableEntry *resolve_record_decl(Context *c, const RecordDecl *record_ |
| 934 | TypeTableEntry *field_type = resolve_qual_type(c, field_decl->getType(), field_decl); | 934 | TypeTableEntry *field_type = resolve_qual_type(c, field_decl->getType(), field_decl); |
| 935 | type_struct_field->type_entry = field_type; | 935 | type_struct_field->type_entry = field_type; |
| 936 | 936 | ||
| 937 | if (field_type->id == TypeTableEntryIdInvalid) { | 937 | if (type_is_invalid(field_type) || !type_is_complete(field_type)) { |
| 938 | emit_warning(c, field_decl, "struct %s demoted to typedef - unresolved type\n", buf_ptr(bare_name)); | 938 | emit_warning(c, field_decl, "struct %s demoted to typedef - unresolved type\n", buf_ptr(bare_name)); |
| 939 | replace_with_fwd_decl(c, struct_type, full_type_name); | 939 | replace_with_fwd_decl(c, struct_type, full_type_name); |
| 940 | return struct_type; | 940 | return struct_type; |
src/parser.cpp+9| ... | @@ -598,6 +598,7 @@ static AstNode *ast_parse_goto_expr(ParseContext *pc, size_t *token_index, bool | ... | @@ -598,6 +598,7 @@ static AstNode *ast_parse_goto_expr(ParseContext *pc, size_t *token_index, bool |
| 598 | *token_index += 2; | 598 | *token_index += 2; |
| 599 | } else if (mandatory) { | 599 | } else if (mandatory) { |
| 600 | ast_expect_token(pc, first_token, TokenIdKeywordGoto); | 600 | ast_expect_token(pc, first_token, TokenIdKeywordGoto); |
| 601 | zig_unreachable(); | ||
| 601 | } else { | 602 | } else { |
| 602 | return nullptr; | 603 | return nullptr; |
| 603 | } | 604 | } |
| ... | @@ -607,6 +608,7 @@ static AstNode *ast_parse_goto_expr(ParseContext *pc, size_t *token_index, bool | ... | @@ -607,6 +608,7 @@ static AstNode *ast_parse_goto_expr(ParseContext *pc, size_t *token_index, bool |
| 607 | *token_index += 1; | 608 | *token_index += 1; |
| 608 | } else if (mandatory) { | 609 | } else if (mandatory) { |
| 609 | ast_expect_token(pc, first_token, TokenIdKeywordGoto); | 610 | ast_expect_token(pc, first_token, TokenIdKeywordGoto); |
| 611 | zig_unreachable(); | ||
| 610 | } else { | 612 | } else { |
| 611 | return nullptr; | 613 | return nullptr; |
| 612 | } | 614 | } |
| ... | @@ -1605,6 +1607,7 @@ static AstNode *ast_parse_while_expr(ParseContext *pc, size_t *token_index, bool | ... | @@ -1605,6 +1607,7 @@ static AstNode *ast_parse_while_expr(ParseContext *pc, size_t *token_index, bool |
| 1605 | *token_index += 2; | 1607 | *token_index += 2; |
| 1606 | } else if (mandatory) { | 1608 | } else if (mandatory) { |
| 1607 | ast_expect_token(pc, while_token, TokenIdKeywordWhile); | 1609 | ast_expect_token(pc, while_token, TokenIdKeywordWhile); |
| 1610 | zig_unreachable(); | ||
| 1608 | } else { | 1611 | } else { |
| 1609 | return nullptr; | 1612 | return nullptr; |
| 1610 | } | 1613 | } |
| ... | @@ -1614,6 +1617,7 @@ static AstNode *ast_parse_while_expr(ParseContext *pc, size_t *token_index, bool | ... | @@ -1614,6 +1617,7 @@ static AstNode *ast_parse_while_expr(ParseContext *pc, size_t *token_index, bool |
| 1614 | *token_index += 1; | 1617 | *token_index += 1; |
| 1615 | } else if (mandatory) { | 1618 | } else if (mandatory) { |
| 1616 | ast_expect_token(pc, first_token, TokenIdKeywordWhile); | 1619 | ast_expect_token(pc, first_token, TokenIdKeywordWhile); |
| 1620 | zig_unreachable(); | ||
| 1617 | } else { | 1621 | } else { |
| 1618 | return nullptr; | 1622 | return nullptr; |
| 1619 | } | 1623 | } |
| ... | @@ -1663,6 +1667,7 @@ static AstNode *ast_parse_for_expr(ParseContext *pc, size_t *token_index, bool m | ... | @@ -1663,6 +1667,7 @@ static AstNode *ast_parse_for_expr(ParseContext *pc, size_t *token_index, bool m |
| 1663 | *token_index += 2; | 1667 | *token_index += 2; |
| 1664 | } else if (mandatory) { | 1668 | } else if (mandatory) { |
| 1665 | ast_expect_token(pc, first_token, TokenIdKeywordFor); | 1669 | ast_expect_token(pc, first_token, TokenIdKeywordFor); |
| 1670 | zig_unreachable(); | ||
| 1666 | } else { | 1671 | } else { |
| 1667 | return nullptr; | 1672 | return nullptr; |
| 1668 | } | 1673 | } |
| ... | @@ -1672,6 +1677,7 @@ static AstNode *ast_parse_for_expr(ParseContext *pc, size_t *token_index, bool m | ... | @@ -1672,6 +1677,7 @@ static AstNode *ast_parse_for_expr(ParseContext *pc, size_t *token_index, bool m |
| 1672 | *token_index += 1; | 1677 | *token_index += 1; |
| 1673 | } else if (mandatory) { | 1678 | } else if (mandatory) { |
| 1674 | ast_expect_token(pc, first_token, TokenIdKeywordFor); | 1679 | ast_expect_token(pc, first_token, TokenIdKeywordFor); |
| 1680 | zig_unreachable(); | ||
| 1675 | } else { | 1681 | } else { |
| 1676 | return nullptr; | 1682 | return nullptr; |
| 1677 | } | 1683 | } |
| ... | @@ -1726,6 +1732,7 @@ static AstNode *ast_parse_switch_expr(ParseContext *pc, size_t *token_index, boo | ... | @@ -1726,6 +1732,7 @@ static AstNode *ast_parse_switch_expr(ParseContext *pc, size_t *token_index, boo |
| 1726 | *token_index += 2; | 1732 | *token_index += 2; |
| 1727 | } else if (mandatory) { | 1733 | } else if (mandatory) { |
| 1728 | ast_expect_token(pc, first_token, TokenIdKeywordSwitch); | 1734 | ast_expect_token(pc, first_token, TokenIdKeywordSwitch); |
| 1735 | zig_unreachable(); | ||
| 1729 | } else { | 1736 | } else { |
| 1730 | return nullptr; | 1737 | return nullptr; |
| 1731 | } | 1738 | } |
| ... | @@ -1735,6 +1742,7 @@ static AstNode *ast_parse_switch_expr(ParseContext *pc, size_t *token_index, boo | ... | @@ -1735,6 +1742,7 @@ static AstNode *ast_parse_switch_expr(ParseContext *pc, size_t *token_index, boo |
| 1735 | *token_index += 1; | 1742 | *token_index += 1; |
| 1736 | } else if (mandatory) { | 1743 | } else if (mandatory) { |
| 1737 | ast_expect_token(pc, first_token, TokenIdKeywordSwitch); | 1744 | ast_expect_token(pc, first_token, TokenIdKeywordSwitch); |
| 1745 | zig_unreachable(); | ||
| 1738 | } else { | 1746 | } else { |
| 1739 | return nullptr; | 1747 | return nullptr; |
| 1740 | } | 1748 | } |
| ... | @@ -2112,6 +2120,7 @@ static AstNode *ast_parse_fn_proto(ParseContext *pc, size_t *token_index, bool m | ... | @@ -2112,6 +2120,7 @@ static AstNode *ast_parse_fn_proto(ParseContext *pc, size_t *token_index, bool m |
| 2112 | *token_index += 1; | 2120 | *token_index += 1; |
| 2113 | } else if (mandatory) { | 2121 | } else if (mandatory) { |
| 2114 | ast_expect_token(pc, first_token, TokenIdKeywordFn); | 2122 | ast_expect_token(pc, first_token, TokenIdKeywordFn); |
| 2123 | zig_unreachable(); | ||
| 2115 | } else { | 2124 | } else { |
| 2116 | return nullptr; | 2125 | return nullptr; |
| 2117 | } | 2126 | } |