diff options
Diffstat (limited to 'test/Sema')
-rw-r--r-- | test/Sema/Inputs/diagnose-if-warn-system-header.h | 11 | ||||
-rw-r--r-- | test/Sema/diagnose_if.c | 9 |
2 files changed, 17 insertions, 3 deletions
diff --git a/test/Sema/Inputs/diagnose-if-warn-system-header.h b/test/Sema/Inputs/diagnose-if-warn-system-header.h new file mode 100644 index 000000000000..753c69d4b532 --- /dev/null +++ b/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/test/Sema/diagnose_if.c b/test/Sema/diagnose_if.c index 219e393bc0cc..27689f49b431 100644 --- a/test/Sema/diagnose_if.c +++ b/test/Sema/diagnose_if.c @@ -70,14 +70,14 @@ void runVariable() { #define _overloadable __attribute__((overloadable)) -int ovl1(const char *n) _overloadable _diagnose_if(n, "oh no", "error"); // expected-note{{oh no}} -int ovl1(void *m) _overloadable; // expected-note{{candidate function}} +int ovl1(const char *n) _overloadable _diagnose_if(n, "oh no", "error"); // expected-note{{from 'diagnose_if'}} +int ovl1(void *m) _overloadable; int ovl2(const char *n) _overloadable _diagnose_if(n, "oh no", "error"); // expected-note{{candidate function}} int ovl2(char *m) _overloadable; // expected-note{{candidate function}} void overloadsYay() { ovl1((void *)0); - ovl1(""); // expected-error{{call to unavailable function}} + ovl1(""); // expected-error{{oh no}} ovl2((void *)0); // expected-error{{ambiguous}} } @@ -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" |