[cfe-dev] Pushable #pragma diagnostics

Eli Friedman eli.friedman at gmail.com
Sun Jul 5 15:26:43 PDT 2009

On Sun, Jul 5, 2009 at 2:42 PM, Louis Gerbarg<lgerbarg at gmail.com> wrote:
> Implementing that is actually not particularly difficult, I have a patch
> attached for comment.The patch may require some slight cleanups, but it
> works. I also have some test cases on my system I can cleanup and send if
> people like this extension.

Looks like a good idea; I'll let Chris comment on it, though, since he
first implemented it.

--- a/lib/Lex/Preprocessor.cpp
+++ b/lib/Lex/Preprocessor.cpp
@@ -120,6 +120,20 @@ Preprocessor::~Preprocessor() {
   delete Callbacks;

+bool Preprocessor::popDiagnostics() {
+  if (PreviousDiagnostics.empty())
+    return false;
+  Diags = &PreviousDiagnostics.back();
+  PreviousDiagnostics.pop_back();
+  return true;

This makes Diags a pointer past the last element of the vector; not a
good idea, even if it does happen to work most of the time.


More information about the cfe-dev mailing list