Merge topic 'fix-continue-after-error'

f1ad71d7 cmMakefile: Restore nested error logic use of cmExecutionStatus
This commit is contained in:
Brad King 2016-09-07 09:48:32 -04:00 committed by CMake Topic Stage
commit 85bfec7572
9 changed files with 62 additions and 16 deletions

View File

@ -40,12 +40,16 @@ public:
this->ReturnInvoked = false;
this->BreakInvoked = false;
this->ContinueInvoked = false;
this->NestedError = false;
}
void SetNestedError(bool val) { this->NestedError = val; }
bool GetNestedError() { return this->NestedError; }
private:
bool ReturnInvoked;
bool BreakInvoked;
bool ContinueInvoked;
bool NestedError;
};
#endif

View File

@ -76,7 +76,7 @@ public:
};
bool cmFunctionHelperCommand::InvokeInitialPass(
const std::vector<cmListFileArgument>& args, cmExecutionStatus&)
const std::vector<cmListFileArgument>& args, cmExecutionStatus& inStatus)
{
// Expand the argument list to the function.
std::vector<std::string> expandedArgs;
@ -129,11 +129,11 @@ bool cmFunctionHelperCommand::InvokeInitialPass(
for (unsigned int c = 0; c < this->Functions.size(); ++c) {
cmExecutionStatus status;
if (!this->Makefile->ExecuteCommand(this->Functions[c], status) ||
(cmSystemTools::GetErrorOccuredFlag() &&
!cmSystemTools::GetFatalErrorOccured())) {
status.GetNestedError()) {
// The error message should have already included the call stack
// so we do not need to report an error here.
functionScope.Quiet();
inStatus.SetNestedError(true);
return false;
}
if (status.GetReturnInvoked()) {

View File

@ -159,11 +159,11 @@ bool cmMacroHelperCommand::InvokeInitialPass(
}
cmExecutionStatus status;
if (!this->Makefile->ExecuteCommand(newLFF, status) ||
(cmSystemTools::GetErrorOccuredFlag() &&
!cmSystemTools::GetFatalErrorOccured())) {
status.GetNestedError()) {
// The error message should have already included the call stack
// so we do not need to report an error here.
macroScope.Quiet();
inStatus.SetNestedError(true);
return false;
}
if (status.GetReturnInvoked()) {

View File

@ -117,6 +117,11 @@ cmMakefile::~cmMakefile()
void cmMakefile::IssueMessage(cmake::MessageType t,
std::string const& text) const
{
if (!this->ExecutionStatusStack.empty()) {
if ((t == cmake::FATAL_ERROR) || (t == cmake::INTERNAL_ERROR)) {
this->ExecutionStatusStack.back()->SetNestedError(true);
}
}
this->GetCMakeInstance()->IssueMessage(t, text, this->GetBacktrace());
}
@ -277,19 +282,11 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
if (this->GetCMakeInstance()->GetTrace()) {
this->PrintCommandTrace(lff);
}
bool hadPreviousNonFatalError = cmSystemTools::GetErrorOccuredFlag() &&
!cmSystemTools::GetFatalErrorOccured();
cmSystemTools::ResetErrorOccuredFlag();
// Try invoking the command.
bool invokeSucceeded = pcmd->InvokeInitialPass(lff.Arguments, status);
bool hadNestedError = cmSystemTools::GetErrorOccuredFlag() &&
!cmSystemTools::GetFatalErrorOccured();
if (hadPreviousNonFatalError) {
cmSystemTools::SetErrorOccured();
}
bool hadNestedError = status.GetNestedError();
if (!invokeSucceeded || hadNestedError) {
if (!hadNestedError && !cmSystemTools::GetFatalErrorOccured()) {
if (!hadNestedError) {
// The command invocation requested that we report an error.
this->IssueMessage(cmake::FATAL_ERROR, pcmd->GetError());
}

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,13 @@
^CMake Error at ContinueAfterError.cmake:[0-9]+ \(message\):
error in loop body
Call Stack \(most recent call first\):
ContinueAfterError.cmake:[0-9]+ \(m\)
ContinueAfterError.cmake:[0-9]+ \(f\)
CMakeLists.txt:[0-9]+ \(include\)
+
CMake Error at ContinueAfterError.cmake:[0-9]+ \(message\):
error in loop body
Call Stack \(most recent call first\):
ContinueAfterError.cmake:[0-9]+ \(m\)
ContinueAfterError.cmake:[0-9]+ \(f\)
CMakeLists.txt:[0-9]+ \(include\)$

View File

@ -0,0 +1,11 @@
-- before f
-- start f
-- start m
-- start loop body
-- end loop body
-- start loop body
-- end loop body
-- end m
-- end f
-- after f
-- Configuring incomplete, errors occurred!

View File

@ -0,0 +1,19 @@
macro(m)
message(STATUS " start m")
foreach(i 1 2)
message(STATUS " start loop body")
message(SEND_ERROR "error in loop body")
message(STATUS " end loop body")
endforeach()
message(STATUS " end m")
endmacro()
function(f)
message(STATUS " start f")
m()
message(STATUS " end f")
endfunction()
message(STATUS "before f")
f()
message(STATUS "after f")

View File

@ -1,5 +1,6 @@
include(RunCMake)
run_cmake(ContinueAfterError)
run_cmake(CustomTargetAfterError)
run_cmake(ErrorLogs)
run_cmake(FailCopyFileABI)