EricWF created this revision. EricWF added reviewers: george.burgess.iv, rsmith, aaron.ballman. EricWF added a subscriber: cfe-commits.
In order for libc++ to meaningfully use `diagnose_if` warnings they need to be emitted from system headers by default. This patch changes the `diagnose_if` warning diagnostic to be shown in system headers. https://reviews.llvm.org/D28703 Files: include/clang/Basic/DiagnosticSemaKinds.td test/Sema/Inputs/diagnose-if-warn-system-header.h test/Sema/diagnose_if.c Index: test/Sema/diagnose_if.c =================================================================== --- test/Sema/diagnose_if.c +++ test/Sema/diagnose_if.c @@ -150,3 +150,6 @@ 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" Index: test/Sema/Inputs/diagnose-if-warn-system-header.h =================================================================== --- /dev/null +++ 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}} +} Index: include/clang/Basic/DiagnosticSemaKinds.td =================================================================== --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -3380,7 +3380,8 @@ "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<UserDefinedWarnings>; +def warn_diagnose_if_succeeded : Warning<"%0">, InGroup<UserDefinedWarnings>, + ShowInSystemHeader; def note_ovl_candidate_disabled_by_function_cond_attr : Note< "candidate disabled: %0">; def note_ovl_candidate_disabled_by_extension : Note<
Index: test/Sema/diagnose_if.c =================================================================== --- test/Sema/diagnose_if.c +++ test/Sema/diagnose_if.c @@ -150,3 +150,6 @@ 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" Index: test/Sema/Inputs/diagnose-if-warn-system-header.h =================================================================== --- /dev/null +++ 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}} +} Index: include/clang/Basic/DiagnosticSemaKinds.td =================================================================== --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -3380,7 +3380,8 @@ "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<UserDefinedWarnings>; +def warn_diagnose_if_succeeded : Warning<"%0">, InGroup<UserDefinedWarnings>, + ShowInSystemHeader; def note_ovl_candidate_disabled_by_function_cond_attr : Note< "candidate disabled: %0">; def note_ovl_candidate_disabled_by_extension : Note<
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits