diff options
author | Brad King <brad.king@kitware.com> | 2015-06-22 15:31:04 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2015-06-22 15:41:51 (GMT) |
commit | 5d85fb4f407cd661fb904f68e2c9cc27ddcc0331 (patch) | |
tree | c9955ec515ddd96a35def323fd3a16a15a6dccec /Source | |
parent | 3a65606591818281ba75bac4751e07c69751451f (diff) | |
download | CMake-5d85fb4f407cd661fb904f68e2c9cc27ddcc0331.zip CMake-5d85fb4f407cd661fb904f68e2c9cc27ddcc0331.tar.gz CMake-5d85fb4f407cd661fb904f68e2c9cc27ddcc0331.tar.bz2 |
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 'Source')
-rw-r--r-- | Source/cmForEachCommand.cxx | 22 | ||||
-rw-r--r-- | Source/cmForEachCommand.h | 5 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 1 | ||||
-rw-r--r-- | Source/cmMakefile.h | 9 | ||||
-rw-r--r-- | Source/cmWhileCommand.cxx | 17 | ||||
-rw-r--r-- | Source/cmWhileCommand.h | 5 |
6 files changed, 32 insertions, 27 deletions
diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx index 8e3510d..33cb234 100644 --- a/Source/cmForEachCommand.cxx +++ b/Source/cmForEachCommand.cxx @@ -13,6 +13,17 @@ #include <cmsys/auto_ptr.hxx> +cmForEachFunctionBlocker::cmForEachFunctionBlocker(cmMakefile* mf): + Makefile(mf), Depth(0) +{ + this->Makefile->PushLoopBlock(); +} + +cmForEachFunctionBlocker::~cmForEachFunctionBlocker() +{ + this->Makefile->PopLoopBlock(); +} + bool cmForEachFunctionBlocker:: IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, cmExecutionStatus &inStatus) @@ -27,8 +38,6 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, // if this is the endofreach for this statement if (!this->Depth) { - cmMakefile::LoopBlockPop loopBlockPop(&mf); - // Remove the function blocker for this scope or bail. cmsys::auto_ptr<cmFunctionBlocker> fb(mf.RemoveFunctionBlocker(this, lff)); @@ -130,7 +139,7 @@ bool cmForEachCommand } // create a function blocker - cmForEachFunctionBlocker *f = new cmForEachFunctionBlocker(); + cmForEachFunctionBlocker *f = new cmForEachFunctionBlocker(this->Makefile); if ( args.size() > 1 ) { if ( args[1] == "RANGE" ) @@ -206,15 +215,14 @@ bool cmForEachCommand } this->Makefile->AddFunctionBlocker(f); - this->Makefile->PushLoopBlock(); - return true; } //---------------------------------------------------------------------------- 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]); enum Doing { DoingNone, DoingLists, DoingItems }; @@ -252,7 +260,5 @@ bool cmForEachCommand::HandleInMode(std::vector<std::string> const& args) this->Makefile->AddFunctionBlocker(f.release()); // TODO: pass auto_ptr - this->Makefile->PushLoopBlock(); - return true; } diff --git a/Source/cmForEachCommand.h b/Source/cmForEachCommand.h index 9b7c85a..36e8808 100644 --- a/Source/cmForEachCommand.h +++ b/Source/cmForEachCommand.h @@ -19,8 +19,8 @@ class cmForEachFunctionBlocker : public cmFunctionBlocker { public: - cmForEachFunctionBlocker() {this->Depth = 0;} - virtual ~cmForEachFunctionBlocker() {} + cmForEachFunctionBlocker(cmMakefile* mf); + ~cmForEachFunctionBlocker(); virtual bool IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, cmExecutionStatus &); @@ -29,6 +29,7 @@ public: std::vector<std::string> Args; std::vector<cmListFileFunction> Functions; private: + cmMakefile* Makefile; int Depth; }; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 61a175c..ba914e1 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3284,7 +3284,6 @@ 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) diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index bff8c12..53a0805 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -125,15 +125,6 @@ public: }; 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 * loaded commands, not as part of the usual build process. diff --git a/Source/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx index 5170ead..012c580 100644 --- a/Source/cmWhileCommand.cxx +++ b/Source/cmWhileCommand.cxx @@ -12,6 +12,17 @@ #include "cmWhileCommand.h" #include "cmConditionEvaluator.h" +cmWhileFunctionBlocker::cmWhileFunctionBlocker(cmMakefile* mf): + Makefile(mf), Depth(0) +{ + this->Makefile->PushLoopBlock(); +} + +cmWhileFunctionBlocker::~cmWhileFunctionBlocker() +{ + this->Makefile->PopLoopBlock(); +} + bool cmWhileFunctionBlocker:: IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, 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->Depth) { - cmMakefile::LoopBlockPop loopBlockPop(&mf); - // Remove the function blocker for this scope or bail. cmsys::auto_ptr<cmFunctionBlocker> fb(mf.RemoveFunctionBlocker(this, lff)); @@ -140,12 +149,10 @@ bool cmWhileCommand } // create a function blocker - cmWhileFunctionBlocker *f = new cmWhileFunctionBlocker(); + cmWhileFunctionBlocker *f = new cmWhileFunctionBlocker(this->Makefile); f->Args = args; this->Makefile->AddFunctionBlocker(f); - this->Makefile->PushLoopBlock(); - return true; } diff --git a/Source/cmWhileCommand.h b/Source/cmWhileCommand.h index 9fafffc..85a0bd3 100644 --- a/Source/cmWhileCommand.h +++ b/Source/cmWhileCommand.h @@ -19,8 +19,8 @@ class cmWhileFunctionBlocker : public cmFunctionBlocker { public: - cmWhileFunctionBlocker() {this->Depth=0;} - virtual ~cmWhileFunctionBlocker() {} + cmWhileFunctionBlocker(cmMakefile* mf); + ~cmWhileFunctionBlocker(); virtual bool IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, cmExecutionStatus &); @@ -29,6 +29,7 @@ public: std::vector<cmListFileArgument> Args; std::vector<cmListFileFunction> Functions; private: + cmMakefile* Makefile; int Depth; }; |