cmFunctionBlocker: Add handling of close block without parameters.

This commit is contained in:
Marc Chevrier 2022-08-05 17:21:46 +02:00
parent 02c067dee5
commit 553da0685f
2 changed files with 16 additions and 4 deletions

View File

@ -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);

View File

@ -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;