2002-07-14-MiscTests3.c
3.18 KB
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
// RUN: %clang_cc1 -w -emit-llvm %s -o /dev/null
void *malloc(unsigned);
int puts(const char *s);
struct FunStructTest {
int Test1;
char *Pointer;
int Array[12];
};
struct SubStruct {
short X, Y;
};
struct Quad {
int w;
struct SubStruct SS;
struct SubStruct *SSP;
char c;
int y;
};
struct Quad GlobalQuad = { 4, {1, 2}, 0, 3, 156 };
typedef int (*FuncPtr)(int);
unsigned PtrFunc(int (*Func)(int), int X) {
return Func(X);
}
char PtrFunc2(FuncPtr FuncTab[30], int Num) {
return FuncTab[Num]('b');
}
extern char SmallArgs2(char w, char x, long long Zrrk, char y, char z);
extern int SomeFunc(void);
char SmallArgs(char w, char x, char y, char z) {
SomeFunc();
return SmallArgs2(w-1, x+1, y, z, w);
}
static int F0(struct Quad Q, int i) { /* Pass Q by value */
struct Quad R;
if (i) R.SS = Q.SS;
Q.SSP = &R.SS;
Q.w = Q.y = Q.c = 1;
return Q.SS.Y + i + R.y - Q.c;
}
int F1(struct Quad *Q, int i) { /* Pass Q by address */
struct Quad R;
#if 0
if (i) R.SS = Q->SS;
#else
if (i) R = *Q;
#endif
Q->w = Q->y = Q->c = 1;
return Q->SS.Y+i+R.y-Q->c;
}
int BadFunc(float Val) {
int Result;
if (Val > 12.345) Result = 4;
return Result; /* Test use of undefined value */
}
int RealFunc(void) {
return SomeUndefinedFunction(1, 4, 5);
}
extern int EF1(int *, char *, int *);
int Func(int Param, long long Param2) {
int Result = Param;
{{{{
char c; int X;
EF1(&Result, &c, &X);
}}}
{ // c & X are duplicate names!
char c; int X;
EF1(&Result, &c, &X);
}
}
return Result;
}
short FunFunc(long long x, char z) {
return x+z;
}
unsigned castTest(int X) { return X; }
double TestAdd(double X, float Y) {
return X+Y+.5;
}
int func(int i, int j) {
while (i != 20)
i += 2;
j += func(2, i);
return (i * 3 + j*2)*j;
}
int SumArray(int Array[], int Num) {
int i, Result = 0;
for (i = 0; i < Num; ++i)
Result += Array[i];
return Result;
}
int ArrayParam(int Values[100]) {
return EF1((int*)Values[50], (char*)1, &Values[50]);
}
int ArrayToSum(void) {
int A[100], i;
for (i = 0; i < 100; ++i)
A[i] = i*4;
return A[A[0]]; //SumArray(A, 100);
}
int ExternFunc(long long, unsigned*, short, unsigned char);
int main(int argc, char *argv[]) {
unsigned i;
puts("Hello world!\n");
ExternFunc(-1, 0, (short)argc, 2);
//func(argc, argc);
for (i = 0; i < 10; i++)
puts(argv[3]);
return 0;
}
double MathFunc(double X, double Y, double Z,
double AA, double BB, double CC, double DD,
double EE, double FF, double GG, double HH,
double aAA, double aBB, double aCC, double aDD,
double aEE, double aFF) {
return X + Y + Z + AA + BB + CC + DD + EE + FF + GG + HH
+ aAA + aBB + aCC + aDD + aEE + aFF;
}
void strcpy(char *s1, char *s2) {
while (*s1++ = *s2++);
}
void strcat(char *s1, char *s2) {
while (*s1++);
s1--;
while (*s1++ = *s2++);
}
int strcmp(char *s1, char *s2) {
while (*s1++ == *s2++);
if (*s1 == 0) {
if (*s2 == 0) {
return 0;
} else {
return -1;
}
} else {
if (*s2 == 0) {
return 1;
} else {
return (*(--s1) - *(--s2));
}
}
}