Fix: Regression in the cmConditionEvaluator::HandleLevel0

As reported in the BUG #22524, mismatched parenthesis reported differently
for `while()` and `if()`.

The problem was in the double loop (over "handlers" and the arguments),
where the outer loop didn't check the result of the running handler.
This commit is contained in:
Alex Turbov
2021-08-09 20:35:56 +03:00
parent 7e3250da2f
commit 61b33c3f4e
7 changed files with 36 additions and 1 deletions
+7 -1
View File
@@ -260,11 +260,17 @@ bool cmConditionEvaluator::IsTrue(
for (auto fn : handlers) {
// Call the reducer 'till there is anything to reduce...
// (i.e., if after an iteration the size becomes smaller)
auto levelResult = true;
for (auto beginSize = newArgs.size();
(this->*fn)(newArgs, errorString, status) &&
(levelResult = (this->*fn)(newArgs, errorString, status)) &&
newArgs.size() < beginSize;
beginSize = newArgs.size()) {
}
if (!levelResult) {
// NOTE `errorString` supposed to be set already
return false;
}
}
// now at the end there should only be one argument left