Don't hide #warnings in a system header, same as gcc. Fixes rdar://8495837.

llvm-svn: 129951
This commit is contained in:
Argyrios Kyrtzidis 2011-04-21 23:08:23 +00:00
parent 8a8b8773b6
commit b77d6f0fd1
6 changed files with 26 additions and 4 deletions

View File

@ -18,7 +18,8 @@ def MAP_IGNORE : DiagMapping;
def MAP_WARNING : DiagMapping;
def MAP_ERROR : DiagMapping;
def MAP_FATAL : DiagMapping;
def MAP_WARNING_NO_WERROR : DiagMapping;
def MAP_WARNING_NO_WERROR : DiagMapping;
def MAP_WARNING_SHOW_IN_SYSTEM_HEADER : DiagMapping;
// Define the diagnostic classes.
class DiagClass;
@ -76,7 +77,10 @@ class DefaultIgnore { DiagMapping DefaultMapping = MAP_IGNORE; }
class DefaultWarn { DiagMapping DefaultMapping = MAP_WARNING; }
class DefaultError { DiagMapping DefaultMapping = MAP_ERROR; }
class DefaultFatal { DiagMapping DefaultMapping = MAP_FATAL; }
class DefaultWarnNoWerror { DiagMapping DefaultMapping = MAP_WARNING_NO_WERROR; }
class DefaultWarnNoWerror { DiagMapping DefaultMapping= MAP_WARNING_NO_WERROR; }
class DefaultWarnShowInSystemHeader {
DiagMapping DefaultMapping = MAP_WARNING_SHOW_IN_SYSTEM_HEADER;
}
class NoSFINAE { bit SFINAE = 0; }
class AccessControl { bit AccessControl = 1; }

View File

@ -64,9 +64,12 @@ namespace clang {
/// Map this diagnostic to "warning", but make it immune to -Werror. This
/// happens when you specify -Wno-error=foo.
MAP_WARNING_NO_WERROR = 5,
/// Map this diagnostic to "warning", but make it immune to
/// -Wno-system-headers.
MAP_WARNING_SHOW_IN_SYSTEM_HEADER = 6,
/// Map this diagnostic to "error", but make it immune to -Wfatal-errors.
/// This happens for -Wno-fatal-errors=foo.
MAP_ERROR_NO_WFATAL = 6
MAP_ERROR_NO_WFATAL = 7
};
}

View File

@ -114,7 +114,8 @@ def err_invalid_pth_file : Error<
//===----------------------------------------------------------------------===//
// Preprocessor Diagnostics
//===----------------------------------------------------------------------===//
def pp_hash_warning : Warning<"#warning%0">, InGroup<PoundWarning>;
def pp_hash_warning : Warning<"#warning%0">,
InGroup<PoundWarning>, DefaultWarnShowInSystemHeader;
def pp_include_next_in_primary : Warning<
"#include_next in primary source file">;
def pp_include_macros_out_of_predefines : Error<

View File

@ -404,6 +404,8 @@ DiagnosticIDs::getDiagnosticLevel(unsigned DiagID, unsigned DiagClass,
if (mapping)
*mapping = (diag::Mapping) (MappingInfo & 7);
bool ShouldEmitInSystemHeader = false;
switch (MappingInfo & 7) {
default: assert(0 && "Unknown mapping!");
case diag::MAP_IGNORE:
@ -426,6 +428,9 @@ DiagnosticIDs::getDiagnosticLevel(unsigned DiagID, unsigned DiagClass,
case diag::MAP_FATAL:
Result = DiagnosticIDs::Fatal;
break;
case diag::MAP_WARNING_SHOW_IN_SYSTEM_HEADER:
ShouldEmitInSystemHeader = true;
// continue as MAP_WARNING.
case diag::MAP_WARNING:
// If warnings are globally mapped to ignore or error, do it.
if (Diag.IgnoreAllWarnings)
@ -477,6 +482,7 @@ DiagnosticIDs::getDiagnosticLevel(unsigned DiagID, unsigned DiagClass,
DiagClass != CLASS_ERROR &&
// Custom diagnostics always are emitted in system headers.
DiagID < diag::DIAG_UPPER_LIMIT &&
!ShouldEmitInSystemHeader &&
Diag.SuppressSystemWarnings &&
Loc.isValid() &&
Diag.getSourceManager().isInSystemHeader(

View File

@ -0,0 +1,4 @@
// RUN: %clang_cc1 -isystem %S %s -fsyntax-only -verify
#include <warn-in-system-header.h>
// expected-warning {{#warning}}

View File

@ -0,0 +1,4 @@
#warning the cake is a lie