Index: test/Preprocessor/pragma_diagnostic_output.c
===================================================================
--- test/Preprocessor/pragma_diagnostic_output.c	(revision 0)
+++ test/Preprocessor/pragma_diagnostic_output.c	(revision 0)
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -E %s | FileCheck %s
+// CHECK: #pragma GCC diagnostic warning "-Wall"
+#pragma GCC diagnostic warning "-Wall"
+// CHECK: #pragma GCC diagnostic ignored "-Wall"
+#pragma GCC diagnostic ignored "-Wall"
+// CHECK: #pragma GCC diagnostic error "-Wall"
+#pragma GCC diagnostic error "-Wall"
+// CHECK: #pragma GCC diagnostic fatal "-Wall"
+#pragma GCC diagnostic fatal "-Wall"
+// CHECK: #pragma GCC diagnostic push
+#pragma GCC diagnostic push
+// CHECK: #pragma GCC diagnostic pop
+#pragma GCC diagnostic pop
Index: include/clang/Lex/PPCallbacks.h
===================================================================
--- include/clang/Lex/PPCallbacks.h	(revision 133347)
+++ include/clang/Lex/PPCallbacks.h	(working copy)
@@ -16,6 +16,7 @@
 
 #include "clang/Lex/DirectoryLookup.h"
 #include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/DiagnosticIDs.h"
 #include "llvm/ADT/StringRef.h"
 #include <string>
 
@@ -124,6 +125,22 @@
   virtual void PragmaMessage(SourceLocation Loc, llvm::StringRef Str) {
   }
 
+  /// PragmaDiagnosticPush - This callback is invoked when a
+  /// #pragma GCC dianostic push directive is read.
+  virtual void PragmaDiagnosticPush(SourceLocation Loc) {
+  }
+
+  /// PragmaDiagnosticPop - This callback is invoked when a
+  /// #pragma GCC dianostic pop directive is read.
+  virtual void PragmaDiagnosticPop(SourceLocation Loc) {
+  }
+
+  /// PragmaDiagnostic - This callback is invoked when a
+  /// #pragma GCC dianostic directive is read.
+  virtual void PragmaDiagnostic(SourceLocation Loc, diag::Mapping mapping,
+                                llvm::StringRef Str) {
+  }
+
   /// MacroExpands - This is called by
   /// Preprocessor::HandleMacroExpandedIdentifier when a macro invocation is
   /// found.
Index: lib/Frontend/PrintPreprocessedOutput.cpp
===================================================================
--- lib/Frontend/PrintPreprocessedOutput.cpp	(revision 133347)
+++ lib/Frontend/PrintPreprocessedOutput.cpp	(working copy)
@@ -26,6 +26,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Config/config.h"
 #include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/ErrorHandling.h"
 #include <cstdio>
 using namespace clang;
 
@@ -122,6 +123,10 @@
   virtual void PragmaComment(SourceLocation Loc, const IdentifierInfo *Kind,
                              const std::string &Str);
   virtual void PragmaMessage(SourceLocation Loc, llvm::StringRef Str);
+  virtual void PragmaDiagnosticPush(SourceLocation Loc);
+  virtual void PragmaDiagnosticPop(SourceLocation Loc);
+  virtual void PragmaDiagnostic(SourceLocation Loc, diag::Mapping Map,
+                                llvm::StringRef Str);
 
   bool HandleFirstTokOnLine(Token &Tok);
   bool MoveToLine(SourceLocation Loc) {
@@ -361,7 +366,41 @@
   EmittedTokensOnThisLine = true;
 }
 
+void PrintPPOutputPPCallbacks::PragmaDiagnosticPush(SourceLocation Loc) {
+  MoveToLine(Loc);
+  OS << "#pragma GCC diagnostic push";
+  EmittedTokensOnThisLine = true;
+}
 
+void PrintPPOutputPPCallbacks::PragmaDiagnosticPop(SourceLocation Loc) {
+  MoveToLine(Loc);
+  OS << "#pragma GCC diagnostic pop";
+  EmittedTokensOnThisLine = true;
+}
+
+void PrintPPOutputPPCallbacks::
+PragmaDiagnostic(SourceLocation Loc, diag::Mapping Map, llvm::StringRef Str) {
+  MoveToLine(Loc);
+  OS << "#pragma GCC diagnostic ";
+  switch (Map) {
+  default: llvm_unreachable("unexpected diagnostic kind");
+  case diag::MAP_WARNING:
+    OS << "warning";
+    break;
+  case diag::MAP_ERROR:
+    OS << "error";
+    break;
+  case diag::MAP_IGNORE:
+    OS << "ignored";
+    break;
+  case diag::MAP_FATAL:
+    OS << "fatal";
+    break;
+  }
+  OS << " \"" << Str << '"';
+  EmittedTokensOnThisLine = true;
+}
+
 /// HandleFirstTokOnLine - When emitting a preprocessed file in -E mode, this
 /// is called for the first token on each new line.  If this really is the start
 /// of a new logical line, handle it and return true, otherwise return false.
Index: lib/Lex/Pragma.cpp
===================================================================
--- lib/Lex/Pragma.cpp	(revision 133347)
+++ lib/Lex/Pragma.cpp	(working copy)
@@ -851,6 +851,7 @@
       return;
     }
     IdentifierInfo *II = Tok.getIdentifierInfo();
+    PPCallbacks *Callbacks = PP.getPPCallbacks();
 
     diag::Mapping Map;
     if (II->isStr("warning"))
@@ -864,10 +865,13 @@
     else if (II->isStr("pop")) {
       if (!PP.getDiagnostics().popMappings(DiagLoc))
         PP.Diag(Tok, diag::warn_pragma_diagnostic_cannot_pop);
-
+      else if (Callbacks)
+        Callbacks->PragmaDiagnosticPop(DiagLoc);
       return;
     } else if (II->isStr("push")) {
       PP.getDiagnostics().pushMappings(DiagLoc);
+      if (Callbacks)
+        Callbacks->PragmaDiagnosticPush(DiagLoc);
       return;
     } else {
       PP.Diag(Tok, diag::warn_pragma_diagnostic_invalid);
@@ -919,6 +923,8 @@
                                                       Map, DiagLoc))
       PP.Diag(StrToks[0].getLocation(),
               diag::warn_pragma_diagnostic_unknown_warning) << WarningName;
+    else if (Callbacks)
+      Callbacks->PragmaDiagnostic(DiagLoc, Map, WarningName);
   }
 };
 
