1 // expected-warning@+1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}}
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)
9 // expected-warning@+1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}}
13 // expected-warning@+1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}}
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
;
20 // expected-warning@+1{{macro 'UNSAFE_MACRO_2' has been marked as unsafe for use in headers}}
21 const int y
= UNSAFE_MACRO_2
;
23 // not-expected-warning@+1{{macro 'UNSAFE_MACRO_2' has been marked as unsafe for use in headers}}
25 // not-expected-warning@+1{{macro 'UNSAFE_MACRO_2' has been marked as unsafe for use in headers}}
26 #define UNSAFE_MACRO_2 2
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
;
32 // Test that we diagnose on #elif.
35 // expected-warning@-1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}}
39 // Test that we diagnose on #elifdef.
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}}
46 // Test that we diagnose on #elifndef.
48 #elifndef UNSAFE_MACRO
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}}
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.
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
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}}
72 // not-expected-warning@+1{{macro 'UNSAFE_MACRO' has been marked as unsafe for use in headers: Don't use this!}}