mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-07 06:09:52 -06:00
cmake_language: Fix EXIT inside control flow blocks
These were missed in commit 1bb1769235 (cmake_language: Add EXIT
subcommand, 2024-01-05, v3.29.0-rc1~112^2).
Fixes: #25674
This commit is contained in:
@@ -127,6 +127,10 @@ bool cmBlockFunctionBlocker::Replay(std::vector<cmListFileFunction> functions,
|
||||
inStatus.SetContinueInvoked();
|
||||
return true;
|
||||
}
|
||||
if (status.HasExitCode()) {
|
||||
inStatus.SetExitCode(status.GetExitCode());
|
||||
return true;
|
||||
}
|
||||
if (cmSystemTools::GetFatalErrorOccurred()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -272,6 +272,11 @@ auto cmForEachFunctionBlocker::invoke(
|
||||
if (status.GetContinueInvoked()) {
|
||||
break;
|
||||
}
|
||||
if (status.HasExitCode()) {
|
||||
inStatus.SetExitCode(status.GetExitCode());
|
||||
result.Break = true;
|
||||
break;
|
||||
}
|
||||
if (cmSystemTools::GetFatalErrorOccurred()) {
|
||||
result.Restore = false;
|
||||
result.Break = true;
|
||||
|
||||
@@ -124,6 +124,10 @@ bool cmFunctionHelperCommand::operator()(
|
||||
makefile.RaiseScope(status.GetReturnVariables());
|
||||
break;
|
||||
}
|
||||
if (status.HasExitCode()) {
|
||||
inStatus.SetExitCode(status.GetExitCode());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// pop scope on the makefile
|
||||
|
||||
@@ -161,6 +161,10 @@ bool cmIfFunctionBlocker::Replay(std::vector<cmListFileFunction> functions,
|
||||
inStatus.SetContinueInvoked();
|
||||
return true;
|
||||
}
|
||||
if (status.HasExitCode()) {
|
||||
inStatus.SetExitCode(status.GetExitCode());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -135,6 +135,10 @@ bool cmMacroHelperCommand::operator()(
|
||||
inStatus.SetBreakInvoked();
|
||||
return true;
|
||||
}
|
||||
if (status.HasExitCode()) {
|
||||
inStatus.SetExitCode(status.GetExitCode());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -105,6 +105,10 @@ bool cmWhileFunctionBlocker::Replay(std::vector<cmListFileFunction> functions,
|
||||
if (status.GetContinueInvoked()) {
|
||||
break;
|
||||
}
|
||||
if (status.HasExitCode()) {
|
||||
inStatus.SetExitCode(status.GetExitCode());
|
||||
return true;
|
||||
}
|
||||
if (cmSystemTools::GetFatalErrorOccurred()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -91,6 +91,13 @@ run_cmake_script(exit_5_script)
|
||||
run_cmake_script(exit_0_script_with_command)
|
||||
run_cmake_script(exit_7_script_in_include)
|
||||
run_cmake_script(exit_8_script_in_recursive_cmake_language)
|
||||
run_cmake_script(exit_9_script_block)
|
||||
run_cmake_script(exit_9_script_control)
|
||||
run_cmake_script(exit_9_script_if)
|
||||
run_cmake_script(exit_9_script_foreach)
|
||||
run_cmake_script(exit_9_script_function)
|
||||
run_cmake_script(exit_9_script_macro)
|
||||
run_cmake_script(exit_9_script_while)
|
||||
|
||||
# Default log level
|
||||
run_cmake_command(
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
^9$
|
||||
5
Tests/RunCMake/cmake_language/exit_9_script_block.cmake
Normal file
5
Tests/RunCMake/cmake_language/exit_9_script_block.cmake
Normal file
@@ -0,0 +1,5 @@
|
||||
block()
|
||||
cmake_language(EXIT 9)
|
||||
message(FATAL_ERROR "This should not be reached!")
|
||||
endblock()
|
||||
message(FATAL_ERROR "This should not be reached!")
|
||||
@@ -0,0 +1 @@
|
||||
^9$
|
||||
24
Tests/RunCMake/cmake_language/exit_9_script_control.cmake
Normal file
24
Tests/RunCMake/cmake_language/exit_9_script_control.cmake
Normal file
@@ -0,0 +1,24 @@
|
||||
function(exit_macro)
|
||||
cmake_language(EXIT 9)
|
||||
message(FATAL_ERROR "This should not be reached!")
|
||||
endfunction()
|
||||
|
||||
function(exit_function)
|
||||
exit_macro()
|
||||
message(FATAL_ERROR "This should not be reached!")
|
||||
endfunction()
|
||||
|
||||
block()
|
||||
if(1)
|
||||
foreach(i IN ITEMS a b)
|
||||
while(1)
|
||||
exit_function()
|
||||
message(FATAL_ERROR "This should not be reached!")
|
||||
endwhile()
|
||||
message(FATAL_ERROR "This should not be reached!")
|
||||
endforeach()
|
||||
message(FATAL_ERROR "This should not be reached!")
|
||||
endif()
|
||||
message(FATAL_ERROR "This should not be reached!")
|
||||
endblock()
|
||||
message(FATAL_ERROR "This should not be reached!")
|
||||
@@ -0,0 +1 @@
|
||||
^9$
|
||||
@@ -0,0 +1,5 @@
|
||||
foreach(i IN ITEMS a b)
|
||||
cmake_language(EXIT 9)
|
||||
message(FATAL_ERROR "This should not be reached!")
|
||||
endforeach()
|
||||
message(FATAL_ERROR "This should not be reached!")
|
||||
@@ -0,0 +1 @@
|
||||
^9$
|
||||
@@ -0,0 +1,6 @@
|
||||
function(exit)
|
||||
cmake_language(EXIT 9)
|
||||
message(FATAL_ERROR "This should not be reached!")
|
||||
endfunction()
|
||||
exit()
|
||||
message(FATAL_ERROR "This should not be reached!")
|
||||
@@ -0,0 +1 @@
|
||||
^9$
|
||||
5
Tests/RunCMake/cmake_language/exit_9_script_if.cmake
Normal file
5
Tests/RunCMake/cmake_language/exit_9_script_if.cmake
Normal file
@@ -0,0 +1,5 @@
|
||||
if(1)
|
||||
cmake_language(EXIT 9)
|
||||
message(FATAL_ERROR "This should not be reached!")
|
||||
endif()
|
||||
message(FATAL_ERROR "This should not be reached!")
|
||||
@@ -0,0 +1 @@
|
||||
^9$
|
||||
6
Tests/RunCMake/cmake_language/exit_9_script_macro.cmake
Normal file
6
Tests/RunCMake/cmake_language/exit_9_script_macro.cmake
Normal file
@@ -0,0 +1,6 @@
|
||||
macro(exit)
|
||||
cmake_language(EXIT 9)
|
||||
message(FATAL_ERROR "This should not be reached!")
|
||||
endmacro()
|
||||
exit()
|
||||
message(FATAL_ERROR "This should not be reached!")
|
||||
@@ -0,0 +1 @@
|
||||
^9$
|
||||
5
Tests/RunCMake/cmake_language/exit_9_script_while.cmake
Normal file
5
Tests/RunCMake/cmake_language/exit_9_script_while.cmake
Normal file
@@ -0,0 +1,5 @@
|
||||
while(1)
|
||||
cmake_language(EXIT 9)
|
||||
message(FATAL_ERROR "This should not be reached!")
|
||||
endwhile()
|
||||
message(FATAL_ERROR "This should not be reached!")
|
||||
Reference in New Issue
Block a user