summaryrefslogtreecommitdiff
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-06-22 11:31:04 -0400
committerBrad King <brad.king@kitware.com>2015-06-22 11:41:51 -0400
commit5d85fb4f407cd661fb904f68e2c9cc27ddcc0331 (patch)
treec9955ec515ddd96a35def323fd3a16a15a6dccec /Tests
parent3a65606591818281ba75bac4751e07c69751451f (diff)
downloadcmake-5d85fb4f407cd661fb904f68e2c9cc27ddcc0331.tar.gz
Fix assertion failure on unmatched function or macro
The fix in commit v3.2.3~3^2 (Fix assertion failure on unmatched foreach in function, 2015-05-18) broke handling of unmatched non-loop blocks because it assumed all function blockers removed during error unwinding were for loops, essentially switching the set of mishandled cases. The purpose of the loop block push/pop operations is to define a scope matching the lifetime of the loop function blockers. Since our function blockers already have the proper lifetime, simply move the push/pop operations to their constructor/destructor. Extend the RunCMake.Syntax test with a case covering this.
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/Syntax/FunctionUnmatched-result.txt1
-rw-r--r--Tests/RunCMake/Syntax/FunctionUnmatched-stderr.txt6
-rw-r--r--Tests/RunCMake/Syntax/FunctionUnmatched.cmake2
-rw-r--r--Tests/RunCMake/Syntax/MacroUnmatched-result.txt1
-rw-r--r--Tests/RunCMake/Syntax/MacroUnmatched-stderr.txt6
-rw-r--r--Tests/RunCMake/Syntax/MacroUnmatched.cmake2
-rw-r--r--Tests/RunCMake/Syntax/RunCMakeTest.cmake2
7 files changed, 20 insertions, 0 deletions
diff --git a/Tests/RunCMake/Syntax/FunctionUnmatched-result.txt b/Tests/RunCMake/Syntax/FunctionUnmatched-result.txt
new file mode 100644
index 0000000000..d00491fd7e
--- /dev/null
+++ b/Tests/RunCMake/Syntax/FunctionUnmatched-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/Syntax/FunctionUnmatched-stderr.txt b/Tests/RunCMake/Syntax/FunctionUnmatched-stderr.txt
new file mode 100644
index 0000000000..776a8f260a
--- /dev/null
+++ b/Tests/RunCMake/Syntax/FunctionUnmatched-stderr.txt
@@ -0,0 +1,6 @@
+^CMake Error at CMakeLists.txt:[0-9]+ \(include\):
+ A logical block opening on the line
+
+ .*/Tests/RunCMake/Syntax/FunctionUnmatched.cmake:[0-9]+ \(function\)
+
+ is not closed.$
diff --git a/Tests/RunCMake/Syntax/FunctionUnmatched.cmake b/Tests/RunCMake/Syntax/FunctionUnmatched.cmake
new file mode 100644
index 0000000000..515b6bf632
--- /dev/null
+++ b/Tests/RunCMake/Syntax/FunctionUnmatched.cmake
@@ -0,0 +1,2 @@
+function(f)
+#endfunction() # missing
diff --git a/Tests/RunCMake/Syntax/MacroUnmatched-result.txt b/Tests/RunCMake/Syntax/MacroUnmatched-result.txt
new file mode 100644
index 0000000000..d00491fd7e
--- /dev/null
+++ b/Tests/RunCMake/Syntax/MacroUnmatched-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/Syntax/MacroUnmatched-stderr.txt b/Tests/RunCMake/Syntax/MacroUnmatched-stderr.txt
new file mode 100644
index 0000000000..1699c436d7
--- /dev/null
+++ b/Tests/RunCMake/Syntax/MacroUnmatched-stderr.txt
@@ -0,0 +1,6 @@
+^CMake Error at CMakeLists.txt:[0-9]+ \(include\):
+ A logical block opening on the line
+
+ .*/Tests/RunCMake/Syntax/MacroUnmatched.cmake:[0-9]+ \(macro\)
+
+ is not closed.$
diff --git a/Tests/RunCMake/Syntax/MacroUnmatched.cmake b/Tests/RunCMake/Syntax/MacroUnmatched.cmake
new file mode 100644
index 0000000000..302d96ec3b
--- /dev/null
+++ b/Tests/RunCMake/Syntax/MacroUnmatched.cmake
@@ -0,0 +1,2 @@
+macro(m)
+#endmacro() # missing
diff --git a/Tests/RunCMake/Syntax/RunCMakeTest.cmake b/Tests/RunCMake/Syntax/RunCMakeTest.cmake
index c43128087e..fd012b9c46 100644
--- a/Tests/RunCMake/Syntax/RunCMakeTest.cmake
+++ b/Tests/RunCMake/Syntax/RunCMakeTest.cmake
@@ -110,5 +110,7 @@ run_cmake(CMP0053-NameWithEscapedSpacesQuoted)
run_cmake(CMP0053-NameWithEscapedTabsQuoted)
# Function and macro tests.
+run_cmake(FunctionUnmatched)
run_cmake(FunctionUnmatchedForeach)
+run_cmake(MacroUnmatched)
run_cmake(MacroUnmatchedForeach)