]> granicus.if.org Git - clang/commitdiff
arrange for -Wno-error=foo warnings to be immune to -Werror as
authorChris Lattner <sabre@nondot.org>
Thu, 16 Apr 2009 04:32:54 +0000 (04:32 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 16 Apr 2009 04:32:54 +0000 (04:32 +0000)
they are supposed to be.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69265 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/Diagnostic.h
lib/Basic/Diagnostic.cpp
test/Misc/diag-mapping2.c [new file with mode: 0644]
tools/clang-cc/Warnings.cpp

index 1d071110bc23fa578f694474a9e1c3ae3ed8c565..99251709aa9f0dfeef78a573b5ce59749e9a3928 100644 (file)
@@ -65,7 +65,16 @@ namespace clang {
       MAP_IGNORE  = 1,     //< Map this diagnostic to nothing, ignore it.
       MAP_WARNING = 2,     //< Map this diagnostic to a warning.
       MAP_ERROR   = 3,     //< Map this diagnostic to an error.
-      MAP_FATAL   = 4      //< Map this diagnostic to a fatal error.
+      MAP_FATAL   = 4,     //< Map this diagnostic to a fatal error.
+      
+      /// Map this diagnostic to "warning", but make it immune to
+      /// -pedantic-errors.  This happens when you specify -Wfoo for an
+      /// extension warning.
+      MAP_WARNING_NO_PEDANTIC_ERROR = 5,
+      
+      /// Map this diagnostic to "warning", but make it immune to -Werror and
+      /// -pedantic-errors.  This happens when you specify -Wno-error=foo.
+      MAP_WARNING_NO_WERROR = 6
     };
   }
   
index 19bfeeea72ad5913c5469e2fbe1aa49d7eb83295..6b7f732b3f0863a3314cf54e861afb39e68efa05 100644 (file)
@@ -382,7 +382,20 @@ Diagnostic::getDiagnosticLevel(unsigned DiagID, unsigned DiagClass) const {
     // If warnings are globally mapped to ignore or error, do it.
     if (IgnoreAllWarnings)
       return Diagnostic::Ignored;
-    Result = WarningsAsErrors ? Diagnostic::Error : Diagnostic::Warning;
+      
+    Result = Diagnostic::Warning;
+    if (WarningsAsErrors)
+      Result = Diagnostic::Error;
+    break;
+  case diag::MAP_WARNING_NO_WERROR:
+    // Diagnostics specified with -Wno-error=foo should be set to warnings, but
+    // not be adjusted by -Werror or -pedantic-errors.
+    Result = Diagnostic::Warning;
+      
+    // If warnings are globally mapped to ignore or error, do it.
+    if (IgnoreAllWarnings)
+      return Diagnostic::Ignored;
+      
     break;
   }
 
diff --git a/test/Misc/diag-mapping2.c b/test/Misc/diag-mapping2.c
new file mode 100644 (file)
index 0000000..7e0d774
--- /dev/null
@@ -0,0 +1,19 @@
+// This should warn by default.
+// RUN: clang-cc %s 2>&1 | grep "warning:" &&
+
+// This should not emit anything.
+// RUN: clang-cc %s -w 2>&1 | not grep diagnostic &&
+// RUN: clang-cc %s -Wno-#warnings 2>&1 | not grep diagnostic &&
+
+// -Werror can map all warnings to error.
+// RUN: clang-cc %s -Werror 2>&1 | grep "error:" &&
+
+// -Werror can map this one warning to error.
+// RUN: clang-cc %s -Werror=#warnings 2>&1 | grep "error:" &&
+
+// -Wno-error= overrides -Werror.  rdar://3158301
+// RUN: clang-cc %s -Werror -Wno-error=#warnings 2>&1 | grep "warning:"
+
+#warning foo
+
+
index ccaa6533e1cd58a29c4f01cb22fd872a02f75a47..818e7743d87b5ae55b63cbfd9023552a4ed680dd 100644 (file)
@@ -138,7 +138,7 @@ bool clang::ProcessWarningOptions(Diagnostic &Diags) {
       }
       
       // -Werror=foo maps foo to Error, -Wno-error=foo maps it to Warning.
-      Mapping = isPositive ? diag::MAP_ERROR : diag::MAP_WARNING;
+      Mapping = isPositive ? diag::MAP_ERROR : diag::MAP_WARNING_NO_WERROR;
       OptStart = Specifier;
     }