Fix PR1966 by ignoring non-error diagnostics from system headers even if they are 
*mapped* onto errors.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46686 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Basic/Diagnostic.cpp b/Basic/Diagnostic.cpp
index 158e8ff..de311a4 100644
--- a/Basic/Diagnostic.cpp
+++ b/Basic/Diagnostic.cpp
@@ -200,22 +200,28 @@
 void Diagnostic::Report(FullSourceLoc Pos, unsigned DiagID,
                         const std::string *Strs, unsigned NumStrs,
                         const SourceRange *Ranges, unsigned NumRanges) {
+  
   // Figure out the diagnostic level of this message.
   Diagnostic::Level DiagLevel = getDiagnosticLevel(DiagID);
   
   // If the client doesn't care about this message, don't issue it.
   if (DiagLevel == Diagnostic::Ignored)
     return;
+
+  // If this is not an error and we are in a system header, ignore it.  We have
+  // to check on the original class here, because we also want to ignore
+  // extensions and warnings in -Werror and -pedantic-errors modes, which *map*
+  // warnings/extensions to errors.
+  if (DiagID < diag::NUM_BUILTIN_DIAGNOSTICS &&
+      getBuiltinDiagClass(DiagID) != ERROR &&
+      Client.isInSystemHeader(Pos))
+    return;
   
   if (DiagLevel >= Diagnostic::Error) {
     ErrorOccurred = true;
     ++NumErrors;
   }
 
-  // Are we going to ignore this diagnosic?
-  if (Client.IgnoreDiagnostic(DiagLevel, Pos))
-    return;
-
   // Finally, report it.
   Client.HandleDiagnostic(*this, DiagLevel, Pos, (diag::kind)DiagID,
                           Strs, NumStrs, Ranges, NumRanges);