John Kessenich | 4d6570a | 2013-11-10 23:07:36 +0000 | [diff] [blame] | 1 | #version 400 |
John Kessenich | 38c507e | 2013-02-08 18:56:56 +0000 | [diff] [blame] | 2 | |
John Kessenich | 464f6d9 | 2013-02-06 00:14:16 +0000 | [diff] [blame] | 3 | #define ON |
| 4 | |
| 5 | float sum = 0.0; |
| 6 | |
| 7 | void main() |
| 8 | { |
| 9 | |
| 10 | #ifdef ON |
| 11 | //yes |
| 12 | sum += 1.0; |
| 13 | #endif |
| 14 | |
| 15 | #ifdef OFF |
| 16 | //no |
| 17 | sum += 20.0; |
| 18 | #endif |
| 19 | |
| 20 | #if defined(ON) |
| 21 | //yes |
| 22 | sum += 300.0; |
| 23 | #endif |
| 24 | |
| 25 | #if defined(OFF) |
| 26 | //no |
| 27 | sum += 4000.0; |
| 28 | #endif |
| 29 | |
| 30 | #if !defined(ON) |
| 31 | //no |
| 32 | sum += 50000.0; |
| 33 | #endif |
| 34 | |
John Kessenich | 52ac67e | 2013-05-05 23:46:22 +0000 | [diff] [blame] | 35 | #ifndef OFF |
John Kessenich | 464f6d9 | 2013-02-06 00:14:16 +0000 | [diff] [blame] | 36 | //yes |
| 37 | sum += 600000.0; |
| 38 | #else |
| 39 | //no |
| 40 | sum += 0.6; |
| 41 | #endif |
| 42 | |
| 43 | #if defined(ON) && defined(OFF) |
| 44 | //no |
| 45 | sum += 0.7; |
| 46 | #elif !defined(OFF) |
| 47 | //yes |
| 48 | sum += 7000000.0; |
| 49 | #endif |
| 50 | |
| 51 | #if defined(ON) && !defined(OFF) |
| 52 | //yes |
| 53 | sum += 80000000.0; |
| 54 | #endif |
| 55 | |
| 56 | #if defined(OFF) || defined(ON) |
| 57 | //yes |
| 58 | sum += 900000000.0; |
| 59 | #endif |
| 60 | |
John Kessenich | 52ac67e | 2013-05-05 23:46:22 +0000 | [diff] [blame] | 61 | #if NEVER_DEFINED |
| 62 | //no |
| 63 | sum += 0.04; |
| 64 | #else |
| 65 | sum += 0.05; |
| 66 | #endif |
| 67 | |
John Kessenich | 464f6d9 | 2013-02-06 00:14:16 +0000 | [diff] [blame] | 68 | // sum should be 987600301.7 |
| 69 | gl_Position = vec4(sum); |
| 70 | } |
John Kessenich | ceb0623 | 2013-06-03 04:15:57 +0000 | [diff] [blame] | 71 | |
| 72 | #define A 0 |
John Kessenich | 98434be | 2013-12-02 15:56:38 +0000 | [diff] [blame] | 73 | # define B 0 |
| 74 | # define C 0 |
John Kessenich | ceb0623 | 2013-06-03 04:15:57 +0000 | [diff] [blame] | 75 | |
| 76 | #if (A == B) || (A == C) |
| 77 | #error good1 |
| 78 | #endif |
| 79 | |
| 80 | #if A == B || (A == C) |
| 81 | #error good2 |
| 82 | #endif |
| 83 | |
| 84 | #if (A == B || (A == C)) |
| 85 | #error good3 |
| 86 | #endif |
| 87 | |
| 88 | #if (AA == BB) || (AA == CC) |
| 89 | #error good4 |
| 90 | #endif |
| 91 | |
| 92 | #if AA == BB || (AA == CC) |
| 93 | #error good5 |
| 94 | #endif |
| 95 | |
| 96 | #if ((AA == BB || (AA == CC))) |
| 97 | #error good6 |
| 98 | #endif |
| 99 | |
| 100 | #if (A == B || (A == C) |
| 101 | #error bad1 |
| 102 | #endif |
| 103 | |
| 104 | #if A == B || A == C) |
| 105 | #error bad2 |
| 106 | #endif |
| 107 | |
| 108 | #if (A == B || (A == C) |
| 109 | #error bad3 |
| 110 | #endif |
| 111 | |
| 112 | #if AA == BB) || (AA == CC) |
| 113 | #error bad4 |
| 114 | #endif |
| 115 | |
| 116 | #if AA == BB || (AA == CC |
| 117 | #error bad5 |
| 118 | #endif |
| 119 | |
| 120 | #if ((AA == BB || (AA == CC)))) |
| 121 | #error bad6 |
John Kessenich | 4d6570a | 2013-11-10 23:07:36 +0000 | [diff] [blame] | 122 | #endif extra tokens |
John Kessenich | fb7044a | 2013-06-13 20:16:43 +0000 | [diff] [blame] | 123 | |
John Kessenich | f78fff9 | 2013-06-13 23:56:04 +0000 | [diff] [blame] | 124 | int linenumber = __LINE__; |
| 125 | int filenumber = __FILE__; |
| 126 | int version = __VERSION__; |
| 127 | |
John Kessenich | 5f1a0b7 | 2013-07-06 19:54:21 +0000 | [diff] [blame] | 128 | #define PI (3.14) |
| 129 | #define TWOPI (2.0 * PI) |
| 130 | float twoPi = TWOPI; |
| 131 | |
John Kessenich | 4d6570a | 2013-11-10 23:07:36 +0000 | [diff] [blame] | 132 | //#define PASTE(a,b) a ## b |
| 133 | //float PASTE(tod, ay) = 17; |
| 134 | |
| 135 | "boo" // ERROR |
| 136 | int a = length("aoenatuh"); // ERROR |
John Kessenich | 7054075 | 2013-12-31 23:02:24 +0000 | [diff] [blame] | 137 | #define QUOTE "abcd" // okay |
John Kessenich | 4d6570a | 2013-11-10 23:07:36 +0000 | [diff] [blame] | 138 | 'int'; // ERROR |
John Kessenich | 7054075 | 2013-12-31 23:02:24 +0000 | [diff] [blame] | 139 | #define SINGLE 'a' // okay |
John Kessenich | 4d6570a | 2013-11-10 23:07:36 +0000 | [diff] [blame] | 140 | // ERROR: all the following are reserved |
| 141 | #define GL_ |
| 142 | #define GL_Macro 1 |
| 143 | #define __M |
| 144 | #define M__ |
| 145 | #define ABC__DE abc |
| 146 | |
| 147 | #if 4 |
| 148 | #else extra |
| 149 | #elif |
| 150 | // ERROR elif after else |
| 151 | #endif |
| 152 | |
| 153 | #if blah |
| 154 | #if 0 |
| 155 | #else extra |
| 156 | #ifdef M |
| 157 | #else |
| 158 | #else |
| 159 | // ERROR else after else |
| 160 | #endif extra |
| 161 | #endif |
| 162 | #endif |
| 163 | |
| 164 | #define m1(a,a) // ERROR |
| 165 | #define m2(a,b) |
| 166 | |
| 167 | // okay |
| 168 | #define m3 (a) |
| 169 | #define m3 (a) |
| 170 | |
| 171 | // ERROR |
| 172 | #define m4(b) |
| 173 | #define m4 (b) |
| 174 | |
| 175 | // ERROR |
| 176 | #define m5 (b) |
| 177 | #define m5(b) |
| 178 | |
| 179 | // ERROR |
| 180 | #define m6(a) |
| 181 | #define m6 |
| 182 | |
| 183 | // ERROR (whitespace) |
| 184 | #define m7 (a) |
| 185 | #define m7 ( a) |
| 186 | |
| 187 | #define m80(a,b) is + exactly m3 the same |
| 188 | #define m80(a,b) is + exactly m3 the same |
| 189 | |
| 190 | // ERROR |
| 191 | #define m8(a,b) almost + exactly m3 the same |
| 192 | #define m8(a,b) almost + exactly m3 thee same |
| 193 | |
| 194 | // ERROR |
| 195 | #define m9(a,b,c) aoe |
| 196 | #define m9(a,d,c) aoe |
| 197 | |
| 198 | #define n1 0xf |
| 199 | int n = n1; |
| 200 | |
| 201 | #define f1 .08e-2Lf |
| 202 | double f = f1; |
| 203 | |
John Kessenich | 69aa9c1 | 2013-11-12 03:31:24 +0000 | [diff] [blame] | 204 | #undef __VERSION__ |
| 205 | #undef GL_ARB_texture_rectangle |
| 206 | |
John Kessenich | 98434be | 2013-12-02 15:56:38 +0000 | [diff] [blame] | 207 | # |
| 208 | # |
| 209 | # |
| 210 | ## |
| 211 | # # |
| 212 | # 0x25 |
| 213 | #### |
| 214 | ####ff |
| 215 | #########ff fg 0x25 |
| 216 | #pragma |
| 217 | #pragma(aoent) |
| 218 | # pragma |
| 219 | #pragma STDGL |
| 220 | #pragma optimize( on) |
| 221 | #pragma optimize(off) |
| 222 | #pragma debug( on) |
| 223 | #pragma debug(off ) |
| 224 | #pragma optimize( on) anoteun |
| 225 | #pragma optimize(off |
| 226 | #pragma debug( on) ( |
| 227 | #pragma debug(off aoeua) |
| 228 | #pragma optimize( on) |
| 229 | #pragma optimize(off,) |
| 230 | #pragma debug( on, aoeu) |
| 231 | #pragma debugoff ) |
| 232 | #pragma aontheu natoeh uantheo uasotea noeahuonea uonethau onethuanoeth aunotehau noeth anthoeua anoethuantoeh uantoehu natoehu naoteh unotaehu noethua onetuh aou |
| 233 | # \ |
| 234 | |
| 235 | # \ |
| 236 | error good continuation |
| 237 | |
| 238 | #flizbit |
| 239 | |
| 240 | #define directive error |
| 241 | |
| 242 | #directive directive was expanded |
| 243 | |
John Kessenich | 1abc404 | 2013-12-03 17:19:03 +0000 | [diff] [blame] | 244 | #line 12000 |
John Kessenich | 2b20dcb | 2014-12-20 07:03:18 +0000 | [diff] [blame] | 245 | #error line should be 12000 |
John Kessenich | 1abc404 | 2013-12-03 17:19:03 +0000 | [diff] [blame] | 246 | #line 13000 7 |
John Kessenich | 2b20dcb | 2014-12-20 07:03:18 +0000 | [diff] [blame] | 247 | #error line should be 13000, string 7 |
John Kessenich | 1abc404 | 2013-12-03 17:19:03 +0000 | [diff] [blame] | 248 | #define L1 14000 |
| 249 | #define L2 13 |
| 250 | #define F1 5 |
| 251 | #define F2 7 |
| 252 | #line L1 + L2 |
John Kessenich | 2b20dcb | 2014-12-20 07:03:18 +0000 | [diff] [blame] | 253 | #error line should be 14013, string 7 |
John Kessenich | 2d2f316 | 2013-12-10 00:25:14 +0000 | [diff] [blame] | 254 | #line L1 + L2 F1 + F2 // antoeuh sat comment |
John Kessenich | 2b20dcb | 2014-12-20 07:03:18 +0000 | [diff] [blame] | 255 | #error line should be 14013, string 12 |
John Kessenich | 1abc404 | 2013-12-03 17:19:03 +0000 | [diff] [blame] | 256 | #line L1 + L2 + F1 + F2 |
John Kessenich | 2b20dcb | 2014-12-20 07:03:18 +0000 | [diff] [blame] | 257 | #error line should be 14025, string 12 |
John Kessenich | 1abc404 | 2013-12-03 17:19:03 +0000 | [diff] [blame] | 258 | #line 1234 F1 + F2 extra |
John Kessenich | 2d2f316 | 2013-12-10 00:25:14 +0000 | [diff] [blame] | 259 | #define empty_extra |
| 260 | #line 1235 F1 + F2 empty_extra |
| 261 | #define moreEmpty empty_extra |
| 262 | #line 1236 F1 + F2 moreEmpty empty_extra // okay, lots of nothin |
| 263 | #line 1237 F1 + F2 moreEmpty empty_extra extra // ERROR, 'extra' |
| 264 | #line 1238 F1 + F2 moreEmpty empty_extra |
| 265 | #line 1239 empty_extra F1 empty_extra + empty_extra F2 empty_extra moreEmpty empty_extra |
John Kessenich | 1abc404 | 2013-12-03 17:19:03 +0000 | [diff] [blame] | 266 | #line (20000) |
John Kessenich | 2b20dcb | 2014-12-20 07:03:18 +0000 | [diff] [blame] | 267 | #error line should be 20000 |
John Kessenich | 1abc404 | 2013-12-03 17:19:03 +0000 | [diff] [blame] | 268 | #line (20000+10) |
John Kessenich | 2b20dcb | 2014-12-20 07:03:18 +0000 | [diff] [blame] | 269 | #error line should be 20010 |
John Kessenich | 1abc404 | 2013-12-03 17:19:03 +0000 | [diff] [blame] | 270 | #line +20020 |
John Kessenich | 2b20dcb | 2014-12-20 07:03:18 +0000 | [diff] [blame] | 271 | #error line should be 20020 |
John Kessenich | 1abc404 | 2013-12-03 17:19:03 +0000 | [diff] [blame] | 272 | |
John Kessenich | e28beee | 2013-12-06 16:13:47 +0000 | [diff] [blame] | 273 | #define VAL1 1.0 |
| 274 | #define VAL2 2.0 |
| 275 | |
| 276 | #define RES2 /* test a multiline |
| 277 | comment in a macro definition */ (RES1 * VAL2) |
| 278 | #define RES1 (VAL2 / VAL1) |
| 279 | #define RES2 /* comment */(RES1 * VAL2) |
| 280 | #define /* */SUM_VALUES (RES2 + RES1) |
| 281 | |
| 282 | void foo234() |
| 283 | { |
| 284 | gl_Position = vec4(SUM_VALUES); |
| 285 | } |
| 286 | |
| 287 | // more whitespace recording tests |
| 288 | #define SPACE_AT_END(a,b) spaceAtEndIsOkay |
| 289 | #define SPACE_AT_END(a,b) spaceAtEndIsOkay // space at end |
| 290 | |
| 291 | #define SPACE_AT_BEGIN(a,b)spaceAtBeginIsOkay |
| 292 | #define SPACE_AT_BEGIN(a,b) spaceAtBeginIsOkay |
| 293 | |
| 294 | // space in middle is an error |
| 295 | #define SPACE_IN_MIDDLE(a,b) space +in middle |
| 296 | #define SPACE_IN_MIDDLE(a,b) space + in middle |
| 297 | |
John Kessenich | 2d2f316 | 2013-12-10 00:25:14 +0000 | [diff] [blame] | 298 | #define FIRSTPART 17 |
| 299 | #define SECONDPART + 5 |
| 300 | |
| 301 | #if FIRSTPART SECONDPART == 22 |
| 302 | #error good evaluation 1 |
| 303 | #endif |
| 304 | |
| 305 | #if moreEmpty FIRSTPART moreEmpty SECONDPART moreEmpty == moreEmpty 22 moreEmpty |
| 306 | #error good evaluation 2 |
| 307 | #endif |
| 308 | |
John Kessenich | fcb4ed0 | 2013-12-30 20:34:28 +0000 | [diff] [blame] | 309 | // ERRORS... |
| 310 | #line 9000 |
| 311 | #if defined(OUNH |
| 312 | #endif |
| 313 | #if defined OUNH) |
| 314 | #endif |
| 315 | |
| 316 | // recursion (okay) |
| 317 | #define RECURSE RECURSE |
| 318 | int RECURSE; |
| 319 | #define R2 R1 |
| 320 | #define R1 R2 |
| 321 | #undef RECURSE |
| 322 | int R1 = RECURSE; |
| 323 | |
| 324 | #define FOOOM(a,b) a + b |
| 325 | int aoeua = FOOOM; |
| 326 | #if FOOOM |
| 327 | #endif |
| 328 | |
John Kessenich | aead93a | 2015-07-25 17:34:32 -0600 | [diff] [blame] | 329 | #line 9500 |
| 330 | #if\376 |
| 331 | #endif |
| 332 | #if \376 |
| 333 | #endif |
| 334 | #if \377 |
| 335 | #endif |
| 336 | #error\377 |
| 337 | #error \ 376 |
| 338 | #error \377 |
| 339 | |
John Kessenich | 2eb1355 | 2017-06-07 17:15:38 -0600 | [diff] [blame] | 340 | // ERROR for macro expansion to yield 'defined' |
| 341 | #line 9600 |
| 342 | #define DEF_MAC |
| 343 | #define DEF_DEFINED defined |
| 344 | #if DEF_DEFINED DEF_MAC |
| 345 | #error DEF_DEFINED then |
| 346 | #else |
| 347 | #error DEF_DEFINED else |
| 348 | #endif |
| 349 | |
John Kessenich | 1abc404 | 2013-12-03 17:19:03 +0000 | [diff] [blame] | 350 | #line 10000 |
John Kessenich | 4d6570a | 2013-11-10 23:07:36 +0000 | [diff] [blame] | 351 | #if 1 |
| 352 | #else |
| 353 | // ERROR, missing #endif |