]> granicus.if.org Git - clang/commitdiff
Allow notes to be printed following a fatal error, then suppress any
authorDouglas Gregor <dgregor@apple.com>
Thu, 19 Mar 2009 18:55:06 +0000 (18:55 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 19 Mar 2009 18:55:06 +0000 (18:55 +0000)
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

Driver/Warnings.cpp
lib/Basic/Diagnostic.cpp

index 3a9943516bc09fbc87f5c16a4f3320770b8db6c1..18e44d72e3c4c34518b95d9ad3778906aeb269b8 100644 (file)
@@ -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();
index 890b0c2ca5b98428b86319d373f4369f5f281e3a..378b8f514d3b3784a2100d686014c0b6bd474dbf 100644 (file)
@@ -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.