Merge branch 'fix-function-missing-end' into release

This commit is contained in:
Brad King 2015-06-22 11:46:09 -04:00
commit 38ee28bfd5
13 changed files with 52 additions and 27 deletions

View File

@ -13,6 +13,17 @@
#include <cmsys/auto_ptr.hxx> #include <cmsys/auto_ptr.hxx>
cmForEachFunctionBlocker::cmForEachFunctionBlocker(cmMakefile* mf):
Makefile(mf), Depth(0)
{
this->Makefile->PushLoopBlock();
}
cmForEachFunctionBlocker::~cmForEachFunctionBlocker()
{
this->Makefile->PopLoopBlock();
}
bool cmForEachFunctionBlocker:: bool cmForEachFunctionBlocker::
IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
cmExecutionStatus &inStatus) cmExecutionStatus &inStatus)
@ -27,8 +38,6 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
// if this is the endofreach for this statement // if this is the endofreach for this statement
if (!this->Depth) if (!this->Depth)
{ {
cmMakefile::LoopBlockPop loopBlockPop(&mf);
// Remove the function blocker for this scope or bail. // Remove the function blocker for this scope or bail.
cmsys::auto_ptr<cmFunctionBlocker> cmsys::auto_ptr<cmFunctionBlocker>
fb(mf.RemoveFunctionBlocker(this, lff)); fb(mf.RemoveFunctionBlocker(this, lff));
@ -128,7 +137,7 @@ bool cmForEachCommand
} }
// create a function blocker // create a function blocker
cmForEachFunctionBlocker *f = new cmForEachFunctionBlocker(); cmForEachFunctionBlocker *f = new cmForEachFunctionBlocker(this->Makefile);
if ( args.size() > 1 ) if ( args.size() > 1 )
{ {
if ( args[1] == "RANGE" ) if ( args[1] == "RANGE" )
@ -204,15 +213,14 @@ bool cmForEachCommand
} }
this->Makefile->AddFunctionBlocker(f); this->Makefile->AddFunctionBlocker(f);
this->Makefile->PushLoopBlock();
return true; return true;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool cmForEachCommand::HandleInMode(std::vector<std::string> const& args) bool cmForEachCommand::HandleInMode(std::vector<std::string> const& args)
{ {
cmsys::auto_ptr<cmForEachFunctionBlocker> f(new cmForEachFunctionBlocker()); cmsys::auto_ptr<cmForEachFunctionBlocker>
f(new cmForEachFunctionBlocker(this->Makefile));
f->Args.push_back(args[0]); f->Args.push_back(args[0]);
enum Doing { DoingNone, DoingLists, DoingItems }; enum Doing { DoingNone, DoingLists, DoingItems };
@ -250,7 +258,5 @@ bool cmForEachCommand::HandleInMode(std::vector<std::string> const& args)
this->Makefile->AddFunctionBlocker(f.release()); // TODO: pass auto_ptr this->Makefile->AddFunctionBlocker(f.release()); // TODO: pass auto_ptr
this->Makefile->PushLoopBlock();
return true; return true;
} }

View File

@ -19,8 +19,8 @@
class cmForEachFunctionBlocker : public cmFunctionBlocker class cmForEachFunctionBlocker : public cmFunctionBlocker
{ {
public: public:
cmForEachFunctionBlocker() {this->Depth = 0;} cmForEachFunctionBlocker(cmMakefile* mf);
virtual ~cmForEachFunctionBlocker() {} ~cmForEachFunctionBlocker();
virtual bool IsFunctionBlocked(const cmListFileFunction& lff, virtual bool IsFunctionBlocked(const cmListFileFunction& lff,
cmMakefile &mf, cmMakefile &mf,
cmExecutionStatus &); cmExecutionStatus &);
@ -29,6 +29,7 @@ public:
std::vector<std::string> Args; std::vector<std::string> Args;
std::vector<cmListFileFunction> Functions; std::vector<cmListFileFunction> Functions;
private: private:
cmMakefile* Makefile;
int Depth; int Depth;
}; };

View File

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

View File

@ -111,15 +111,6 @@ public:
}; };
friend class LexicalPushPop; friend class LexicalPushPop;
class LoopBlockPop
{
public:
LoopBlockPop(cmMakefile* mf) { this->Makefile = mf; }
~LoopBlockPop() { this->Makefile->PopLoopBlock(); }
private:
cmMakefile* Makefile;
};
/** /**
* Try running cmake and building a file. This is used for dynalically * Try running cmake and building a file. This is used for dynalically
* loaded commands, not as part of the usual build process. * loaded commands, not as part of the usual build process.

View File

@ -12,6 +12,17 @@
#include "cmWhileCommand.h" #include "cmWhileCommand.h"
#include "cmConditionEvaluator.h" #include "cmConditionEvaluator.h"
cmWhileFunctionBlocker::cmWhileFunctionBlocker(cmMakefile* mf):
Makefile(mf), Depth(0)
{
this->Makefile->PushLoopBlock();
}
cmWhileFunctionBlocker::~cmWhileFunctionBlocker()
{
this->Makefile->PopLoopBlock();
}
bool cmWhileFunctionBlocker:: bool cmWhileFunctionBlocker::
IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
cmExecutionStatus &inStatus) cmExecutionStatus &inStatus)
@ -27,8 +38,6 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
// if this is the endwhile for this while loop then execute // if this is the endwhile for this while loop then execute
if (!this->Depth) if (!this->Depth)
{ {
cmMakefile::LoopBlockPop loopBlockPop(&mf);
// Remove the function blocker for this scope or bail. // Remove the function blocker for this scope or bail.
cmsys::auto_ptr<cmFunctionBlocker> cmsys::auto_ptr<cmFunctionBlocker>
fb(mf.RemoveFunctionBlocker(this, lff)); fb(mf.RemoveFunctionBlocker(this, lff));
@ -140,12 +149,10 @@ bool cmWhileCommand
} }
// create a function blocker // create a function blocker
cmWhileFunctionBlocker *f = new cmWhileFunctionBlocker(); cmWhileFunctionBlocker *f = new cmWhileFunctionBlocker(this->Makefile);
f->Args = args; f->Args = args;
this->Makefile->AddFunctionBlocker(f); this->Makefile->AddFunctionBlocker(f);
this->Makefile->PushLoopBlock();
return true; return true;
} }

View File

@ -19,8 +19,8 @@
class cmWhileFunctionBlocker : public cmFunctionBlocker class cmWhileFunctionBlocker : public cmFunctionBlocker
{ {
public: public:
cmWhileFunctionBlocker() {this->Depth=0;} cmWhileFunctionBlocker(cmMakefile* mf);
virtual ~cmWhileFunctionBlocker() {} ~cmWhileFunctionBlocker();
virtual bool IsFunctionBlocked(const cmListFileFunction& lff, virtual bool IsFunctionBlocked(const cmListFileFunction& lff,
cmMakefile &mf, cmMakefile &mf,
cmExecutionStatus &); cmExecutionStatus &);
@ -29,6 +29,7 @@ public:
std::vector<cmListFileArgument> Args; std::vector<cmListFileArgument> Args;
std::vector<cmListFileFunction> Functions; std::vector<cmListFileFunction> Functions;
private: private:
cmMakefile* Makefile;
int Depth; int Depth;
}; };

View File

@ -0,0 +1 @@
1

View File

@ -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.$

View File

@ -0,0 +1,2 @@
function(f)
#endfunction() # missing

View File

@ -0,0 +1 @@
1

View File

@ -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.$

View File

@ -0,0 +1,2 @@
macro(m)
#endmacro() # missing

View File

@ -110,5 +110,7 @@ run_cmake(CMP0053-NameWithEscapedSpacesQuoted)
run_cmake(CMP0053-NameWithEscapedTabsQuoted) run_cmake(CMP0053-NameWithEscapedTabsQuoted)
# Function and macro tests. # Function and macro tests.
run_cmake(FunctionUnmatched)
run_cmake(FunctionUnmatchedForeach) run_cmake(FunctionUnmatchedForeach)
run_cmake(MacroUnmatched)
run_cmake(MacroUnmatchedForeach) run_cmake(MacroUnmatchedForeach)