[cfe-commits] r141119 - in /cfe/trunk: lib/Basic/Diagnostic.cpp test/Frontend/warning-mapping-5.c

Daniel Dunbar daniel at zuster.org
Tue Oct 4 14:17:25 PDT 2011


Author: ddunbar
Date: Tue Oct  4 16:17:24 2011
New Revision: 141119

URL: http://llvm.org/viewvc/llvm-project?rev=141119&view=rev
Log:
Basic/Diagnostics: Apparently, #pragma ... diagnostic is intended to override
the command line options (at least according to GCC's documentation). GCC 4.2
didn't appear to actually do this, but it seems like that has been fixed in
later release, so we will follow the docs.

Added:
    cfe/trunk/test/Frontend/warning-mapping-5.c
Modified:
    cfe/trunk/lib/Basic/Diagnostic.cpp

Modified: cfe/trunk/lib/Basic/Diagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Diagnostic.cpp?rev=141119&r1=141118&r2=141119&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Diagnostic.cpp (original)
+++ cfe/trunk/lib/Basic/Diagnostic.cpp Tue Oct  4 16:17:24 2011
@@ -175,6 +175,13 @@
   DiagnosticMappingInfo MappingInfo = DiagnosticMappingInfo::Make(
     Map, /*IsUser=*/true, isPragma);
 
+  // If this is a pragma mapping, then set the diagnostic mapping flags so that
+  // we override command line options.
+  if (isPragma) {
+    MappingInfo.setNoWarningAsError(true);
+    MappingInfo.setNoErrorAsFatal(true);
+  }
+
   // Common case; setting all the diagnostics of a group in one place.
   if (Loc.isInvalid() || Loc == LastStateChangePos) {
     GetCurDiagState()->setMappingInfo(Diag, MappingInfo);

Added: cfe/trunk/test/Frontend/warning-mapping-5.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/warning-mapping-5.c?rev=141119&view=auto
==============================================================================
--- cfe/trunk/test/Frontend/warning-mapping-5.c (added)
+++ cfe/trunk/test/Frontend/warning-mapping-5.c Tue Oct  4 16:17:24 2011
@@ -0,0 +1,9 @@
+// Check that #pragma diagnostic warning overrides -Werror. This matches GCC's
+// original documentation, but not its earlier implementations.
+// 
+// RUN: %clang_cc1 -verify -Werror %s
+
+#pragma clang diagnostic warning "-Wsign-compare"
+int f0(int x, unsigned y) {
+  return x < y; // expected-warning {{comparison of integers}}
+}





More information about the cfe-commits mailing list