[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / Lexer / deprecate-macro.c
blob1f08093b17a4ec38bf63980184220c3185ced827
1 // RUN: %clang_cc1 -Wdeprecated %s -fsyntax-only -verify
3 // expected-error@+1{{expected (}}
4 #pragma clang deprecated
6 // expected-error@+1{{expected identifier}}
7 #pragma clang deprecated(4
9 // expected-error@+1{{no macro named 'foo'}}
10 #pragma clang deprecated(foo)
12 #define bar 1
13 // expected-note@+1{{macro marked 'deprecated' here}}
14 #pragma clang deprecated(bar, "bar is deprecated use 1")
16 // expected-warning@+1{{macro 'bar' has been marked as deprecated: bar is deprecated use 1}}
17 #if bar
18 #endif
20 #define foo 1
21 // expected-note@+8{{macro marked 'deprecated' here}}
22 // expected-note@+7{{macro marked 'deprecated' here}}
23 // expected-note@+6{{macro marked 'deprecated' here}}
24 // expected-note@+5{{macro marked 'deprecated' here}}
25 // expected-note@+4{{macro marked 'deprecated' here}}
26 // expected-note@+3{{macro marked 'deprecated' here}}
27 // expected-note@+2{{macro marked 'deprecated' here}}
28 // expected-note@+1{{macro marked 'deprecated' here}}
29 #pragma clang deprecated(foo)
31 // expected-error@+1{{expected )}}
32 #pragma clang deprecated(foo
34 // expected-warning@+1{{macro 'foo' has been marked as deprecated}}
35 #if foo
36 #endif
38 // expected-warning@+1{{macro 'foo' has been marked as deprecated}}
39 #if defined(foo)
40 #endif
42 // expected-warning@+1{{macro 'foo' has been marked as deprecated}}
43 #ifdef foo
44 #endif
46 // expected-warning@+1{{macro 'foo' has been marked as deprecated}}
47 #ifndef foo
48 #endif
50 int main(int argc, char** argv) {
51 // expected-error@+1{{no macro named 'main'}}
52 #pragma clang deprecated(main)
54 // expected-warning@+1{{macro 'foo' has been marked as deprecated}}
55 return foo;
58 #define frobble 1
59 #pragma clang deprecated(frobble)
61 // not-expected-warning@+1{{macro 'frobble' has been marked as deprecated}}
62 #undef frobble // Expect no diagnostics here
64 // not-expected-warning@+1{{macro 'frobble' has been marked as deprecated}}
65 #define frobble 1 // How about here given that this was undefined?
67 // not-expected-warning@+1{{macro 'frobble' has been marked as deprecated}}
68 #if defined(frobble)
69 #endif
71 // Test that we diagnose on #elif.
72 #if 0
73 #elif foo
74 // expected-warning@-1{{macro 'foo' has been marked as deprecated}}
75 #endif
78 // Test that we diagnose on #elifdef.
79 #ifdef baz
80 #elifdef foo
81 // expected-warning@-1{{macro 'foo' has been marked as deprecated}}
82 // expected-warning@-2{{use of a '#elifdef' directive is a C2x extension}}
83 #endif
85 // Test that we diagnose on #elifndef.
86 #ifdef baz
87 #elifndef foo
88 #endif
89 // expected-warning@-2{{macro 'foo' has been marked as deprecated}}
90 // expected-warning@-3{{use of a '#elifndef' directive is a C2x extension}}
92 // FIXME: These cases are currently not handled because clang doesn't expand
93 // conditions on skipped #elif* blocks. See the FIXME notes in
94 // Preprocessor::SkipExcludedConditionalBlock.
96 #ifdef frobble
97 // not-expected-warning@+2{{macro 'foo' has been marked as deprecated}}
98 // expected-warning@+1{{use of a '#elifndef' directive is a C2x extension}}
99 #elifndef foo
100 #endif
102 #ifdef frobble
103 // not-expected-warning@+2{{macro 'foo' has been marked as deprecated}}
104 // expected-warning@+1{{use of a '#elifdef' directive is a C2x extension}}
105 #elifdef foo
106 #endif
108 #if 1
109 // not-expected-warning@+1{{macro 'foo' has been marked as deprecated}}
110 #elif foo
111 #endif