aboutsummaryrefslogtreecommitdiffstats
path: root/code/tools/lcc/tst/front.c
blob: 13125cfa6172672879de7731c0fb4bb41f82cab6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
main() {
	exit(0);
}

nested(a,b) {
	if ((a<4 && b == 'r')
		|| (a == 1 && (b == 'h' || b == 'i'))
		|| (a == 2 && (b == 'o' || b == 'y'))
	) a=b;
}

/* type name scope */

void s(struct D *d) {}	/* this struct D differs from the one below */
typedef struct D D;
struct D {int x, y;} Dy={0};
D Dz={1};
Dfunc(){
	D a; a.y=1;
	s(&Dy);		/* error */
}

/* qualifiers */

const a; int b;
const int a, *x; int b, *y;
volatile unsigned z;

f() {
	x = y;
	z = z + z;	/* should be 2 references to z's r-value */
}
f1() {
	x = &a;
	x = &b;
	y = &a;		/* error */
	y = &b;
}
f2(int **a, int **b) {
	f(&x, &y);
	**a = 0;
	return **b;
}
g(const int *p) {
	g(&a);
	g(&b);
	return *p;
}
h(int *p) {
	f(&a);
	f(&b);
	return *p;
}
h1(const int x, int y) {
	h1(a,b);
	h1(b,a);
	return x + y;
}
h2() {
	char *b; const void *p;
	p = b;
	b = p;		/* error */
}


/* static naming */

extern int yy; set1() { { static yy=1; yy=2;} yy=4;}
static int yy; set2() { yy=5; {static yy=2; yy=3; }}
static void goo() {}
sss() { int goo; { static int goo();} goo=1;}
rrr(p) float *p; { extern int xr;
 { static float xr;
 { extern int *xr; } p=&xr; }}

/* local extern */

static int ss1;
int ss3;
extern int ss5;
setstatic() { extern int ss1,ss2,ss3,ss4; ss1 = ss2; ss3 = ss4; ss5 = 0;}
static int ss2;
int ss4;
static int ss5;

/* function prototypes */

int fx1(void);
int fx1();

int gx1(double x);
int gx1(x) double x; { gx1(&x); }	/* error */

int hx1();
int hx1(double x,...);	/* error */

int ff1(double x, int *y);
int ff1(x,y) float x; int y[]; {x=y[0];}

int gg1(int a);
int gg1(a,b){a=b;}

int hh1(const int x);
hh1(a) {return a;}

extern int strcmp(const char*, const char*);
extern void qsort(void*, int, int, int (*)(const void*, const void*));
extern int cmp(char**a, char**b) { return strcmp(*a,*b); }
sort() {
	int n; char *a[100];
	qsort(a, n, sizeof(char*), (int (*)(const void*, const void*))cmp);
	qsort(a, n, sizeof(char*), cmp);	/* error */
}

/* nasty calls */

onearg(){
	int a,b,c,d;
	f( ( (a? (b = 1): (c = 2)), (d ? 3 : 4) ) );	/* 1 argument */
}