1 /*
2  * Define:
3  *	ERR_YACC	to force yacc error reporting
4  *	ERR_LEX		to force lex error reporting
5  *	ERR_CHECK	to force compiler error reporting
6  */
7 		/* use one item from type-specifiers */
8 #ifdef	ERR_YACC
9 auto		x;
10 register	x1;
11 #endif	/* ERR_YACC */
12 static		x2;
13 extern		x3;
14 #ifdef	ERR_CC
15 typedef		x4;
16 #endif
17 typedef	int	x4t;
18 #ifdef	ERR_YACC
19 void		x5;
20 #endif	/* ERR_YACC */
21 char		x6;
22 short		x7;
23 int		x8;
24 long		x9;
25 float		x10;
26 double		x11;
27 signed		x12;
28 unsigned	x13;
29 struct		x14;
30 #ifdef	ERR_CHECK
31 struct		x14a {};
32 struct		{};
33 #endif	/* ERR_CHECK */
34 union		x15;
35 enum		x16;
36 x4t;
37 x4t		x17;
38 const		x18;
39 volatile	x19;
40 #ifdef	ERR_CHECK
41 junk		x20;
42 #endif	/* ERR_CHECK */
43 
44 extern int *asm (fopen, (__const char *__restrict __filename, __const char *__restrict __modes), fopen64);
45 extern int __asm__ (mkstemp, (char *__template), mkstemp64);
46 int __asm__ (mkstemp, (char *__template), mkstemp64);
47 asm("something");
48 asm("something", "else");
49 asm("something", (this and that));
50 int asm(first, "something");
51 static int asm(first, "something");
52 extern int asm(first, "something");
53 
54 typedef	struct	_first	{
55 	int		a:5;
56 	struct	{
57 		int	a,b;
58 	} b_struct;
59 	char		b:16, b1:1;	/* comment with };};}; */
60 	long		c:16, c1;
61 	short		d:16, d1:8, d2;
62 	unsigned	e:16;
63 	float		f;
64 	double		g;
65 #ifdef	ERR_CHECK
66 	long	float	f2;
67 	long	double	g2;
68 #endif	/* ERR_CHECK */
69 	struct	_first	*link;
70 	}	_FIRST;
71 
72 typedef int badStyle;
badFunc(int * badStyle)73 void badFunc(int *badStyle) { }
74 
75 _FIRST	first, last={0}, first_last[] = {{0},{1},{2},{3,{4}}};
76 
77 struct	_second	{
78 		enum	{true, false} bool;
79 		enum	{wrong=1, right=3} values;
80 	} _SECOND;
81 
82 int	i[] = {1,
83 		'\002',
84 		03,
85 		0x4,
86 		0X5,
87 		0x6a,
88 		0X7b,
89 		0x8aBcD,
90 		9l,
91 		10l,
92 		11L};
93 float	f[] = {5,
94 #ifdef	ERR_CHECK
95 		.5e,
96 		.5e+,
97 		5e-,
98 		5e,
99 		.34P1,
100 		0x1.2.34,	/* error */
101 #endif
102 		.5,
103 		5.5,
104 		5e5,
105 		5e0,
106 		5e-1,
107 		5e+5
108 #ifdef	__STDC_VERSION__ /* ( C9X supports hexadecimal floating point ;-) */
109 		0x12.34+1,
110 		0x12.34P1,
111 		.34e1,
112 		0.34e1,
113 		0x.34P1,
114 #endif
115 		.0e-1
116 		};
117 
118 int	array[][10][20];
119 
120 	/*
121 	 * This grammar can accept some illegal stuff too, in particular it will
122 	 * permit some instances of parameter-names to be dropped.
123 	 */
124 #ifdef	ERR_CHECK
125 #define	P1
126 #define	P2
127 #define	P3
128 #else
129 #define	P1	p1
130 #define	P2	p2
131 #define	P3	p3
132 #endif
133 
134 	/* ellipsis is legal, except in K&R style declaration */
135 
dots_0(p1)136 	dots_0(p1)		{ return(1); }
137 
dots_1(int p1,...)138 	dots_1(int p1, ...)	{ return(1); }
139 
140 #ifdef	ERR_CHECK
dots_2(p1,...)141 	dots_2(p1, ...)		{ return(1); }
142 #endif	/* ERR_CHECK */
143 
dots_3(int P1,char P2,...)144 	dots_3(int P1,char P2, ...)	{ return(1); }
145 
146 int	dots_4(int,char, char *);
147 char *	dots_5(int,char, char *, ...);
148 char *	(dots_6)(int,char, char *, ...);
149 
150 extern	_FIRST *xdots_0(p1);
151 
152 extern	char *xdots_1(int p1, ...);
153 
154 #ifdef	ERR_CHECK
155 extern	xdots_2(p1, ...);
156 #endif	/* ERR_CHECK */
157 
158 extern	xdots_3(int P1,char P2, ...);
159 
func1()160 _FIRST	*func1() { }
func2(_FIRST * P1,int P2[],float p)161 _FIRST	*func2(_FIRST *P1,int P2[],float p) { }
162 
163 int	*(func_func)(
164 #ifdef	ERR_CHECK
165 p1,p2,p3
166 #endif	/* ERR_CHECK */
167 )	{ return(0); }
168 
169 extern	float	efunc0(p1,p2,p3);
170 extern	_FIRST	efunc1(int p1, float p2,long P3);
171 #ifdef	ERR_CHECK
172 extern	_FIRST	efunc1(int p1, float p2,p3);
173 #endif	/* ERR_CHECK */
174 
175 
176 typedef	int	bool;
177 
178 bool	a1;
179 static	bool	a2;
180 extern	bool	a3;
181 
182 struct	ZIP1	{ int x1, y1; };
183 struct	zip2	{ int x2, y2; } z2;
184 struct		{ int x3, y3; } z3;	/* not ANSI, but mostly accepted */
185 
186 static	struct	ZIP4	{ int x4, y4; };
187 static	struct	zip5	{ int x5, y5; } z5;
188 static	struct	zip6	{ int x6, y6; } z6, w6;
189 static	struct		{ int x7, y7; } z7;
190 static	struct		{ int x8, y8; } z8, w8;
191 
192 enum	zap1	{ a,b,c,d }	what;
193 enum	zap2			what2;
194 enum		{a9,b9,c9,d9}	what3;
195 
196 static	char	*zap = "alphabet/\
197 first/\
198 last";
199 typedef	struct	bong	{
200 	int	(*func)();
201 	} BONG;
202 
203 typedef	char	*string;
204 
205 #ifdef	ERR_LEX
206 string	s = "aaa\0000\
207 
208 bbb";
209 #endif	/* ERR_LEX */
210 
211 extern	int	junk;
212 
main(argc,argv)213 main(argc, argv)
214 register argc;
215 #ifdef	ERR_CHECK
216 extern
217 #endif	/* ERR_CHECK */
218 char	**argv;
219 {
220 }
221 
222 /*VARARGS*/
223 /* some other comment */
veryfunny(a,b,c)224 veryfunny(a,b,c)
225 char *a;
226 long b, c;
227 {
228 	return 0;
229 }
230 
231 /*VARARGS3*/
program(argv,y,zz,z1,z2,z3)232 program(argv, y, zz, z1, z2, z3)
233 string	argv[];	/* first argument */
234 struct	alpha { int x,z; } y;	/* second argument */
235 {
236 	return(0);
237 }
238 
junk0()239 junk0() { if(junk != 6) return; else junk++; }
junk1()240 junk1() { return (0); }
junk2()241 junk2() { }
junk3()242 junk3() { return 1; }
243 
junk4()244 BONG	*junk4() { }
245 
246 typedef	int	extern_junk;
foo()247 extern_junk	*foo() { }
248 
249 typedef	int	void_junk;
foo2a()250 extern void_junk	*foo2a() { }
251 extern void_junk	*foo2a();
foo2()252 void_junk	*foo2() { }
foo_void(void_junk void_int)253 void_junk	*foo_void(void_junk void_int) { }
foo_void2()254 static	void_junk	*foo_void2() { }
255 
256 extern void (*sigdisp(int sig, void (*func)(int sig)))(int sig);
257 
Sigdisp(int sig,void (* func)(int sig))258 void (*Sigdisp(int sig, void (*func)(int sig)))(int sig1)
259 { /* nothing */ }
260 
261 void (*sigdisp2(sig, func))(int sig2)
262 	int sig;		/* the signal value */
263 	void (*func)(int sig);	/* the function pointer */
264 { /* nothing again! */ }
265 
266 int (*K_R_INT_ptr(p1, p2))() long *p1; int p2; { return (*(int(*)())0); }
267 
268 int (*STD_INT_ptr(long* , int))();
269 
270 void (*K_R_VOID_ptr(p1,p2))() long *p1; int p2; { return (*(void(*)())0); }
271 
272 void (*STD_VOID_ptr(long* , int))();
273 
K_R_int_ptr(p1,p2)274 int *K_R_int_ptr(p1,p2) long *p1; int p2; { return (*(int **)0); }
275 
276 int **STD_int2_ptr(long* , int);
277 
278 int *STD_int_ptr(long* , int);
279 
K_R_void_ptr(p1,p2)280 void *K_R_void_ptr(p1,p2) long *p1; int p2; { return (*(void **)0); }
281 
282 void *STD_void_ptr(long* , int);
283 
K_R_int_val(p1,p2)284 int K_R_int_val(p1,p2) long *p1; int p2; { return (*(int *)0); }
285 
K_R_int_val2(p1,p2)286 K_R_int_val2(p1,p2) long *p1; int p2; { return (*(int *)0); }
287 
288 int STD_int_val(long*, int);
289 
K_R_void_val(p1,p2)290 void K_R_void_val(p1,p2) long *p1; int p2; { /*void*/ }
291 
K_R_void_val2(p1,p2)292 K_R_void_val2(p1,p2) long *p1; int p2; { /*void*/ }
293 
294 void STD_void_val(long* , int);
295 
296 extern	xdots_3(int P1,char P2, ...);
297 
298 extern int (*XSetAfterFunction(long* , int (*) ( long*)))();
299 extern XQueryKeymap(long*, char [32]);
300 extern Another(long*, int (*)());
301 
302 extern GenFunc(int *, int *());
303 
304 /* these are pointers, not actual functions */
305 extern void * (*__glob_opendir_hook) (const char *__directory);
306 extern const char *(*__glob_readdir_hook) (void * __stream);
307 extern void (*__glob_closedir_hook) (void * __stream);
308 
309 /* inline function */
inline_func(double x)310 int inline inline_func(double x) { return(0); }
local_inline_func(double x)311 static int inline local_inline_func(double x) { return(0); }
312 
313 /* c99 types */
314 long long xxx = 1;
315 char *xxs = "\x1234\?\u1234";
316