[cmake-developers] [PATCH v5 0/4] Add continue keyword
Ben Boeckel
ben.boeckel at kitware.com
Tue Nov 18 11:19:47 EST 2014
On Tue, Nov 18, 2014 at 16:34:28 +0100, Gregor Jasny wrote:
> Changes compared to v4:
> * Use new style error reporting in cmContinueCommand.cxx
> * Reject any given arguments to continue()
> * CMP0055: Reject any arguments to break, too.
Untested, but from a (very) quick skim, I don't see anything wrong. I
thought of a test for break() while looking at it. I wonder if we should
fix anything about it and if so, make continue behave in an analogous
way before it might also need a policy[1]:
-------- loop.cmake ---------
function (my_breakf)
break()
endfunction ()
macro (my_breakm)
break()
endmacro ()
foreach (a IN ITEMS 1 2 3)
my_breakf()
message("-->${a}<--")
endforeach ()
foreach (a IN ITEMS 4 5 6)
my_breakm()
message("-->${a}<--")
endforeach ()
-------- loop.cmake ---------
Which prints:
-->1<--
-->2<--
-->3<--
without any error messages (e.g., about using break() outside a
loop…which doesn't seem to happen anyways, so maybe this is moot). I
don't see any existing tests about break inside of a function or macro
having an effect on the caller's logic.
Thoughts?
--Ben
[1]Though it might be better to fix, if necessary, both with one policy
so that they're always the same and there is no case where continue has
NEW behavior and break OLD behavior.
More information about the cmake-developers
mailing list