[cfe-commits] r69265 - in /cfe/trunk: include/clang/Basic/Diagnostic.h lib/Basic/Diagnostic.cpp test/Misc/diag-mapping2.c tools/clang-cc/Warnings.cpp
Chris Lattner
sabre at nondot.org
Wed Apr 15 21:32:54 PDT 2009
Author: lattner
Date: Wed Apr 15 23:32:54 2009
New Revision: 69265
URL: http://llvm.org/viewvc/llvm-project?rev=69265&view=rev
Log:
arrange for -Wno-error=foo warnings to be immune to -Werror as
they are supposed to be.
Added:
cfe/trunk/test/Misc/diag-mapping2.c
Modified:
cfe/trunk/include/clang/Basic/Diagnostic.h
cfe/trunk/lib/Basic/Diagnostic.cpp
cfe/trunk/tools/clang-cc/Warnings.cpp
Modified: cfe/trunk/include/clang/Basic/Diagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagnostic.h?rev=69265&r1=69264&r2=69265&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Diagnostic.h (original)
+++ cfe/trunk/include/clang/Basic/Diagnostic.h Wed Apr 15 23:32:54 2009
@@ -65,7 +65,16 @@
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
};
}
Modified: cfe/trunk/lib/Basic/Diagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Diagnostic.cpp?rev=69265&r1=69264&r2=69265&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Diagnostic.cpp (original)
+++ cfe/trunk/lib/Basic/Diagnostic.cpp Wed Apr 15 23:32:54 2009
@@ -382,7 +382,20 @@
// 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;
}
Added: cfe/trunk/test/Misc/diag-mapping2.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/diag-mapping2.c?rev=69265&view=auto
==============================================================================
--- cfe/trunk/test/Misc/diag-mapping2.c (added)
+++ cfe/trunk/test/Misc/diag-mapping2.c Wed Apr 15 23:32:54 2009
@@ -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
+
+
Modified: cfe/trunk/tools/clang-cc/Warnings.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/Warnings.cpp?rev=69265&r1=69264&r2=69265&view=diff
==============================================================================
--- cfe/trunk/tools/clang-cc/Warnings.cpp (original)
+++ cfe/trunk/tools/clang-cc/Warnings.cpp Wed Apr 15 23:32:54 2009
@@ -138,7 +138,7 @@
}
// -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;
}
More information about the cfe-commits
mailing list