| 1 | // Test that -Wsystem-headers works with default and custom mappings like -Werror. |
| 2 | // Keep run lines at the bottom for line number stability. |
| 3 | |
| 4 | #ifdef IS_SYSHEADER |
| 5 | #pragma clang system_header |
| 6 | |
| 7 | int f() { return (int)0; } // Use the old-style-cast warning as an arbitrary "ordinary" diagnostic for the purpose of testing. |
| 8 | |
| 9 | #warning "custom message" |
| 10 | |
| 11 | #if defined(A) || defined(B) |
| 12 | // expected-warning@9 {{"custom message"}} |
| 13 | #elif defined(C) |
| 14 | // expected-warning@7 {{use of old-style cast}} |
| 15 | // expected-warning@9 {{"custom message"}} |
| 16 | #elif defined(D) |
| 17 | // expected-error@7 {{use of old-style cast}} |
| 18 | // expected-error@9 {{"custom message"}} |
| 19 | #elif defined(E) |
| 20 | // expected-error@7 {{use of old-style cast}} |
| 21 | // expected-warning@9 {{"custom message"}} |
| 22 | #endif |
| 23 | |
| 24 | #else |
| 25 | #define IS_SYSHEADER |
| 26 | #include __FILE__ |
| 27 | #endif |
| 28 | |
| 29 | // RUN: %clang_cc1 -verify -fsyntax-only -DA %s |
| 30 | // RUN: %clang_cc1 -verify -fsyntax-only -DB -Wold-style-cast %s |
| 31 | // RUN: %clang_cc1 -verify -fsyntax-only -DC -Wold-style-cast -Wsystem-headers %s |
| 32 | // RUN: %clang_cc1 -verify -fsyntax-only -DD -Wold-style-cast -Wsystem-headers -Werror %s |
| 33 | // RUN: %clang_cc1 -verify -fsyntax-only -DE -Wold-style-cast -Wsystem-headers -Werror=old-style-cast %s |
| 34 | |