Index: cfe/trunk/include/clang/Basic/Diagnostic.h =================================================================== --- cfe/trunk/include/clang/Basic/Diagnostic.h +++ cfe/trunk/include/clang/Basic/Diagnostic.h @@ -209,8 +209,8 @@ // Used by __extension__ unsigned char AllExtensionsSilenced = 0; - // Suppress diagnostics after a fatal error? - bool SuppressAfterFatalError = true; + // Treat fatal errors like errors. + bool FatalsAsError = false; // Suppress all diagnostics. bool SuppressAllDiagnostics = false; @@ -614,9 +614,11 @@ void setErrorsAsFatal(bool Val) { GetCurDiagState()->ErrorsAsFatal = Val; } bool getErrorsAsFatal() const { return GetCurDiagState()->ErrorsAsFatal; } - /// When set to true (the default), suppress further diagnostics after - /// a fatal error. - void setSuppressAfterFatalError(bool Val) { SuppressAfterFatalError = Val; } + /// \brief When set to true, any fatal error reported is made an error. + /// + /// This setting takes precedence over the setErrorsAsFatal setting above. + void setFatalsAsError(bool Val) { FatalsAsError = Val; } + bool getFatalsAsError() const { return FatalsAsError; } /// When set to true mask warnings that come from system headers. void setSuppressSystemWarnings(bool Val) { Index: cfe/trunk/lib/Basic/DiagnosticIDs.cpp =================================================================== --- cfe/trunk/lib/Basic/DiagnosticIDs.cpp +++ cfe/trunk/lib/Basic/DiagnosticIDs.cpp @@ -481,6 +481,11 @@ Result = diag::Severity::Fatal; } + // If explicitly requested, map fatal errors to errors. + if (Result == diag::Severity::Fatal && + Diag.CurDiagID != diag::fatal_too_many_errors && Diag.FatalsAsError) + Result = diag::Severity::Error; + // Custom diagnostics always are emitted in system headers. bool ShowInSystemHeader = !GetDiagInfo(DiagID) || GetDiagInfo(DiagID)->WarnShowInSystemHeader; @@ -660,7 +665,7 @@ // If a fatal error has already been emitted, silence all subsequent // diagnostics. - if (Diag.FatalErrorOccurred && Diag.SuppressAfterFatalError) { + if (Diag.FatalErrorOccurred) { if (DiagLevel >= DiagnosticIDs::Error && Diag.Client->IncludeInDiagnosticCounts()) { ++Diag.NumErrors; Index: cfe/trunk/test/Index/Inputs/keep-going-template-instantiations.h =================================================================== --- cfe/trunk/test/Index/Inputs/keep-going-template-instantiations.h +++ cfe/trunk/test/Index/Inputs/keep-going-template-instantiations.h @@ -0,0 +1,3 @@ +template struct c {}; +using d = c; +struct foo : public d {}; Index: cfe/trunk/test/Index/keep-going-template-instantiations.cpp =================================================================== --- cfe/trunk/test/Index/keep-going-template-instantiations.cpp +++ cfe/trunk/test/Index/keep-going-template-instantiations.cpp @@ -0,0 +1,5 @@ +#include "missing.h" +#include + +// RUN: env CINDEXTEST_KEEP_GOING=1 c-index-test -test-load-source none -I%S/Inputs %s 2>&1 | FileCheck %s +// CHECK-NOT: error: expected class name Index: cfe/trunk/test/Index/keep-going.cpp =================================================================== --- cfe/trunk/test/Index/keep-going.cpp +++ cfe/trunk/test/Index/keep-going.cpp @@ -34,5 +34,5 @@ // CHECK-KEEP-GOING-ONLY: VarDecl=global_var:1:12 [type=int] [typekind=Int] [isPOD=1] -// CHECK-DIAG: keep-going.cpp:1:10: fatal error: 'missing1.h' file not found -// CHECK-DIAG: keep-going.cpp:8:10: fatal error: 'missing2.h' file not found +// CHECK-DIAG: keep-going.cpp:1:10: error: 'missing1.h' file not found +// CHECK-DIAG: keep-going.cpp:8:10: error: 'missing2.h' file not found Index: cfe/trunk/tools/libclang/CIndex.cpp =================================================================== --- cfe/trunk/tools/libclang/CIndex.cpp +++ cfe/trunk/tools/libclang/CIndex.cpp @@ -3408,7 +3408,7 @@ Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions)); if (options & CXTranslationUnit_KeepGoing) - Diags->setSuppressAfterFatalError(false); + Diags->setFatalsAsError(true); // Recover resources if we crash before exiting this function. llvm::CrashRecoveryContextCleanupRegistrar