diff options
author | Brad King <brad.king@kitware.com> | 2009-01-21 14:49:00 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2009-01-21 14:49:00 (GMT) |
commit | 1dcc5b455829db89f0d931cd57c12e0e247c0f44 (patch) | |
tree | 65b04dafe29a8a753be2824ea7f4f985d0fc43fb /Source/cmMakefile.cxx | |
parent | bca1026250c5d2006a3829662b736660982e3a33 (diff) | |
download | CMake-1dcc5b455829db89f0d931cd57c12e0e247c0f44.zip CMake-1dcc5b455829db89f0d931cd57c12e0e247c0f44.tar.gz CMake-1dcc5b455829db89f0d931cd57c12e0e247c0f44.tar.bz2 |
ENH: Better handling of mismatched blocks
If a logical block terminates with mismatching arguments we previously
failed to remove the function blocker but replayed the commands anyway,
which led to cases in which we failed to report the mismatch (return
shortly after the ending command). The recent refactoring of function
blocker deletion changed this behavior to produce an error on the ending
line by not blocking the command. Furthermore, the function blocker
would stay in place and complain at the end of every equal-level block
of the same type.
This teaches CMake to treat the begin/end commands (if/endif, etc.) as
correct and just warns when the arguments mismatch. The change allows
cases in which CMake 2.6.2 silently ignored a mismatch to run as before
but with a warning.
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r-- | Source/cmMakefile.cxx | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index c6bc4f2..890f752 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2422,7 +2422,8 @@ void cmMakefile::AddFunctionBlocker(cmFunctionBlocker* fb) } cmsys::auto_ptr<cmFunctionBlocker> -cmMakefile::RemoveFunctionBlocker(const cmListFileFunction& lff) +cmMakefile::RemoveFunctionBlocker(cmFunctionBlocker* fb, + const cmListFileFunction& lff) { // Find the function blocker stack barrier for the current scope. // We only remove a blocker whose index is not less than the barrier. @@ -2438,8 +2439,20 @@ cmMakefile::RemoveFunctionBlocker(const cmListFileFunction& lff) { std::vector<cmFunctionBlocker*>::iterator pos = this->FunctionBlockers.begin() + (i - 1); - if ((*pos)->ShouldRemove(lff, *this)) + if (*pos == fb) { + // Warn if the arguments do not match, but always remove. + if(!(*pos)->ShouldRemove(lff, *this)) + { + cmListFileContext const& lfc = fb->GetStartingContext(); + cmOStringStream e; + e << "A logical block opening on the line\n" + << " " << lfc << "\n" + << "closes on the line\n" + << " " << lff << "\n" + << "with mis-matching arguments."; + this->IssueMessage(cmake::AUTHOR_WARNING, e.str()); + } cmFunctionBlocker* b = *pos; this->FunctionBlockers.erase(pos); return cmsys::auto_ptr<cmFunctionBlocker>(b); |