mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-22 06:59:01 -06:00
Merge branch 'while-bug-compatibility' into release-3.22
Merge-request: !7041
This commit is contained in:
@@ -79,12 +79,17 @@ bool cmWhileFunctionBlocker::Replay(std::vector<cmListFileFunction> functions,
|
||||
return out;
|
||||
};
|
||||
|
||||
// FIXME(#23296): For compatibility with older versions of CMake, we
|
||||
// tolerate condition errors that evaluate to false. We should add
|
||||
// a policy to enforce such errors.
|
||||
bool enforceError = true;
|
||||
std::string errorString;
|
||||
MessageType messageType;
|
||||
|
||||
for (cmConditionEvaluator conditionEvaluator(mf, whileBT);
|
||||
conditionEvaluator.IsTrue(expandArgs(this->Args, expandedArguments),
|
||||
errorString, messageType);) {
|
||||
(enforceError = /* enforce condition errors that evaluate to true */
|
||||
conditionEvaluator.IsTrue(expandArgs(this->Args, expandedArguments),
|
||||
errorString, messageType));) {
|
||||
// Invoke all the functions that were collected in the block.
|
||||
for (cmListFileFunction const& fn : functions) {
|
||||
cmExecutionStatus status(mf);
|
||||
@@ -105,7 +110,7 @@ bool cmWhileFunctionBlocker::Replay(std::vector<cmListFileFunction> functions,
|
||||
}
|
||||
}
|
||||
|
||||
if (!errorString.empty()) {
|
||||
if (!errorString.empty() && enforceError) {
|
||||
std::string err = "had incorrect arguments:\n ";
|
||||
for (auto const& i : expandedArguments) {
|
||||
err += " ";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
CMake Error at unbalanced-parenthesis\.cmake:[0-9]+ \(if\):
|
||||
if given arguments:
|
||||
|
||||
"NOT" "\(" "IN_LIST" "some_list"
|
||||
"\("
|
||||
|
||||
mismatched parenthesis in condition
|
||||
Call Stack \(most recent call first\):
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
set(var_with_paren "(")
|
||||
set(some_list "")
|
||||
|
||||
if(NOT ${var_with_paren} IN_LIST some_list)
|
||||
message(STATUS "Never prints")
|
||||
else()
|
||||
message(STATUS "Never prints")
|
||||
set(paren "(")
|
||||
if(${paren})
|
||||
message(STATUS "Condition incorrectly true")
|
||||
endif()
|
||||
message(STATUS "Code incorrectly accepted")
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
1
|
||||
@@ -1,8 +0,0 @@
|
||||
CMake Error at unbalanced-parenthesis.cmake:[0-9]+ \(while\):
|
||||
had incorrect arguments:
|
||||
|
||||
"NOT" "\(" "IN_LIST" "some_list"
|
||||
|
||||
mismatched parenthesis in condition
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:[0-9]+ \(include\)
|
||||
1
Tests/RunCMake/while/unbalanced-parenthesis-stdout.txt
Normal file
1
Tests/RunCMake/while/unbalanced-parenthesis-stdout.txt
Normal file
@@ -0,0 +1 @@
|
||||
-- Code incorrectly accepted
|
||||
@@ -1,8 +1,7 @@
|
||||
set(var_with_paren "(")
|
||||
set(some_list "")
|
||||
|
||||
while(NOT ${var_with_paren} IN_LIST some_list)
|
||||
message(STATUS "Never prints")
|
||||
set(paren "(")
|
||||
while(${paren})
|
||||
message(STATUS "Condition incorrectly true")
|
||||
break()
|
||||
endwhile()
|
||||
|
||||
message(STATUS "Never prints")
|
||||
# FIXME(#23296): The above condition error is tolerated for compatibility.
|
||||
message(STATUS "Code incorrectly accepted")
|
||||
|
||||
Reference in New Issue
Block a user