| 1 |
// expected-warning@+1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}} |
| 2 |
#if UNSAFE_MACRO |
| 3 |
#endif |
| 4 |
|
| 5 |
// expected-warning@+1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}} |
| 6 |
#if defined(UNSAFE_MACRO) |
| 7 |
#endif |
| 8 |
|
| 9 |
// expected-warning@+1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}} |
| 10 |
#ifdef UNSAFE_MACRO |
| 11 |
#endif |
| 12 |
|
| 13 |
// expected-warning@+1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}} |
| 14 |
#ifndef UNSAFE_MACRO |
| 15 |
#endif |
| 16 |
|
| 17 |
// expected-warning@+1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}} |
| 18 |
const int x = UNSAFE_MACRO; |
| 19 |
|
| 20 |
// expected-warning@+1{{macro 'UNSAFE_MACRO_2' has been marked as unsafe for use in headers}} |
| 21 |
const int y = UNSAFE_MACRO_2; |
| 22 |
|
| 23 |
// not-expected-warning@+1{{macro 'UNSAFE_MACRO_2' has been marked as unsafe for use in headers}} |
| 24 |
#undef UNSAFE_MACRO_2 |
| 25 |
// not-expected-warning@+1{{macro 'UNSAFE_MACRO_2' has been marked as unsafe for use in headers}} |
| 26 |
#define UNSAFE_MACRO_2 2 |
| 27 |
|
| 28 |
// not-expected-warning@+1{{macro 'UNSAFE_MACRO_2' has been marked as unsafe for use in headers}} |
| 29 |
const int z = UNSAFE_MACRO_2; |
| 30 |
|
| 31 |
|
| 32 |
// Test that we diagnose on #elif. |
| 33 |
#if 0 |
| 34 |
#elif UNSAFE_MACRO |
| 35 |
// expected-warning@-1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}} |
| 36 |
#endif |
| 37 |
|
| 38 |
|
| 39 |
// Test that we diagnose on #elifdef. |
| 40 |
#ifdef baz |
| 41 |
#elifdef UNSAFE_MACRO |
| 42 |
// expected-warning@-1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}} |
| 43 |
// expected-warning@-2{{use of a '#elifdef' directive is a C23 extension}} |
| 44 |
#endif |
| 45 |
|
| 46 |
// Test that we diagnose on #elifndef. |
| 47 |
#ifdef baz |
| 48 |
#elifndef UNSAFE_MACRO |
| 49 |
#endif |
| 50 |
// expected-warning@-2{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}} |
| 51 |
// expected-warning@-3{{use of a '#elifndef' directive is a C23 extension}} |
| 52 |
|
| 53 |
// FIXME: These cases are currently not handled because clang doesn't expand |
| 54 |
// conditions on skipped #elif* blocks. See the FIXME notes in |
| 55 |
// Preprocessor::SkipExcludedConditionalBlock. |
| 56 |
|
| 57 |
#define frobble |
| 58 |
|
| 59 |
#ifdef frobble |
| 60 |
// not-expected-warning@+2{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}} |
| 61 |
// expected-warning@+1{{use of a '#elifndef' directive is a C23 extension}} |
| 62 |
#elifndef UNSAFE_MACRO |
| 63 |
#endif |
| 64 |
|
| 65 |
#ifdef frobble |
| 66 |
// not-expected-warning@+2{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}} |
| 67 |
// expected-warning@+1{{use of a '#elifdef' directive is a C23 extension}} |
| 68 |
#elifdef UNSAFE_MACRO |
| 69 |
#endif |
| 70 |
|
| 71 |
#if 1 |
| 72 |
// not-expected-warning@+1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}} |
| 73 |
#elif UNSAFE_MACRO |
| 74 |
#endif |