From f54fa0077a821ac574a70da336503a5ee52dbb63 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Thu, 27 Sep 2012 20:22:52 +0200 Subject: [PATCH] Only allow a single D main() function. Fixes DMD testcase 'fail5634'. --- gen/functions.cpp | 5 +++++ 1 file changed, 5 insertions(+) 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; }