| 1 |
// Check that clang-diagnostic pragmas take precedence over suppression mapping. |
| 2 |
// RUN: %clang -cc1 -verify -Wformat=2 --warning-suppression-mappings=%S/Inputs/suppression-mapping.txt -fsyntax-only %s |
| 3 |
|
| 4 |
__attribute__((__format__ (__printf__, 1, 2))) |
| 5 |
void format_err(const char* const pString, ...); |
| 6 |
|
| 7 |
void foo() { |
| 8 |
const char *x; |
| 9 |
format_err(x); // Warning suppressed here. |
| 10 |
// check that pragmas take precedence |
| 11 |
#pragma clang diagnostic push |
| 12 |
#pragma clang diagnostic warning "-Wformat=2" |
| 13 |
format_err(x); // expected-warning{{format string is not a string literal (potentially insecure)}} \ |
| 14 |
// expected-note{{treat the string as an argument to avoid this}} |
| 15 |
#pragma clang diagnostic pop |
| 16 |
} |