diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ast/attrs.hpp | 2 | ||||
-rw-r--r-- | src/hir/deserialise.cpp | 4 | ||||
-rw-r--r-- | src/span.cpp | 4 | ||||
-rw-r--r-- | src/trans/codegen_c.cpp | 70 | ||||
-rw-r--r-- | src/trans/target.cpp | 7 | ||||
-rw-r--r-- | src/version.cpp | 8 |
6 files changed, 63 insertions, 32 deletions
diff --git a/src/ast/attrs.hpp b/src/ast/attrs.hpp index 1926e96a..0e1c8149 100644 --- a/src/ast/attrs.hpp +++ b/src/ast/attrs.hpp @@ -113,7 +113,7 @@ public: ) ) } - Attribute& operator=(const Attribute&& ) = delete; + Attribute& operator=(const Attribute& ) = delete; Attribute(Attribute&& ) = default; Attribute& operator=(Attribute&& ) = default; Attribute clone() const; diff --git a/src/hir/deserialise.cpp b/src/hir/deserialise.cpp index 17a93730..afce2fe4 100644 --- a/src/hir/deserialise.cpp +++ b/src/hir/deserialise.cpp @@ -734,7 +734,9 @@ ::HIR::LifetimeRef HirDeserialiser::deserialise_lifetimeref() { - return { static_cast<uint32_t>(m_in.read_count()) }; + ::HIR::LifetimeRef rv; + rv.binding = static_cast<uint32_t>(m_in.read_count()); + return rv; } ::HIR::TypeRef HirDeserialiser::deserialise_type() diff --git a/src/span.cpp b/src/span.cpp index 3d4d1ceb..eacdc7aa 100644 --- a/src/span.cpp +++ b/src/span.cpp @@ -59,7 +59,11 @@ namespace { void Span::bug(::std::function<void(::std::ostream&)> msg) const { print_span_message(*this, [](auto& os){os << "BUG";}, msg); +#ifndef _WIN32 abort(); +#else + exit(1); +#endif } void Span::error(ErrorType tag, ::std::function<void(::std::ostream&)> msg) const { diff --git a/src/trans/codegen_c.cpp b/src/trans/codegen_c.cpp index ca038230..322846e8 100644 --- a/src/trans/codegen_c.cpp +++ b/src/trans/codegen_c.cpp @@ -955,6 +955,7 @@ namespace { if( te.size() > 0 ) { m_of << "typedef struct "; emit_ctype(ty); m_of << " {\n"; + unsigned n_fields = 0; for(unsigned int i = 0; i < te.size(); i++) { m_of << "\t"; @@ -967,8 +968,13 @@ namespace { else { emit_ctype(te[i], FMT_CB(ss, ss << "_" << i;)); m_of << ";\n"; + n_fields += 1; } } + if( n_fields == 0 && m_options.disallow_empty_structs ) + { + m_of << "\tchar _d;\n"; + } m_of << "} "; emit_ctype(ty); m_of << ";\n"; } @@ -1315,36 +1321,40 @@ namespace { assert(1 + union_fields.size() + 1 >= repr->fields.size()); // Make the union! // NOTE: The way the structure generation works is that enum variants are always first, so the field index = the variant index - m_of << "\tunion {\n"; - // > First field + // TODO: + if( !this->type_is_bad_zst(repr->fields[0].ty) || ::std::any_of(union_fields.begin(), union_fields.end(), [this,repr](auto x){ return !this->type_is_bad_zst(repr->fields[x].ty); }) ) { - m_of << "\t\t"; - const auto& ty = repr->fields[0].ty; - if( this->type_is_bad_zst(ty) ) { - m_of << "// ZST: " << ty << "\n"; - } - else { - emit_ctype( ty, FMT_CB(ss, ss << "var_0") ); - m_of << ";\n"; - //sized_fields ++; + m_of << "\tunion {\n"; + // > First field + { + m_of << "\t\t"; + const auto& ty = repr->fields[0].ty; + if( this->type_is_bad_zst(ty) ) { + m_of << "// ZST: " << ty << "\n"; + } + else { + emit_ctype( ty, FMT_CB(ss, ss << "var_0") ); + m_of << ";\n"; + //sized_fields ++; + } } - } - // > All others - for(auto idx : union_fields) - { - m_of << "\t\t"; + // > All others + for(auto idx : union_fields) + { + m_of << "\t\t"; - const auto& ty = repr->fields[idx].ty; - if( this->type_is_bad_zst(ty) ) { - m_of << "// ZST: " << ty << "\n"; - } - else { - emit_ctype( ty, FMT_CB(ss, ss << "var_" << idx) ); - m_of << ";\n"; - //sized_fields ++; + const auto& ty = repr->fields[idx].ty; + if( this->type_is_bad_zst(ty) ) { + m_of << "// ZST: " << ty << "\n"; + } + else { + emit_ctype( ty, FMT_CB(ss, ss << "var_" << idx) ); + m_of << ";\n"; + //sized_fields ++; + } } + m_of << "\t} DATA;\n"; } - m_of << "\t} DATA;\n"; if( repr->fields.size() == 1 + union_fields.size() ) { @@ -1791,14 +1801,14 @@ namespace { m_of << "{"; const auto& ity = get_inner_type(e.idx, 0); if( this->type_is_bad_zst(ity) ) { - m_of << " {}"; + //m_of << " {}"; } else { m_of << " { .var_" << e.idx << " = "; emit_literal(ity, *e.val, params); - m_of << " }"; + m_of << " }, "; } - m_of << ", .TAG = "; emit_enum_variant_val(repr, e.idx); + m_of << ".TAG = "; emit_enum_variant_val(repr, e.idx); m_of << "}"; } ), @@ -3991,13 +4001,15 @@ namespace { m_of << name << o_before << "8" << o_after << "("; break; case ::HIR::CoreType::U16: + case ::HIR::CoreType::I16: m_of << name << o_before << "16" << o_after << "("; break; case ::HIR::CoreType::U32: + case ::HIR::CoreType::I32: m_of << name << o_before << o_after << "("; break; case ::HIR::CoreType::U64: - //case ::HIR::CoreType::I64: + case ::HIR::CoreType::I64: m_of << name << o_before << "64" << o_after << "("; break; case ::HIR::CoreType::Usize: diff --git a/src/trans/target.cpp b/src/trans/target.cpp index ea850937..f91b679a 100644 --- a/src/trans/target.cpp +++ b/src/trans/target.cpp @@ -691,7 +691,12 @@ bool Target_GetSizeAndAlignOf(const Span& sp, const StaticTraitResolve& resolve, case ::HIR::CoreType::I128: out_size = 16; // TODO: If i128 is emulated, this can be 8 (as it is on x86, where it's actually 4 due to the above comment) - out_align = g_target.m_arch.m_name == "x86" ? 4 : 16; + if( g_target.m_arch.m_name == "x86" ) + out_align = 4; + else if( /*g_target.m_arch.m_name == "x86_64" && */g_target.m_backend_c.m_codegen_mode == CodegenMode::Msvc ) + out_align = 8; + else + out_align = 16; return true; case ::HIR::CoreType::Usize: case ::HIR::CoreType::Isize: diff --git a/src/version.cpp b/src/version.cpp index d6307618..b40196ff 100644 --- a/src/version.cpp +++ b/src/version.cpp @@ -12,6 +12,14 @@ #define VERSION_MINOR 8 #define VERSION_PATCH 0 +#ifdef _WIN32 +# define VERSION_GIT_ISDIRTY 1 +# define VERSION_GIT_FULLHASH "" +# define VERSION_GIT_SHORTHASH "" +# define VERSION_BUILDTIME "" +# define VERSION_GIT_BRANCH "" +#endif + unsigned int giVersion_Major = VERSION_MAJOR; unsigned int giVersion_Minor = VERSION_MINOR; unsigned int giVersion_Patch = VERSION_PATCH; |