blob: 198203a69d7a9f42c0ed0ce54e1a2b88cadca0dc [file] [log] [blame]
John Kessenich4d6570a2013-11-10 23:07:36 +00001#version 400
John Kessenich38c507e2013-02-08 18:56:56 +00002
John Kessenich464f6d92013-02-06 00:14:16 +00003#define ON
4
5float sum = 0.0;
6
7void main()
8{
9
10#ifdef ON
11//yes
12sum += 1.0;
13#endif
14
15#ifdef OFF
16//no
17sum += 20.0;
18#endif
19
20#if defined(ON)
21//yes
22sum += 300.0;
23#endif
24
25#if defined(OFF)
26//no
27sum += 4000.0;
28#endif
29
30#if !defined(ON)
31//no
32sum += 50000.0;
33#endif
34
John Kessenich52ac67e2013-05-05 23:46:22 +000035#ifndef OFF
John Kessenich464f6d92013-02-06 00:14:16 +000036//yes
37sum += 600000.0;
38#else
39//no
40sum += 0.6;
41#endif
42
43#if defined(ON) && defined(OFF)
44//no
45sum += 0.7;
46#elif !defined(OFF)
47//yes
48sum += 7000000.0;
49#endif
50
51#if defined(ON) && !defined(OFF)
52//yes
53sum += 80000000.0;
54#endif
55
56#if defined(OFF) || defined(ON)
57//yes
58sum += 900000000.0;
59#endif
60
John Kessenich52ac67e2013-05-05 23:46:22 +000061#if NEVER_DEFINED
62//no
63sum += 0.04;
64#else
65sum += 0.05;
66#endif
67
John Kessenich464f6d92013-02-06 00:14:16 +000068// sum should be 987600301.7
69 gl_Position = vec4(sum);
70}
John Kessenichceb06232013-06-03 04:15:57 +000071
72#define A 0
John Kessenich98434be2013-12-02 15:56:38 +000073# define B 0
74 # define C 0
John Kessenichceb06232013-06-03 04:15:57 +000075
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 Kessenich4d6570a2013-11-10 23:07:36 +0000122#endif extra tokens
John Kessenichfb7044a2013-06-13 20:16:43 +0000123
John Kessenichf78fff92013-06-13 23:56:04 +0000124int linenumber = __LINE__;
125int filenumber = __FILE__;
126int version = __VERSION__;
127
John Kessenich5f1a0b72013-07-06 19:54:21 +0000128#define PI (3.14)
129#define TWOPI (2.0 * PI)
130float twoPi = TWOPI;
131
John Kessenich4d6570a2013-11-10 23:07:36 +0000132//#define PASTE(a,b) a ## b
133//float PASTE(tod, ay) = 17;
134
135"boo" // ERROR
136int a = length("aoenatuh"); // ERROR
John Kessenich70540752013-12-31 23:02:24 +0000137#define QUOTE "abcd" // okay
John Kessenich4d6570a2013-11-10 23:07:36 +0000138'int'; // ERROR
John Kessenich70540752013-12-31 23:02:24 +0000139#define SINGLE 'a' // okay
John Kessenich4d6570a2013-11-10 23:07:36 +0000140// 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
199int n = n1;
200
201#define f1 .08e-2Lf
202double f = f1;
203
John Kessenich69aa9c12013-11-12 03:31:24 +0000204#undef __VERSION__
205#undef GL_ARB_texture_rectangle
206
John Kessenich98434be2013-12-02 15:56:38 +0000207#
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 Kessenich1abc4042013-12-03 17:19:03 +0000244#line 12000
John Kessenich2b20dcb2014-12-20 07:03:18 +0000245#error line should be 12000
John Kessenich1abc4042013-12-03 17:19:03 +0000246#line 13000 7
John Kessenich2b20dcb2014-12-20 07:03:18 +0000247#error line should be 13000, string 7
John Kessenich1abc4042013-12-03 17:19:03 +0000248#define L1 14000
249#define L2 13
250#define F1 5
251#define F2 7
252#line L1 + L2
John Kessenich2b20dcb2014-12-20 07:03:18 +0000253#error line should be 14013, string 7
John Kessenich2d2f3162013-12-10 00:25:14 +0000254#line L1 + L2 F1 + F2 // antoeuh sat comment
John Kessenich2b20dcb2014-12-20 07:03:18 +0000255#error line should be 14013, string 12
John Kessenich1abc4042013-12-03 17:19:03 +0000256#line L1 + L2 + F1 + F2
John Kessenich2b20dcb2014-12-20 07:03:18 +0000257#error line should be 14025, string 12
John Kessenich1abc4042013-12-03 17:19:03 +0000258#line 1234 F1 + F2 extra
John Kessenich2d2f3162013-12-10 00:25:14 +0000259#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 Kessenich1abc4042013-12-03 17:19:03 +0000266#line (20000)
John Kessenich2b20dcb2014-12-20 07:03:18 +0000267#error line should be 20000
John Kessenich1abc4042013-12-03 17:19:03 +0000268#line (20000+10)
John Kessenich2b20dcb2014-12-20 07:03:18 +0000269#error line should be 20010
John Kessenich1abc4042013-12-03 17:19:03 +0000270#line +20020
John Kessenich2b20dcb2014-12-20 07:03:18 +0000271#error line should be 20020
John Kessenich1abc4042013-12-03 17:19:03 +0000272
John Kesseniche28beee2013-12-06 16:13:47 +0000273#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
282void 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 Kessenich2d2f3162013-12-10 00:25:14 +0000298#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 Kessenichfcb4ed02013-12-30 20:34:28 +0000309// ERRORS...
310#line 9000
311#if defined(OUNH
312#endif
313#if defined OUNH)
314#endif
315
316// recursion (okay)
317#define RECURSE RECURSE
318int RECURSE;
319#define R2 R1
320#define R1 R2
321#undef RECURSE
322int R1 = RECURSE;
323
324#define FOOOM(a,b) a + b
325int aoeua = FOOOM;
326#if FOOOM
327#endif
328
John Kessenichaead93a2015-07-25 17:34:32 -0600329#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 Kessenich1abc4042013-12-03 17:19:03 +0000340#line 10000
John Kessenich4d6570a2013-11-10 23:07:36 +0000341#if 1
342#else
343// ERROR, missing #endif