Only allow a single D main() function.

Fixes DMD testcase 'fail5634'.
This commit is contained in:
David Nadlinger
2012-09-27 20:22:52 +02:00
parent 8968103b8b
commit f54fa0077a

View File

@@ -522,6 +522,11 @@ void DtoDeclareFunction(FuncDeclaration* fdecl)
// main
if (fdecl->isMain()) {
// Detect multiple main functions, which is disallowed. DMD checks this
// in the glue code, so we need to do it here as well.
if (gIR->mainFunc) {
error(fdecl->loc, "only one main function allowed");
}
gIR->mainFunc = func;
}