| 1 | /*============================================================================= |
| 2 | Boost.Wave: A Standard compliant C++ preprocessor library |
| 3 | http://www.boost.org/ |
| 4 | |
| 5 | Copyright (c) 2022 Jeff Trull. Distributed under the Boost |
| 6 | Software License, Version 1.0. (See accompanying file |
| 7 | LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 8 | |
| 9 | =============================================================================*/ |
| 10 | |
| 11 | // Check generated line directives |
| 12 | // This test covers issue #24 |
| 13 | |
| 14 | // define one macro |
| 15 | #define FOO |
| 16 | |
| 17 | // try a variation matrix: |
| 18 | // 1. initial #if true vs. false |
| 19 | // 2. with/without else clause |
| 20 | // 3. additional text immediately after #endif vs. one line later |
| 21 | |
| 22 | #ifdef FOO |
| 23 | struct Bar {}; |
| 24 | #endif |
| 25 | struct Quux {}; |
| 26 | |
| 27 | // initial #if false |
| 28 | |
| 29 | #ifndef FOO |
| 30 | struct Bar {}; |
| 31 | #endif |
| 32 | struct Quux {}; |
| 33 | |
| 34 | // adding else clause |
| 35 | |
| 36 | #ifdef FOO |
| 37 | struct Bar {}; |
| 38 | #else |
| 39 | struct Baz {}; |
| 40 | #endif |
| 41 | struct Quux {}; |
| 42 | |
| 43 | #ifndef FOO |
| 44 | struct Bar {}; |
| 45 | #else |
| 46 | struct Baz {}; |
| 47 | #endif |
| 48 | struct Quux {}; |
| 49 | |
| 50 | // intermediate space before next line |
| 51 | |
| 52 | #ifdef FOO |
| 53 | struct Bar {}; |
| 54 | #endif |
| 55 | |
| 56 | struct Quux {}; |
| 57 | |
| 58 | #ifndef FOO |
| 59 | struct Bar {}; |
| 60 | #endif |
| 61 | |
| 62 | struct Quux {}; |
| 63 | |
| 64 | #ifdef FOO |
| 65 | struct Bar {}; |
| 66 | #else |
| 67 | struct Baz {}; |
| 68 | #endif |
| 69 | |
| 70 | struct Quux {}; |
| 71 | |
| 72 | #ifndef FOO |
| 73 | struct Bar {}; |
| 74 | #else |
| 75 | struct Baz {}; |
| 76 | #endif |
| 77 | |
| 78 | struct Quux {}; |
| 79 | |
| 80 | // varying the location of the "true" conditional block among 3 |
| 81 | |
| 82 | #ifdef FOO |
| 83 | // first block is present |
| 84 | struct Bar {}; |
| 85 | #elif defined(BAR) |
| 86 | struct Baz {}; |
| 87 | #else |
| 88 | struct Boozle {}; |
| 89 | #endif |
| 90 | |
| 91 | struct Quux {}; |
| 92 | |
| 93 | #ifndef FOO |
| 94 | struct Bar {}; |
| 95 | #elif !defined(BAR) |
| 96 | // second block is present |
| 97 | struct Baz {}; |
| 98 | #else |
| 99 | struct Boozle {}; |
| 100 | #endif |
| 101 | |
| 102 | struct Quux {}; |
| 103 | |
| 104 | #ifndef FOO |
| 105 | struct Bar {}; |
| 106 | #elif defined(BAR) |
| 107 | struct Baz {}; |
| 108 | #else |
| 109 | // third block is present |
| 110 | struct Boozle {}; |
| 111 | #endif |
| 112 | |
| 113 | struct Quux {}; |
| 114 | |
| 115 | // test two-part conditionals that have an elif instead of an else |
| 116 | #ifdef FOO |
| 117 | // first part true |
| 118 | struct Bar {}; |
| 119 | #elif defined(BAR) |
| 120 | struct Baz {}; |
| 121 | #endif |
| 122 | struct Quux {}; |
| 123 | |
| 124 | #ifndef FOO |
| 125 | struct Bar {}; |
| 126 | #elif !defined(BAR) |
| 127 | // second part true |
| 128 | struct Baz {}; |
| 129 | #endif |
| 130 | |
| 131 | struct Quux {}; |
| 132 | |
| 133 | // neither part true |
| 134 | #ifndef FOO |
| 135 | struct Bar {}; |
| 136 | #elif defined(BAR) |
| 137 | struct Baz {}; |
| 138 | #endif |
| 139 | struct Quux {}; |
| 140 | |
| 141 | // one more test: extra empty line before else clause |
| 142 | #ifndef FOO |
| 143 | struct Bar {}; |
| 144 | #else |
| 145 | |
| 146 | struct Baz {}; |
| 147 | #endif |
| 148 | struct Quux {}; |
| 149 | |
| 150 | |
| 151 | |
| 152 | //R #line 23 "t_5_039.cpp" |
| 153 | //R struct Bar {}; |
| 154 | //R |
| 155 | //R struct Quux {}; |
| 156 | //R #line 32 "t_5_039.cpp" |
| 157 | //R struct Quux {}; |
| 158 | //R #line 37 "t_5_039.cpp" |
| 159 | //R struct Bar {}; |
| 160 | //R #line 41 "t_5_039.cpp" |
| 161 | //R struct Quux {}; |
| 162 | //R #line 46 "t_5_039.cpp" |
| 163 | //R struct Baz {}; |
| 164 | //R |
| 165 | //R struct Quux {}; |
| 166 | //R #line 53 "t_5_039.cpp" |
| 167 | //R struct Bar {}; |
| 168 | //R #line 56 "t_5_039.cpp" |
| 169 | //R struct Quux {}; |
| 170 | //R #line 62 "t_5_039.cpp" |
| 171 | //R struct Quux {}; |
| 172 | //R #line 65 "t_5_039.cpp" |
| 173 | //R struct Bar {}; |
| 174 | //R #line 70 "t_5_039.cpp" |
| 175 | //R struct Quux {}; |
| 176 | //R #line 75 "t_5_039.cpp" |
| 177 | //R struct Baz {}; |
| 178 | //R #line 78 "t_5_039.cpp" |
| 179 | //R struct Quux {}; |
| 180 | //R #line 84 "t_5_039.cpp" |
| 181 | //R struct Bar {}; |
| 182 | //R #line 91 "t_5_039.cpp" |
| 183 | //R struct Quux {}; |
| 184 | //R #line 97 "t_5_039.cpp" |
| 185 | //R struct Baz {}; |
| 186 | //R #line 102 "t_5_039.cpp" |
| 187 | //R struct Quux {}; |
| 188 | //R #line 110 "t_5_039.cpp" |
| 189 | //R struct Boozle {}; |
| 190 | //R #line 113 "t_5_039.cpp" |
| 191 | //R struct Quux {}; |
| 192 | //R #line 118 "t_5_039.cpp" |
| 193 | //R struct Bar {}; |
| 194 | //R #line 122 "t_5_039.cpp" |
| 195 | //R struct Quux {}; |
| 196 | //R #line 128 "t_5_039.cpp" |
| 197 | //R struct Baz {}; |
| 198 | //R #line 131 "t_5_039.cpp" |
| 199 | //R struct Quux {}; |
| 200 | //R #line 139 "t_5_039.cpp" |
| 201 | //R struct Quux {}; |
| 202 | //R #line 146 "t_5_039.cpp" |
| 203 | //R struct Baz {}; |
| 204 | //R |
| 205 | //R struct Quux {}; |
| 206 | |