diff options
-rw-r--r-- | Source/cmFunctionBlocker.cxx | 18 | ||||
-rw-r--r-- | Source/cmFunctionBlocker.h | 2 |
2 files changed, 16 insertions, 4 deletions
diff --git a/Source/cmFunctionBlocker.cxx b/Source/cmFunctionBlocker.cxx index 40e692d..523482a 100644 --- a/Source/cmFunctionBlocker.cxx +++ b/Source/cmFunctionBlocker.cxx @@ -24,10 +24,11 @@ bool cmFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff, auto self = mf.RemoveFunctionBlocker(); assert(self.get() == this); - if (!this->ArgumentsMatch(lff, mf)) { - cmListFileContext const& lfc = this->GetStartingContext(); - cmListFileContext closingContext = - cmListFileContext::FromListFileFunction(lff, lfc.FilePath); + cmListFileContext const& lfc = this->GetStartingContext(); + cmListFileContext closingContext = + cmListFileContext::FromListFileFunction(lff, lfc.FilePath); + if (this->EndCommandSupportsArguments() && + !this->ArgumentsMatch(lff, mf)) { std::ostringstream e; /* clang-format off */ e << "A logical block opening on the line\n" @@ -37,6 +38,15 @@ bool cmFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff, << "with mis-matching arguments."; /* clang-format on */ mf.IssueMessage(MessageType::AUTHOR_WARNING, e.str()); + } else if (!this->EndCommandSupportsArguments() && + !lff.Arguments().empty()) { + std::ostringstream e; + /* clang-format off */ + e << "A logical block closing on the line\n" + " " << closingContext << "\n" + "has unexpected arguments."; + /* clang-format on */ + mf.IssueMessage(MessageType::AUTHOR_WARNING, e.str()); } return this->Replay(std::move(this->Functions), status); diff --git a/Source/cmFunctionBlocker.h b/Source/cmFunctionBlocker.h index 38abeba..3e096f2 100644 --- a/Source/cmFunctionBlocker.h +++ b/Source/cmFunctionBlocker.h @@ -38,6 +38,8 @@ private: virtual cm::string_view StartCommandName() const = 0; virtual cm::string_view EndCommandName() const = 0; + virtual bool EndCommandSupportsArguments() const { return true; } + virtual bool ArgumentsMatch(cmListFileFunction const& lff, cmMakefile& mf) const = 0; |