Skip to content

Commit

Permalink
Merge pull request #1938 from WalterBright/fix9931
Browse files Browse the repository at this point in the history
fix Issue 9931 - Mac OS X ABI not followed when returning structs for extern (C)
  • Loading branch information
MartinNowak committed Apr 26, 2013
2 parents 33b9548 + a2c2ddc commit 5167cc1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/e2ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ elem *callfunc(Loc loc,
int reverse;
TypeFunction *tf;
int op;
elem *eresult = ehidden;

#if 0
printf("callfunc(directcall = %d, tret = '%s', ec = %p, fd = %p)\n",
Expand Down Expand Up @@ -211,6 +212,7 @@ elem *callfunc(Loc loc,
tc = type_fake(tret->totym());
Symbol *stmp = symbol_genauto(tc);
ehidden = el_ptr(stmp);
eresult = ehidden;
}
if ((global.params.isLinux ||
global.params.isOSX ||
Expand Down Expand Up @@ -371,6 +373,10 @@ if (I32) assert(tysize[TYnptr] == 4);

if (retmethod == RETstack)
{
if (global.params.isOSX && eresult)
/* ABI quirk: hidden pointer is not returned in registers
*/
e = el_combine(e, el_copytree(eresult));
e->Ety = TYnptr;
e = el_una(OPind, tyret, e);
}
Expand Down

0 comments on commit 5167cc1

Please sign in to comment.