diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2020-02-27 18:54:42 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2020-02-27 19:52:06 (GMT) |
commit | 185d1aefaa209115d21c6c821ff85f64411e95de (patch) | |
tree | 3cdb8491c92fa55e004054966c0cc646c8a3d076 | |
parent | a33b3949e5337da978828d611f3ca3f08bcda21b (diff) | |
download | CMake-185d1aefaa209115d21c6c821ff85f64411e95de.zip CMake-185d1aefaa209115d21c6c821ff85f64411e95de.tar.gz CMake-185d1aefaa209115d21c6c821ff85f64411e95de.tar.bz2 |
foreach: Set fatal error on invalid range
Fixes: #20394
5 files changed, 9 insertions, 0 deletions
diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx index 08e51ad..0546186 100644 --- a/Source/cmForEachCommand.cxx +++ b/Source/cmForEachCommand.cxx @@ -428,6 +428,7 @@ bool cmForEachCommand(std::vector<std::string> const& args, status.SetError( cmStrCat("called with incorrect range specification: start ", start, ", stop ", stop, ", step ", step)); + cmSystemTools::SetFatalErrorOccured(); return false; } diff --git a/Tests/RunCMake/foreach/RunCMakeTest.cmake b/Tests/RunCMake/foreach/RunCMakeTest.cmake index 6bb0683..22a0a75 100644 --- a/Tests/RunCMake/foreach/RunCMakeTest.cmake +++ b/Tests/RunCMake/foreach/RunCMakeTest.cmake @@ -18,3 +18,4 @@ run_cmake(foreach-RANGE-non-int-test-2-2) run_cmake(foreach-RANGE-non-int-test-3-1) run_cmake(foreach-RANGE-non-int-test-3-2) run_cmake(foreach-RANGE-non-int-test-3-3) +run_cmake(foreach-RANGE-invalid-test) diff --git a/Tests/RunCMake/foreach/foreach-RANGE-invalid-test-result.txt b/Tests/RunCMake/foreach/foreach-RANGE-invalid-test-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-invalid-test-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/foreach/foreach-RANGE-invalid-test-stderr.txt b/Tests/RunCMake/foreach/foreach-RANGE-invalid-test-stderr.txt new file mode 100644 index 0000000..66efdc1 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-invalid-test-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at foreach-RANGE-invalid-test\.cmake:[0-9]+ \(foreach\): + foreach called with incorrect range specification: start 2, stop 1, step 1 +Call Stack \(most recent call first\): + CMakeLists\.txt:3 \(include\)$ diff --git a/Tests/RunCMake/foreach/foreach-RANGE-invalid-test.cmake b/Tests/RunCMake/foreach/foreach-RANGE-invalid-test.cmake new file mode 100644 index 0000000..2f8eaba --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-invalid-test.cmake @@ -0,0 +1,2 @@ +foreach(a RANGE 2 1 1) +endforeach() |