diff options
author | John Hodge <tpg@mutabah.net> | 2018-03-30 15:13:37 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2018-03-30 15:17:17 +0800 |
commit | 20354a7ce66167150c046d3745b02f2501d2f5b3 (patch) | |
tree | 5e99387c6e0d4e68d583beb68a68e9095e1b488c /src/trans/codegen_c.cpp | |
parent | cb4f7855057ade06cceec236774ed59aa03f67ba (diff) | |
download | mrust-20354a7ce66167150c046d3745b02f2501d2f5b3.tar.gz |
Codegen C - Fix ZST handling
Diffstat (limited to 'src/trans/codegen_c.cpp')
-rw-r--r-- | src/trans/codegen_c.cpp | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/trans/codegen_c.cpp b/src/trans/codegen_c.cpp index 87d96abb..b709b6e8 100644 --- a/src/trans/codegen_c.cpp +++ b/src/trans/codegen_c.cpp @@ -213,6 +213,7 @@ namespace { { m_options.emulated_i128 = true; } + m_options.disallow_empty_structs = true; break; case CodegenMode::Msvc: m_compiler = Compiler::Msvc; @@ -706,10 +707,20 @@ namespace { ::std::cerr << "INVOKE CC: " << cmd_ss.str() << ::std::endl; ::std::ofstream(opt.build_command_file) << cmd_ss.str() << ::std::endl; } - else if( system(cmd_ss.str().c_str()) != 0 ) + else { - ::std::cerr << "C Compiler failed to execute" << ::std::endl; - abort(); + int ec = system(cmd_ss.str().c_str()); + if( ec == -1 ) + { + ::std::cerr << "C Compiler failed to execute (system returned -1)" << ::std::endl; + perror("system"); + exit(1); + } + else if( ec != 0 ) + { + ::std::cerr << "C Compiler failed to execute - error code " << ec << ::std::endl; + exit(1); + } } } @@ -3337,6 +3348,11 @@ namespace { const auto& name = e.fcn.as_Intrinsic().name; const auto& params = e.fcn.as_Intrinsic().params; emit_intrinsic_call(name, params, e); + if( has_zst ) + { + indent.n --; + m_of << indent << "}\n"; + } return ; ) ) @@ -3968,7 +3984,10 @@ namespace { m_of << "memset( &"; emit_lvalue(e.ret_val); m_of << ", 0, sizeof("; emit_ctype(params.m_types.at(0)); m_of << "))"; } else if( name == "move_val_init" ) { - m_of << "*"; emit_param(e.args.at(0)); m_of << " = "; emit_param(e.args.at(1)); + if( !this->type_is_bad_zst(params.m_types.at(0)) ) + { + m_of << "*"; emit_param(e.args.at(0)); m_of << " = "; emit_param(e.args.at(1)); + } } else if( name == "abort" ) { m_of << "abort()"; |