[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Lexer / Inputs / unsafe-macro-2.h
blobabec80477d73910f617610537f1a238fee49c48c
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
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
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
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
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}}
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
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.
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
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
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}}
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.
57 #define frobble
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
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
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