Warn about unquoted arguments that look like long brackets
In the future CMake will introduce Lua-style long bracket syntax. Warn about unquoted arguments that in the future will be treated as opening long brackets. Teach the RunCMake.Syntax test to cover such cases and ensure that the warning appears.
This commit is contained in:
parent
58e524165d
commit
bf73264694
@ -343,6 +343,27 @@ void cmListFileParser::AddArgument(cmListFileLexer_Token* token,
|
||||
{
|
||||
cmListFileArgument a(token->text, delim, this->FileName, token->line);
|
||||
this->Function.Arguments.push_back(a);
|
||||
if(delim == cmListFileArgument::Unquoted)
|
||||
{
|
||||
// Warn about a future behavior change.
|
||||
const char* c = a.Value.c_str();
|
||||
if(*c++ == '[')
|
||||
{
|
||||
while(*c == '=')
|
||||
{ ++c; }
|
||||
if(*c == '[')
|
||||
{
|
||||
cmOStringStream m;
|
||||
m << "Syntax Warning in cmake code at\n"
|
||||
<< " " << this->FileName << ":" << token->line << ":"
|
||||
<< token->column << "\n"
|
||||
<< "A future version of CMake may treat unquoted argument:\n"
|
||||
<< " " << a.Value << "\n"
|
||||
<< "as an opening long bracket. Double-quote the argument.";
|
||||
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, m.str().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
if(this->Separation == SeparationOkay)
|
||||
{
|
||||
return;
|
||||
|
35
Tests/RunCMake/Syntax/BracketWarn-stderr.txt
Normal file
35
Tests/RunCMake/Syntax/BracketWarn-stderr.txt
Normal file
@ -0,0 +1,35 @@
|
||||
CMake Warning \(dev\) at CMakeLists.txt:3 \(include\):
|
||||
Syntax Warning in cmake code at
|
||||
|
||||
.*/Tests/RunCMake/Syntax/BracketWarn.cmake:1:16
|
||||
|
||||
A future version of CMake may treat unquoted argument:
|
||||
|
||||
\[\[
|
||||
|
||||
as an opening long bracket. Double-quote the argument.
|
||||
This warning is for project developers. Use -Wno-dev to suppress it.
|
||||
|
||||
CMake Warning \(dev\) at CMakeLists.txt:3 \(include\):
|
||||
Syntax Warning in cmake code at
|
||||
|
||||
.*/Tests/RunCMake/Syntax/BracketWarn.cmake:1:19
|
||||
|
||||
A future version of CMake may treat unquoted argument:
|
||||
|
||||
\[=\[
|
||||
|
||||
as an opening long bracket. Double-quote the argument.
|
||||
This warning is for project developers. Use -Wno-dev to suppress it.
|
||||
|
||||
CMake Warning \(dev\) at CMakeLists.txt:3 \(include\):
|
||||
Syntax Warning in cmake code at
|
||||
|
||||
.*/Tests/RunCMake/Syntax/BracketWarn.cmake:1:27
|
||||
|
||||
A future version of CMake may treat unquoted argument:
|
||||
|
||||
\[==\[x
|
||||
|
||||
as an opening long bracket. Double-quote the argument.
|
||||
This warning is for project developers. Use -Wno-dev to suppress it.
|
1
Tests/RunCMake/Syntax/BracketWarn-stdout.txt
Normal file
1
Tests/RunCMake/Syntax/BracketWarn-stdout.txt
Normal file
@ -0,0 +1 @@
|
||||
-- \[\[\[=\[\[=x\[==\[x
|
1
Tests/RunCMake/Syntax/BracketWarn.cmake
Normal file
1
Tests/RunCMake/Syntax/BracketWarn.cmake
Normal file
@ -0,0 +1 @@
|
||||
message(STATUS [[ [=[ [=x [==[x)
|
@ -14,3 +14,4 @@ run_cmake(Unquoted1)
|
||||
run_cmake(UnterminatedCall1)
|
||||
run_cmake(UnterminatedCall2)
|
||||
run_cmake(UnterminatedString)
|
||||
run_cmake(BracketWarn)
|
||||
|
Loading…
x
Reference in New Issue
Block a user