diff options
author | Alex Turbov <i.zaufi@gmail.com> | 2021-08-09 17:58:27 (GMT) |
---|---|---|
committer | Alex Turbov <i.zaufi@gmail.com> | 2021-08-09 19:35:11 (GMT) |
commit | 880ca66b51551d5ee732c7b81349c1a5f724d093 (patch) | |
tree | fd40673ed1a024227edcc53a310ff52dc1eaaae8 /Source/cmWhileCommand.cxx | |
parent | 61b33c3f4eae3ce81df36c79ec69630cd9fcefdc (diff) | |
download | CMake-880ca66b51551d5ee732c7b81349c1a5f724d093.zip CMake-880ca66b51551d5ee732c7b81349c1a5f724d093.tar.gz CMake-880ca66b51551d5ee732c7b81349c1a5f724d093.tar.bz2 |
Fix: `while()` can silently ignore incorrect condition
When `conditionEvaluator.IsTrue(...)` returns `false` it just
didn't print the error occured.
Diffstat (limited to 'Source/cmWhileCommand.cxx')
-rw-r--r-- | Source/cmWhileCommand.cxx | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/Source/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx index 327c1c7..1363386 100644 --- a/Source/cmWhileCommand.cxx +++ b/Source/cmWhileCommand.cxx @@ -75,24 +75,6 @@ bool cmWhileFunctionBlocker::Replay(std::vector<cmListFileFunction> functions, conditionEvaluator.IsTrue(expandedArguments, errorString, messageType); while (isTrue) { - if (!errorString.empty()) { - std::string err = "had incorrect arguments: "; - for (cmListFileArgument const& arg : this->Args) { - err += (arg.Delim ? "\"" : ""); - err += arg.Value; - err += (arg.Delim ? "\"" : ""); - err += " "; - } - err += "("; - err += errorString; - err += ")."; - mf.GetCMakeInstance()->IssueMessage(messageType, err, whileBT); - if (messageType == MessageType::FATAL_ERROR) { - cmSystemTools::SetFatalErrorOccured(); - return true; - } - } - // Invoke all the functions that were collected in the block. for (cmListFileFunction const& fn : functions) { cmExecutionStatus status(mf); @@ -116,6 +98,24 @@ bool cmWhileFunctionBlocker::Replay(std::vector<cmListFileFunction> functions, isTrue = conditionEvaluator.IsTrue(expandedArguments, errorString, messageType); } + + if (!isTrue && !errorString.empty()) { + std::string err = "had incorrect arguments: "; + for (cmListFileArgument const& arg : this->Args) { + err += (arg.Delim ? "\"" : ""); + err += arg.Value; + err += (arg.Delim ? "\"" : ""); + err += " "; + } + err += "("; + err += errorString; + err += ")."; + mf.GetCMakeInstance()->IssueMessage(messageType, err, whileBT); + if (messageType == MessageType::FATAL_ERROR) { + cmSystemTools::SetFatalErrorOccured(); + } + } + return true; } |