1 // RUN: %llvmgcc -w -S %s -o - | llvm-as -o /dev/null
2
3
4
5 void *malloc(unsigned);
6
7 //#include <stdio.h>
8 int puts(const char *s);
9
10 struct FunStructTest {
11 int Test1;
12 char *Pointer;
13 int Array[12];
14 };
15
16 struct SubStruct {
17 short X, Y;
18 };
19
20 struct Quad {
21 int w;
22 struct SubStruct SS;
23 struct SubStruct *SSP;
24 char c;
25 int y;
26 };
27
28 struct Quad GlobalQuad = { 4, {1, 2}, 0, 3, 156 };
29
30 typedef int (*FuncPtr)(int);
31
PtrFunc(int (* Func)(int),int X)32 unsigned PtrFunc(int (*Func)(int), int X) {
33 return Func(X);
34 }
35
PtrFunc2(FuncPtr FuncTab[30],int Num)36 char PtrFunc2(FuncPtr FuncTab[30], int Num) {
37 return FuncTab[Num]('b');
38 }
39
40 extern char SmallArgs2(char w, char x, long long Zrrk, char y, char z);
41 extern int SomeFunc(void);
SmallArgs(char w,char x,char y,char z)42 char SmallArgs(char w, char x, char y, char z) {
43 SomeFunc();
44 return SmallArgs2(w-1, x+1, y, z, w);
45 }
46
F0(struct Quad Q,int i)47 static int F0(struct Quad Q, int i) { /* Pass Q by value */
48 struct Quad R;
49 if (i) R.SS = Q.SS;
50 Q.SSP = &R.SS;
51 Q.w = Q.y = Q.c = 1;
52 return Q.SS.Y + i + R.y - Q.c;
53 }
54
F1(struct Quad * Q,int i)55 int F1(struct Quad *Q, int i) { /* Pass Q by address */
56 struct Quad R;
57 #if 0
58 if (i) R.SS = Q->SS;
59 #else
60 if (i) R = *Q;
61 #endif
62 Q->w = Q->y = Q->c = 1;
63 return Q->SS.Y+i+R.y-Q->c;
64 }
65
66
BadFunc(float Val)67 int BadFunc(float Val) {
68 int Result;
69 if (Val > 12.345) Result = 4;
70 return Result; /* Test use of undefined value */
71 }
72
RealFunc(void)73 int RealFunc(void) {
74 return SomeUndefinedFunction(1, 4, 5);
75 }
76
77 extern int EF1(int *, char *, int *);
78
Func(int Param,long long Param2)79 int Func(int Param, long long Param2) {
80 int Result = Param;
81
82 {{{{
83 char c; int X;
84 EF1(&Result, &c, &X);
85 }}}
86
87 { // c & X are duplicate names!
88 char c; int X;
89 EF1(&Result, &c, &X);
90 }
91
92 }
93 return Result;
94 }
95
96
FunFunc(long long x,char z)97 short FunFunc(long long x, char z) {
98 return x+z;
99 }
100
castTest(int X)101 unsigned castTest(int X) { return X; }
102
TestAdd(double X,float Y)103 double TestAdd(double X, float Y) {
104 return X+Y+.5;
105 }
106
func(int i,int j)107 int func(int i, int j) {
108 while (i != 20)
109 i += 2;
110
111 j += func(2, i);
112 return (i * 3 + j*2)*j;
113 }
114
SumArray(int Array[],int Num)115 int SumArray(int Array[], int Num) {
116 int i, Result = 0;
117 for (i = 0; i < Num; ++i)
118 Result += Array[i];
119
120 return Result;
121 }
122
ArrayParam(int Values[100])123 int ArrayParam(int Values[100]) {
124 return EF1((int*)Values[50], (char*)1, &Values[50]);
125 }
126
ArrayToSum(void)127 int ArrayToSum(void) {
128 int A[100], i;
129 for (i = 0; i < 100; ++i)
130 A[i] = i*4;
131
132 return A[A[0]]; //SumArray(A, 100);
133 }
134
135
136 int ExternFunc(long long, unsigned*, short, unsigned char);
137
main(int argc,char * argv[])138 int main(int argc, char *argv[]) {
139 unsigned i;
140 puts("Hello world!\n");
141
142 ExternFunc(-1, 0, (short)argc, 2);
143 //func(argc, argc);
144
145 for (i = 0; i < 10; i++)
146 puts(argv[3]);
147 return 0;
148 }
149
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)150 double MathFunc(double X, double Y, double Z,
151 double AA, double BB, double CC, double DD,
152 double EE, double FF, double GG, double HH,
153 double aAA, double aBB, double aCC, double aDD,
154 double aEE, double aFF) {
155 return X + Y + Z + AA + BB + CC + DD + EE + FF + GG + HH
156 + aAA + aBB + aCC + aDD + aEE + aFF;
157 }
158
159
160
strcpy(char * s1,char * s2)161 void strcpy(char *s1, char *s2) {
162 while (*s1++ = *s2++);
163 }
164
strcat(char * s1,char * s2)165 void strcat(char *s1, char *s2) {
166 while (*s1++);
167 s1--;
168 while (*s1++ = *s2++);
169 }
170
strcmp(char * s1,char * s2)171 int strcmp(char *s1, char *s2) {
172 while (*s1++ == *s2++);
173 if (*s1 == 0) {
174 if (*s2 == 0) {
175 return 0;
176 } else {
177 return -1;
178 }
179 } else {
180 if (*s2 == 0) {
181 return 1;
182 } else {
183 return (*(--s1) - *(--s2));
184 }
185 }
186 }
187
188