From: Douglas Gregor Date: Thu, 19 Mar 2009 18:55:06 +0000 (+0000) Subject: Allow notes to be printed following a fatal error, then suppress any X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=525c4b0d1bd1a70bf269adecf91b192f3e6c1a89;p=clang Allow notes to be printed following a fatal error, then suppress any diagnostics following those notes. Make exceeding the template instantiation depth a fatal error. Thanks to Daniel for pointing out the problem! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67320 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Driver/Warnings.cpp b/Driver/Warnings.cpp index 3a9943516b..18e44d72e3 100644 --- a/Driver/Warnings.cpp +++ b/Driver/Warnings.cpp @@ -170,6 +170,8 @@ bool ProcessWarningOptions(Diagnostic &Diags) { diag::MAP_IGNORE); Diags.setDiagnosticMapping(diag::err_pp_file_not_found, diag::MAP_FATAL); + Diags.setDiagnosticMapping(diag::err_template_recursion_depth_exceeded, + diag::MAP_FATAL); Diags.setSuppressSystemWarnings(!OptWarnInSystemHeaders); for (OptionsList::iterator it = Options.begin(), e = Options.end(); diff --git a/lib/Basic/Diagnostic.cpp b/lib/Basic/Diagnostic.cpp index 890b0c2ca5..378b8f514d 100644 --- a/lib/Basic/Diagnostic.cpp +++ b/lib/Basic/Diagnostic.cpp @@ -217,7 +217,7 @@ Diagnostic::Diagnostic(DiagnosticClient *client) : Client(client) { NumErrors = 0; CustomDiagInfo = 0; CurDiagID = ~0U; - LastDiagLevel = Fatal; + LastDiagLevel = Ignored; ArgToStringFn = DummyArgToStringFn; ArgToStringCookie = 0; @@ -336,12 +336,7 @@ Diagnostic::getDiagnosticLevel(unsigned DiagID, unsigned DiagClass) const { /// finally fully formed. void Diagnostic::ProcessDiag() { DiagnosticInfo Info(this); - - // If a fatal error has already been emitted, silence all subsequent - // diagnostics. - if (FatalErrorOccurred) - return; - + // Figure out the diagnostic level of this message. Diagnostic::Level DiagLevel; unsigned DiagID = Info.getID(); @@ -375,9 +370,22 @@ void Diagnostic::ProcessDiag() { } } - if (DiagLevel != Diagnostic::Note) + if (DiagLevel != Diagnostic::Note) { + // Record that a fatal error occurred only when we see a second + // non-note diagnostic. This allows notes to be attached to the + // fatal error, but suppresses any diagnostics that follow those + // notes. + if (LastDiagLevel == Diagnostic::Fatal) + FatalErrorOccurred = true; + LastDiagLevel = DiagLevel; - + } + + // If a fatal error has already been emitted, silence all subsequent + // diagnostics. + if (FatalErrorOccurred) + return; + // If the client doesn't care about this message, don't issue it. If this is // a note and the last real diagnostic was ignored, ignore it too. if (DiagLevel == Diagnostic::Ignored || @@ -397,9 +405,6 @@ void Diagnostic::ProcessDiag() { if (DiagLevel >= Diagnostic::Error) { ErrorOccurred = true; ++NumErrors; - - if (DiagLevel == Diagnostic::Fatal) - FatalErrorOccurred = true; } // Finally, report it.