Skip to content

Commit

Permalink
fix Issue 13147 - Wrong codegen for thisptr in naked extern (C++) met…
Browse files Browse the repository at this point in the history
…hods
  • Loading branch information
WalterBright authored and WalterWaldron committed May 5, 2016
1 parent 7c3ccd8 commit 940e48c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/func.d
Original file line number Diff line number Diff line change
Expand Up @@ -1695,6 +1695,12 @@ public:
if (!fbody)
fbody = new CompoundStatement(Loc(), new Statements());

if (naked)
{
fpreinv = null; // can't accommodate with no stack frame
fpostinv = null;
}

assert(type == f || (type.ty == Tfunction && f.purity == PUREimpure && (cast(TypeFunction)type).purity >= PUREfwdref));
f = cast(TypeFunction)type;

Expand Down
19 changes: 19 additions & 0 deletions test/runnable/testinvariant.d
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,30 @@ void test13113()
assert(S13113.count == 4);
}

/***************************************************/
// 13147

class C13147
{
extern (C++) C13147 test()
{
asm { naked; ret; }
return this;
}
}

void test13147()
{
auto c = new C13147();
c.test();
}

/***************************************************/

void main()
{
testinvariant();
test6453();
test13113();
test13147();
}

0 comments on commit 940e48c

Please sign in to comment.