On 04/11/14 21:21, Brad King wrote: > On 11/04/2014 03:10 PM, Gregor Jasny wrote: >> About the continue() outside of a block error: I added a test but I >> have no idea how to enforce the desired behavior. > > It's been a while since I looked at the relevant parts of the code > but here is one approach that may work: > > Find all call sites to cmMakefile::ExecuteCommand. Teach them to > check the resulting status argument for GetContinueInvoked. If it > is true for any call sites other than the loop implementations then > it is an error.
I wonder if this will really work. Imaging the following: foreach(...) if(...) continue() endif() endforeach() As you can see in the patch the if command detects the continue invocation and aborts looping over the collected commands. It also bounces the continue to the outer inStatus execution status. IMHO what's needed is a in loop counter that counts how deep we are in a loop construct. It gets incremented within every foreach or while loop. Decremented with each endforeach or endwhile. Additionally new function, macro or includes will push the counter on a stack and reset it. I'd consider the following invalid: function(foo) continue() endfunction() foreach(...) foo() endforeach() Do you have and idea how to achieve this? I thought about storing the state in the cmExecutionStatus which gets pushed to the cmMakefile::CallStack. But the call stack is surprisingly empty at the continue() when I execute the following: if (1) if (1) continue () endif (1) endif (1) Another approach would be to hook into ExecuteCommand, but this misses all the endFoos. Thanks for your help, Gregor -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers