summaryrefslogtreecommitdiffstats
path: root/Source/cmIfCommand.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmIfCommand.cxx')
-rw-r--r--Source/cmIfCommand.cxx20
1 files changed, 20 insertions, 0 deletions
diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx
index a8fa4f9..421c3dd 100644
--- a/Source/cmIfCommand.cxx
+++ b/Source/cmIfCommand.cxx
@@ -57,8 +57,19 @@ bool cmIfFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
// watch for our state change
if (scopeDepth == 0 &&
!cmSystemTools::Strucmp(this->Functions[c].Name.c_str(), "else")) {
+
+ if (this->ElseSeen) {
+ cmListFileBacktrace bt = mf.GetBacktrace(this->Functions[c]);
+ mf.GetCMakeInstance()->IssueMessage(
+ cmake::FATAL_ERROR,
+ "A duplicate ELSE command was found inside an IF block.", bt);
+ cmSystemTools::SetFatalErrorOccured();
+ return true;
+ }
+
this->IsBlocking = this->HasRun;
this->HasRun = true;
+ this->ElseSeen = true;
// if trace is enabled, print a (trivially) evaluated "else"
// statement
@@ -68,6 +79,15 @@ bool cmIfFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
} else if (scopeDepth == 0 &&
!cmSystemTools::Strucmp(this->Functions[c].Name.c_str(),
"elseif")) {
+ if (this->ElseSeen) {
+ cmListFileBacktrace bt = mf.GetBacktrace(this->Functions[c]);
+ mf.GetCMakeInstance()->IssueMessage(
+ cmake::FATAL_ERROR,
+ "An ELSEIF command was found after an ELSE command.", bt);
+ cmSystemTools::SetFatalErrorOccured();
+ return true;
+ }
+
if (this->HasRun) {
this->IsBlocking = true;
} else {