Skip to content

Commit

Permalink
Codegen C - Handle high-align types in struct/enum constructors (#208)
Browse files Browse the repository at this point in the history
  • Loading branch information
thepowersgang committed Jan 4, 2022
1 parent 9c6fe86 commit 270a07a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/trans/codegen_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2092,7 +2092,8 @@ namespace {
{
if(i != 0)
m_of << ", ";
emit_ctype( args[i].second, FMT_CB(ss, ss << "arg" << i;) );
const auto& ty = args[i].second; // already monomorphised
emit_ctype( ty, FMT_CB(ss, ss << (this->type_is_high_align(ty) ? "*" : "") << "arg" << i;) );
}
m_of << ") {\n";

Expand Down Expand Up @@ -2132,19 +2133,21 @@ namespace {
{
if(i != 0)
m_of << ", ";
emit_ctype( monomorph(e[i].ent), FMT_CB(ss, ss << "_" << i;) );
const auto& ty = monomorph(e[i].ent);
emit_ctype( ty, FMT_CB(ss, ss << (this->type_is_high_align(ty) ? "*" : "") << "_" << i;) );
}
m_of << ") {\n";
m_of << "\tstruct s_" << Trans_Mangle(p) << " rv = {";
bool emitted = false;
for(unsigned int i = 0; i < e.size(); i ++)
{
if( this->type_is_bad_zst(monomorph(e[i].ent)) )
const auto& ty = monomorph(e[i].ent);
if( this->type_is_bad_zst(ty) )
continue ;
if(emitted)
m_of << ",";
emitted = true;
m_of << "\n\t\t_" << i;
m_of << "\n\t\t" << (this->type_is_high_align(ty) ? "*" : "") << "_" << i;
}
if( !emitted )
{
Expand Down

0 comments on commit 270a07a

Please sign in to comment.