[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / Preprocessor / elifdef.c
blob900d21e6548e05e14793f2da9d6dc68c38359442
1 // RUN: %clang_cc1 %s -Eonly -verify
3 /* expected-warning@+2 {{use of a '#elifdef' directive is a C2x extension}} */
4 #ifdef FOO
5 #elifdef BAR
6 #error "did not expect to get here"
7 #endif
9 /* expected-error@+5 {{"got it"}} */
10 /* expected-warning@+2 {{use of a '#elifdef' directive is a C2x extension}} */
11 #ifdef FOO
12 #elifdef BAR
13 #else
14 #error "got it"
15 #endif
17 /* expected-error@+4 {{"got it"}} */
18 /* expected-warning@+2 {{use of a '#elifndef' directive is a C2x extension}} */
19 #ifdef FOO
20 #elifndef BAR
21 #error "got it"
22 #endif
24 /* expected-error@+4 {{"got it"}} */
25 /* expected-warning@+2 {{use of a '#elifndef' directive is a C2x extension}} */
26 #ifdef FOO
27 #elifndef BAR
28 #error "got it"
29 #else
30 #error "did not expect to get here"
31 #endif
33 #define BAR
34 /* expected-error@+4 {{"got it"}} */
35 /* expected-warning@+2 {{use of a '#elifdef' directive is a C2x extension}} */
36 #ifdef FOO
37 #elifdef BAR
38 #error "got it"
39 #endif
40 #undef BAR
42 /* expected-warning@+2 {{use of a '#elifdef' directive is a C2x extension}} */
43 #ifdef FOO
44 #elifdef BAR // test that comments aren't an issue
45 #error "did not expect to get here"
46 #endif
48 /* expected-error@+5 {{"got it"}} */
49 /* expected-warning@+2 {{use of a '#elifdef' directive is a C2x extension}} */
50 #ifdef FOO
51 #elifdef BAR // test that comments aren't an issue
52 #else
53 #error "got it"
54 #endif
56 /* expected-error@+4 {{"got it"}} */
57 /* expected-warning@+2 {{use of a '#elifndef' directive is a C2x extension}} */
58 #ifdef FOO
59 #elifndef BAR // test that comments aren't an issue
60 #error "got it"
61 #endif
63 /* expected-error@+4 {{"got it"}} */
64 /* expected-warning@+2 {{use of a '#elifndef' directive is a C2x extension}} */
65 #ifdef FOO
66 #elifndef BAR // test that comments aren't an issue
67 #error "got it"
68 #else
69 #error "did not expect to get here"
70 #endif
72 #define BAR
73 /* expected-error@+4 {{"got it"}} */
74 /* expected-warning@+2 {{use of a '#elifdef' directive is a C2x extension}} */
75 #ifdef FOO
76 #elifdef BAR // test that comments aren't an issue
77 #error "got it"
78 #endif
79 #undef BAR
81 #define BAR
82 /* expected-error@+7 {{"got it"}} */
83 /* expected-warning@+3 {{use of a '#elifndef' directive is a C2x extension}} */
84 #ifdef FOO
85 #error "did not expect to get here"
86 #elifndef BAR
87 #error "did not expect to get here"
88 #else
89 #error "got it"
90 #endif
91 #undef BAR
93 /* expected-error@+4 {{#elifdef after #else}} */
94 /* expected-warning@+3 {{use of a '#elifdef' directive is a C2x extension}} */
95 #ifdef FOO
96 #else
97 #elifdef BAR
98 #endif
100 /* expected-error@+4 {{#elifndef after #else}} */
101 /* expected-warning@+3 {{use of a '#elifndef' directive is a C2x extension}} */
102 #ifdef FOO
103 #else
104 #elifndef BAR
105 #endif
107 /* expected-warning@+1 {{use of a '#elifdef' directive is a C2x extension}} */
108 #elifdef FOO /* expected-error {{#elifdef without #if}} */
109 #endif /* expected-error {{#endif without #if}} */
111 /* expected-warning@+1 {{use of a '#elifndef' directive is a C2x extension}} */
112 #elifndef FOO /* expected-error {{#elifndef without #if}} */
113 #endif /* expected-error {{#endif without #if}} */
115 /* Note, we do not expect errors about the missing macro name in the skipped
116 blocks. This is consistent with #elif behavior. */
117 /* expected-error@+4 {{"got it"}} */
118 /* expected-warning@+4 {{use of a '#elifdef' directive is a C2x extension}} */
119 /* expected-warning@+4 {{use of a '#elifndef' directive is a C2x extension}} */
120 #ifndef FOO
121 #error "got it"
122 #elifdef
123 #elifndef
124 #endif
126 /* expected-error@+3 {{#elif after #else}}*/
127 #if 1
128 #else
129 #elif
130 #endif