Merge topic 'fix-function-missing-endforeach'

3a656065 Fix assertion failure on unmatched foreach in function (#15572)
This commit is contained in:
Brad King 2015-05-19 11:09:21 -04:00 committed by CMake Topic Stage
commit aa68f2e4c9
9 changed files with 34 additions and 1 deletions

View File

@ -94,8 +94,8 @@ bool cmFunctionHelperCommand::InvokeInitialPass
}
// we push a scope on the makefile
cmMakefile::LexicalPushPop lexScope(this->Makefile);
cmMakefile::ScopePushPop varScope(this->Makefile);
cmMakefile::LexicalPushPop lexScope(this->Makefile);
static_cast<void>(varScope);
// Push a weak policy scope which restores the policies recorded at

View File

@ -3276,6 +3276,7 @@ void cmMakefile::PopFunctionBlockerBarrier(bool reportError)
this->FunctionBlockerBarriers.back();
while(this->FunctionBlockers.size() > barrier)
{
cmMakefile::LoopBlockPop loopBlockPop(this);
cmsys::auto_ptr<cmFunctionBlocker> fb(this->FunctionBlockers.back());
this->FunctionBlockers.pop_back();
if(reportError)

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,8 @@
^CMake Error at FunctionUnmatchedForeach.cmake:[0-9]+ \(f\):
A logical block opening on the line
.*/Tests/RunCMake/Syntax/FunctionUnmatchedForeach.cmake:[0-9]+ \(foreach\)
is not closed.
Call Stack \(most recent call first\):
CMakeLists.txt:[0-9]+ \(include\)$

View File

@ -0,0 +1,5 @@
function(f)
foreach(i 1)
#endforeach() # missing
endfunction()
f()

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,8 @@
^CMake Error at MacroUnmatchedForeach.cmake:[0-9]+ \(m\):
A logical block opening on the line
.*/Tests/RunCMake/Syntax/MacroUnmatchedForeach.cmake:[0-9]+ \(foreach\)
is not closed.
Call Stack \(most recent call first\):
CMakeLists.txt:[0-9]+ \(include\)$

View File

@ -0,0 +1,5 @@
macro(m)
foreach(i 1)
#endforeach() # missing
endmacro()
m()

View File

@ -108,3 +108,7 @@ run_cmake(CMP0053-NameWithNewlineQuoted)
run_cmake(CMP0053-NameWithCarriageReturnQuoted)
run_cmake(CMP0053-NameWithEscapedSpacesQuoted)
run_cmake(CMP0053-NameWithEscapedTabsQuoted)
# Function and macro tests.
run_cmake(FunctionUnmatchedForeach)
run_cmake(MacroUnmatchedForeach)