diff --git a/gen/functions.cpp b/gen/functions.cpp index 73eb433e..438a167d 100644 --- a/gen/functions.cpp +++ b/gen/functions.cpp @@ -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; }