]> granicus.if.org Git - clang/commitdiff
For Diagnostic::Reset() also reset the state related to #pragma diagnostic. Fixes...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sat, 26 Mar 2011 18:58:17 +0000 (18:58 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sat, 26 Mar 2011 18:58:17 +0000 (18:58 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128346 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Basic/Diagnostic.cpp
test/Index/pragma-diag-reparse.c [new file with mode: 0644]

index dc81f88c5c595daac7aa02fecfa9e1ba6f551826..7601d49d4dfef72bf8208f1e72d969009262b6cc 100644 (file)
@@ -51,11 +51,6 @@ Diagnostic::Diagnostic(const llvm::IntrusiveRefCntPtr<DiagnosticIDs> &diags,
   ErrorLimit = 0;
   TemplateBacktraceLimit = 0;
 
-  // Create a DiagState and DiagStatePoint representing diagnostic changes
-  // through command-line.
-  DiagStates.push_back(DiagState());
-  PushDiagStatePoint(&DiagStates.back(), SourceLocation());
-
   Reset();
 }
 
@@ -102,6 +97,16 @@ void Diagnostic::Reset() {
   // displayed.
   LastDiagLevel = (DiagnosticIDs::Level)-1;
   DelayedDiagID = 0;
+
+  // Clear state related to #pragma diagnostic.
+  DiagStates.clear();
+  DiagStatePoints.clear();
+  DiagStateOnPushStack.clear();
+
+  // Create a DiagState and DiagStatePoint representing diagnostic changes
+  // through command-line.
+  DiagStates.push_back(DiagState());
+  PushDiagStatePoint(&DiagStates.back(), SourceLocation());
 }
 
 void Diagnostic::SetDelayedDiagnostic(unsigned DiagID, llvm::StringRef Arg1,
diff --git a/test/Index/pragma-diag-reparse.c b/test/Index/pragma-diag-reparse.c
new file mode 100644 (file)
index 0000000..efe59b1
--- /dev/null
@@ -0,0 +1,13 @@
+// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 5 local %s | FileCheck %s
+
+int main (int argc, const char * argv[])
+{
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+  int x;
+#pragma clang diagnostic pop
+
+  return 0;
+}
+
+// CHECK: pragma-diag-reparse.c:7:7: VarDecl=x:7:7 (Definition) Extent=[7:3 - 7:8]