summaryrefslogtreecommitdiffstats
path: root/Source/cmWhileCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-06-22 15:31:04 (GMT)
committerBrad King <brad.king@kitware.com>2015-06-22 15:41:51 (GMT)
commit5d85fb4f407cd661fb904f68e2c9cc27ddcc0331 (patch)
treec9955ec515ddd96a35def323fd3a16a15a6dccec /Source/cmWhileCommand.cxx
parent3a65606591818281ba75bac4751e07c69751451f (diff)
downloadCMake-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/cmWhileCommand.cxx')
-rw-r--r--Source/cmWhileCommand.cxx17
1 files changed, 12 insertions, 5 deletions
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;
}