macro: Fix handling of 'continue' inside macros

Fixes: #17677
This commit is contained in:
Ruslan Baratov authored and Brad King committed 2026-05-19 14:45:40 -04:00
1 parent 4f5d22f085
commit a0f0e52dbd
4 files changed
+23

No files matched your search

+4
View File
@@ -136,6 +136,10 @@ bool cmMacroHelperCommand::operator()(
inStatus.SetBreakInvoked();
return true;
}
if (status.GetContinueInvoked()) {
inStatus.SetContinueInvoked();
return true;
}
if (status.HasExitCode()) {
inStatus.SetExitCode(status.GetExitCode());
return true;
@@ -0,0 +1,7 @@
-- start
-- 1 before continue
-- 2 before continue
-- 3 before continue
-- 4 before continue
-- 5 before continue
-- end
@@ -0,0 +1,11 @@
macro(wrapped_continue)
continue()
endmacro()
message(STATUS "start")
foreach(iter RANGE 1 5)
message(STATUS "${iter} before continue")
wrapped_continue()
message(STATUS "${iter} after continue")
endforeach()
message(STATUS "end")
@@ -4,6 +4,7 @@ run_cmake(ContinueForeach)
run_cmake(ContinueForEachInLists)
run_cmake(ContinueNestedForeach)
run_cmake(ContinueWhile)
run_cmake(ContinueInMacro)
run_cmake(NoArgumentsToContinue)
run_cmake(NoEnclosingBlock)
run_cmake(NoEnclosingBlockInFunction)