diff options
author | John Hodge <tpg@mutabah.net> | 2018-04-01 10:14:06 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2018-04-01 10:14:06 +0800 |
commit | c643adf22ea365bd7c8ed40f971c0cc99c9cf2a6 (patch) | |
tree | 3200ed061ff02ab85b971ac5151ee2583ab02718 /src/trans | |
parent | 26a349ebb09474cc022d228786603f62504fc1e4 (diff) | |
download | mrust-c643adf22ea365bd7c8ed40f971c0cc99c9cf2a6.tar.gz |
Codegen C - Fix compilation error in cargo (#66)
Diffstat (limited to 'src/trans')
-rw-r--r-- | src/trans/codegen_c.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/trans/codegen_c.cpp b/src/trans/codegen_c.cpp index ad7c9f2d..0171f19f 100644 --- a/src/trans/codegen_c.cpp +++ b/src/trans/codegen_c.cpp @@ -1287,7 +1287,11 @@ namespace { void emit_constructor_enum(const Span& sp, const ::HIR::GenericPath& path, const ::HIR::Enum& item, size_t var_idx) override { + ::MIR::Function empty_fcn; + ::MIR::TypeResolve top_mir_res { sp, m_resolve, FMT_CB(ss, ss << "enum cons " << path;), ::HIR::TypeRef(), {}, empty_fcn }; + m_mir_res = &top_mir_res; TRACE_FUNCTION_F(path << " var_idx=" << var_idx); + ::HIR::TypeRef tmp; auto monomorph = [&](const auto& x)->const auto& { if( monomorphise_type_needed(x) ) { @@ -1349,17 +1353,25 @@ namespace { else { m_of << " .DATA = { .var_" << var_idx << " = {"; - for(unsigned int i = 0; i < e.size(); i ++) + if( this->type_is_bad_zst(repr->fields[var_idx].ty) ) { - if(i != 0) - m_of << ","; - m_of << "\n\t\t_" << i; + m_of << "\n\t\t0"; + } + else + { + for(unsigned int i = 0; i < e.size(); i ++) + { + if(i != 0) + m_of << ","; + m_of << "\n\t\t_" << i; + } } m_of << "\n\t\t}"; } m_of << " }};\n"; m_of << "\treturn rv;\n"; m_of << "}\n"; + m_mir_res = nullptr; } void emit_constructor_struct(const Span& sp, const ::HIR::GenericPath& p, const ::HIR::Struct& item) override { |