Merge topic 'fix-flow-control-override'
c017098d4d
CMake: Allow override of unexpected non-flow-control commands
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6232
This commit is contained in:
commit
1aa16906e6
@ -164,36 +164,36 @@ void GetScriptingCommands(cmState* state)
|
|||||||
state->AddBuiltinCommand("string", cmStringCommand);
|
state->AddBuiltinCommand("string", cmStringCommand);
|
||||||
state->AddBuiltinCommand("unset", cmUnsetCommand);
|
state->AddBuiltinCommand("unset", cmUnsetCommand);
|
||||||
|
|
||||||
state->AddUnexpectedCommand(
|
state->AddUnexpectedFlowControlCommand(
|
||||||
"else",
|
"else",
|
||||||
"An ELSE command was found outside of a proper "
|
"An ELSE command was found outside of a proper "
|
||||||
"IF ENDIF structure. Or its arguments did not match "
|
"IF ENDIF structure. Or its arguments did not match "
|
||||||
"the opening IF command.");
|
"the opening IF command.");
|
||||||
state->AddUnexpectedCommand(
|
state->AddUnexpectedFlowControlCommand(
|
||||||
"elseif",
|
"elseif",
|
||||||
"An ELSEIF command was found outside of a proper "
|
"An ELSEIF command was found outside of a proper "
|
||||||
"IF ENDIF structure.");
|
"IF ENDIF structure.");
|
||||||
state->AddUnexpectedCommand(
|
state->AddUnexpectedFlowControlCommand(
|
||||||
"endforeach",
|
"endforeach",
|
||||||
"An ENDFOREACH command was found outside of a proper "
|
"An ENDFOREACH command was found outside of a proper "
|
||||||
"FOREACH ENDFOREACH structure. Or its arguments did "
|
"FOREACH ENDFOREACH structure. Or its arguments did "
|
||||||
"not match the opening FOREACH command.");
|
"not match the opening FOREACH command.");
|
||||||
state->AddUnexpectedCommand(
|
state->AddUnexpectedFlowControlCommand(
|
||||||
"endfunction",
|
"endfunction",
|
||||||
"An ENDFUNCTION command was found outside of a proper "
|
"An ENDFUNCTION command was found outside of a proper "
|
||||||
"FUNCTION ENDFUNCTION structure. Or its arguments did not "
|
"FUNCTION ENDFUNCTION structure. Or its arguments did not "
|
||||||
"match the opening FUNCTION command.");
|
"match the opening FUNCTION command.");
|
||||||
state->AddUnexpectedCommand(
|
state->AddUnexpectedFlowControlCommand(
|
||||||
"endif",
|
"endif",
|
||||||
"An ENDIF command was found outside of a proper "
|
"An ENDIF command was found outside of a proper "
|
||||||
"IF ENDIF structure. Or its arguments did not match "
|
"IF ENDIF structure. Or its arguments did not match "
|
||||||
"the opening IF command.");
|
"the opening IF command.");
|
||||||
state->AddUnexpectedCommand(
|
state->AddUnexpectedFlowControlCommand(
|
||||||
"endmacro",
|
"endmacro",
|
||||||
"An ENDMACRO command was found outside of a proper "
|
"An ENDMACRO command was found outside of a proper "
|
||||||
"MACRO ENDMACRO structure. Or its arguments did not "
|
"MACRO ENDMACRO structure. Or its arguments did not "
|
||||||
"match the opening MACRO command.");
|
"match the opening MACRO command.");
|
||||||
state->AddUnexpectedCommand(
|
state->AddUnexpectedFlowControlCommand(
|
||||||
"endwhile",
|
"endwhile",
|
||||||
"An ENDWHILE command was found outside of a proper "
|
"An ENDWHILE command was found outside of a proper "
|
||||||
"WHILE ENDWHILE structure. Or its arguments did not "
|
"WHILE ENDWHILE structure. Or its arguments did not "
|
||||||
|
@ -481,7 +481,7 @@ void cmState::AddDisallowedCommand(std::string const& name,
|
|||||||
|
|
||||||
void cmState::AddUnexpectedCommand(std::string const& name, const char* error)
|
void cmState::AddUnexpectedCommand(std::string const& name, const char* error)
|
||||||
{
|
{
|
||||||
this->AddFlowControlCommand(
|
this->AddBuiltinCommand(
|
||||||
name,
|
name,
|
||||||
[name, error](std::vector<cmListFileArgument> const&,
|
[name, error](std::vector<cmListFileArgument> const&,
|
||||||
cmExecutionStatus& status) -> bool {
|
cmExecutionStatus& status) -> bool {
|
||||||
@ -496,6 +496,13 @@ void cmState::AddUnexpectedCommand(std::string const& name, const char* error)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cmState::AddUnexpectedFlowControlCommand(std::string const& name,
|
||||||
|
const char* error)
|
||||||
|
{
|
||||||
|
this->FlowControlCommands.insert(name);
|
||||||
|
this->AddUnexpectedCommand(name, error);
|
||||||
|
}
|
||||||
|
|
||||||
bool cmState::AddScriptedCommand(std::string const& name, BT<Command> command,
|
bool cmState::AddScriptedCommand(std::string const& name, BT<Command> command,
|
||||||
cmMakefile& mf)
|
cmMakefile& mf)
|
||||||
{
|
{
|
||||||
|
@ -166,6 +166,8 @@ public:
|
|||||||
void AddDisallowedCommand(std::string const& name, BuiltinCommand command,
|
void AddDisallowedCommand(std::string const& name, BuiltinCommand command,
|
||||||
cmPolicies::PolicyID policy, const char* message);
|
cmPolicies::PolicyID policy, const char* message);
|
||||||
void AddUnexpectedCommand(std::string const& name, const char* error);
|
void AddUnexpectedCommand(std::string const& name, const char* error);
|
||||||
|
void AddUnexpectedFlowControlCommand(std::string const& name,
|
||||||
|
const char* error);
|
||||||
bool AddScriptedCommand(std::string const& name, BT<Command> command,
|
bool AddScriptedCommand(std::string const& name, BT<Command> command,
|
||||||
cmMakefile& mf);
|
cmMakefile& mf);
|
||||||
void RemoveBuiltinCommand(std::string const& name);
|
void RemoveBuiltinCommand(std::string const& name);
|
||||||
|
1
Tests/RunCMake/Syntax/OverrideProject-result.txt
Normal file
1
Tests/RunCMake/Syntax/OverrideProject-result.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
1
|
3
Tests/RunCMake/Syntax/OverrideProject-stderr.txt
Normal file
3
Tests/RunCMake/Syntax/OverrideProject-stderr.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
^CMake Error at [^
|
||||||
|
]*/Tests/RunCMake/Syntax/Override\.cmake:[0-9]+ \(message\):
|
||||||
|
This shouldn't happen$
|
@ -150,3 +150,4 @@ run_override(If)
|
|||||||
run_override(Macro)
|
run_override(Macro)
|
||||||
run_override(Return)
|
run_override(Return)
|
||||||
run_override(While)
|
run_override(While)
|
||||||
|
run_override(Project)
|
||||||
|
Loading…
Reference in New Issue
Block a user