summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmForEachCommand.cxx6
-rw-r--r--Tests/RunCMake/foreach/RunCMakeTest.cmake1
-rw-r--r--Tests/RunCMake/foreach/foreach-RANGE-out-of-range-test-result.txt1
-rw-r--r--Tests/RunCMake/foreach/foreach-RANGE-out-of-range-test-stderr.txt4
-rw-r--r--Tests/RunCMake/foreach/foreach-RANGE-out-of-range-test.cmake3
5 files changed, 15 insertions, 0 deletions
diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx
index 12fb55a..42df923 100644
--- a/Source/cmForEachCommand.cxx
+++ b/Source/cmForEachCommand.cxx
@@ -366,6 +366,12 @@ bool TryParseInteger(cmExecutionStatus& status, const std::string& str, int& i)
status.SetError(e.str());
cmSystemTools::SetFatalErrorOccured();
return false;
+ } catch (std::out_of_range&) {
+ std::ostringstream e;
+ e << "Integer out of range: '" << str << "'";
+ status.SetError(e.str());
+ cmSystemTools::SetFatalErrorOccured();
+ return false;
}
return true;
diff --git a/Tests/RunCMake/foreach/RunCMakeTest.cmake b/Tests/RunCMake/foreach/RunCMakeTest.cmake
index 22a0a75..d3f7c23 100644
--- a/Tests/RunCMake/foreach/RunCMakeTest.cmake
+++ b/Tests/RunCMake/foreach/RunCMakeTest.cmake
@@ -19,3 +19,4 @@ 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)
+run_cmake(foreach-RANGE-out-of-range-test)
diff --git a/Tests/RunCMake/foreach/foreach-RANGE-out-of-range-test-result.txt b/Tests/RunCMake/foreach/foreach-RANGE-out-of-range-test-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/foreach/foreach-RANGE-out-of-range-test-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/foreach/foreach-RANGE-out-of-range-test-stderr.txt b/Tests/RunCMake/foreach/foreach-RANGE-out-of-range-test-stderr.txt
new file mode 100644
index 0000000..f05f864
--- /dev/null
+++ b/Tests/RunCMake/foreach/foreach-RANGE-out-of-range-test-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at foreach-RANGE-out-of-range-test\.cmake:[0-9]+ \(foreach\):
+ foreach Integer out of range: '10000000000000000000'
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:3 \(include\)$
diff --git a/Tests/RunCMake/foreach/foreach-RANGE-out-of-range-test.cmake b/Tests/RunCMake/foreach/foreach-RANGE-out-of-range-test.cmake
new file mode 100644
index 0000000..3099ca9
--- /dev/null
+++ b/Tests/RunCMake/foreach/foreach-RANGE-out-of-range-test.cmake
@@ -0,0 +1,3 @@
+foreach(a RANGE 10000000000000000000)
+ break()
+endforeach()