Skip to content

Commit

Permalink
Issue 2350 - Contracts with a naked body are indecent
Browse files Browse the repository at this point in the history
Error on a naked function with contracts instead of generating wrong code
  • Loading branch information
yebblies committed Aug 31, 2014
1 parent bace9da commit a643c1e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/func.c
Expand Up @@ -314,7 +314,7 @@ FuncDeclaration::FuncDeclaration(Loc loc, Loc endloc, Identifier *id, StorageCla
overnext0 = NULL;
vtblIndex = -1;
hasReturnExp = 0;
naked = 0;
naked = false;
inlineStatusExp = ILSuninitialized;
inlineStatusStmt = ILSuninitialized;
inlineNest = 0;
Expand Down Expand Up @@ -2115,6 +2115,9 @@ void FuncDeclaration::semantic3(Scope *sc)
}
}

if (naked && (fensure || frequire))
error("naked assembly functions with contracts are not supported");

sc2->callSuper = 0;
sc2->pop();
}
Expand Down
15 changes: 15 additions & 0 deletions test/fail_compilation/fail2350.d
@@ -0,0 +1,15 @@
/*
TEST_OUTPUT:
---
fail_compilation/fail2350.d(8): Error: function fail2350.test2350 naked assembly functions with contracts are not supported
---
*/

void test2350()
in
{
}
body
{
asm { naked; }
}

0 comments on commit a643c1e

Please sign in to comment.