Fixed segfault on invalid naked functions.

Emitting a frontend error during codegen is somewhat problematic in
any case, but stopping if an error ocurred should work just fine here.
This commit is contained in:
David Nadlinger
2012-09-07 03:51:33 +02:00
parent 45d9efb203
commit 6275c66a89
+6 -1
View File
@@ -18,7 +18,7 @@
void Statement::toNakedIR(IRState *p) void Statement::toNakedIR(IRState *p)
{ {
error("not allowed in naked function"); error("statement not allowed in naked function");
} }
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
@@ -179,6 +179,11 @@ void DtoDefineNakedFunction(FuncDeclaration* fd)
// emit body // emit body
fd->fbody->toNakedIR(gIR); fd->fbody->toNakedIR(gIR);
// We could have generated new errors in toNakedIR(), but we are in codegen
// already so we have to abort here.
if (global.errors)
fatal();
// emit size after body // emit size after body
// llvm does this on linux, but not on osx or Win // llvm does this on linux, but not on osx or Win
if (global.params.os != OSMacOSX && global.params.os != OSWindows) if (global.params.os != OSMacOSX && global.params.os != OSWindows)