summaryrefslogtreecommitdiffstats
path: root/Source/cmIfCommand.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmIfCommand.cxx')
-rw-r--r--Source/cmIfCommand.cxx26
1 files changed, 23 insertions, 3 deletions
diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx
index a8fa4f9..0972664 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 {
@@ -117,15 +137,15 @@ bool cmIfFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
status.Clear();
mf.ExecuteCommand(this->Functions[c], status);
if (status.GetReturnInvoked()) {
- inStatus.SetReturnInvoked(true);
+ inStatus.SetReturnInvoked();
return true;
}
if (status.GetBreakInvoked()) {
- inStatus.SetBreakInvoked(true);
+ inStatus.SetBreakInvoked();
return true;
}
if (status.GetContinueInvoked()) {
- inStatus.SetContinueInvoked(true);
+ inStatus.SetContinueInvoked();
return true;
}
}