1#version 400
2
3#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
35#ifndef OFF
36//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
61#if NEVER_DEFINED
62//no
63sum += 0.04;
64#else
65sum += 0.05;
66#endif
67
68// sum should be 987600301.7
69    gl_Position = vec4(sum);
70}
71
72#define A 0
73# define B 0
74 #   define C 0
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
122#endif extra tokens
123
124int linenumber = __LINE__;
125int filenumber = __FILE__;
126int version = __VERSION__;
127
128#define PI (3.14)
129#define TWOPI (2.0 * PI)
130float twoPi = TWOPI;
131
132//#define PASTE(a,b) a ## b
133//float PASTE(tod, ay) = 17;
134
135"boo" // ERROR
136int a = length("aoenatuh");  // ERROR
137#define QUOTE "abcd"  // okay
138'int';  // ERROR
139#define SINGLE 'a'   // okay
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
174
175// ERROR
176#define m5 (b)
177#define m5(b)
178
179// ERROR
180#define m6(a)
181#define m6(a,b)
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
204#undef __VERSION__
205#undef GL_ARB_texture_rectangle
206
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
244#line 12000
245#error line should be 12000
246#line 13000 7
247#error line should be 13000, string 7
248#define L1 14000
249#define L2 13
250#define F1 5
251#define F2 7
252#line L1 + L2
253#error line should be 14013, string 7
254#line L1 + L2 F1 + F2 //  antoeuh sat  comment
255#error line should be 14013, string 12
256#line L1 + L2 + F1 + F2
257#error line should be 14025, string 12
258#line 1234 F1 + F2 extra
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
266#line (20000)
267#error line should be 20000
268#line (20000+10)
269#error line should be 20010
270#line +20020
271#error line should be 20020
272
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
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
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
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
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
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
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
350#line 10000
351#if 1
352#else
353// ERROR, missing #endif