diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 1c3937fb5fac..0d0f68713d7d 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -3380,7 +3380,8 @@ def note_ovl_candidate_has_pass_object_size_params: Note< "candidate address cannot be taken because parameter %0 has " "pass_object_size attribute">; def err_diagnose_if_succeeded : Error<"%0">; -def warn_diagnose_if_succeeded : Warning<"%0">, InGroup; +def warn_diagnose_if_succeeded : Warning<"%0">, InGroup, + ShowInSystemHeader; def note_ovl_candidate_disabled_by_function_cond_attr : Note< "candidate disabled: %0">; def note_ovl_candidate_disabled_by_extension : Note< diff --git a/clang/test/Sema/Inputs/diagnose-if-warn-system-header.h b/clang/test/Sema/Inputs/diagnose-if-warn-system-header.h new file mode 100644 index 000000000000..753c69d4b532 --- /dev/null +++ b/clang/test/Sema/Inputs/diagnose-if-warn-system-header.h @@ -0,0 +1,11 @@ +#pragma GCC system_header + +inline int system_header_func(int x) + __attribute__((diagnose_if(x == x, "system header warning", "warning"))) // expected-note {{from 'diagnose_if' attribute}} +{ + return 0; +} + +void test_system_header() { + system_header_func(0); // expected-warning {{system header warning}} +} diff --git a/clang/test/Sema/diagnose_if.c b/clang/test/Sema/diagnose_if.c index 219e393bc0cc..6dd8bafe8be6 100644 --- a/clang/test/Sema/diagnose_if.c +++ b/clang/test/Sema/diagnose_if.c @@ -150,3 +150,6 @@ void alwaysWarnWithArg(int a) _diagnose_if(1 || a, "alwaysWarn", "warning"); // void runAlwaysWarnWithArg(int a) { alwaysWarnWithArg(a); // expected-warning{{alwaysWarn}} } + +// Test that diagnose_if warnings generated in system headers are not ignored. +#include "Inputs/diagnose-if-warn-system-header.h"