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.

llvm-svn: 141119
This commit is contained in:
Daniel Dunbar 2011-10-04 21:17:24 +00:00
parent 4dfad843e3
commit 2fba0979fe
2 changed files with 16 additions and 0 deletions

View File

@ -175,6 +175,13 @@ void DiagnosticsEngine::setDiagnosticMapping(diag::kind Diag, diag::Mapping Map,
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);

View File

@ -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}}
}