mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-10 10:01:42 +00:00
Don't hide #warnings in a system header, same as gcc. Fixes rdar://8495837.
llvm-svn: 129951
This commit is contained in:
parent
8a8b8773b6
commit
b77d6f0fd1
@ -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; }
|
||||
|
@ -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
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -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<
|
||||
|
@ -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(
|
||||
|
4
clang/test/Misc/warn-in-system-header.c
Normal file
4
clang/test/Misc/warn-in-system-header.c
Normal file
@ -0,0 +1,4 @@
|
||||
// RUN: %clang_cc1 -isystem %S %s -fsyntax-only -verify
|
||||
|
||||
#include <warn-in-system-header.h>
|
||||
// expected-warning {{#warning}}
|
4
clang/test/Misc/warn-in-system-header.h
Normal file
4
clang/test/Misc/warn-in-system-header.h
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
|
||||
|
||||
#warning the cake is a lie
|
Loading…
Reference in New Issue
Block a user