[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGen / 2002-07-14-MiscTests3.c
blobb9d69ee2c7ef00983288cbaef4b0696edf1fedb7
1 // RUN: %clang_cc1 -Wno-implicit-function-declaration -w -emit-llvm %s -o /dev/null
3 void *malloc(unsigned);
4 int puts(const char *s);
6 struct FunStructTest {
7 int Test1;
8 char *Pointer;
9 int Array[12];
12 struct SubStruct {
13 short X, Y;
16 struct Quad {
17 int w;
18 struct SubStruct SS;
19 struct SubStruct *SSP;
20 char c;
21 int y;
24 struct Quad GlobalQuad = { 4, {1, 2}, 0, 3, 156 };
26 typedef int (*FuncPtr)(int);
28 unsigned PtrFunc(int (*Func)(int), int X) {
29 return Func(X);
32 char PtrFunc2(FuncPtr FuncTab[30], int Num) {
33 return FuncTab[Num]('b');
36 extern char SmallArgs2(char w, char x, long long Zrrk, char y, char z);
37 extern int SomeFunc(void);
38 char SmallArgs(char w, char x, char y, char z) {
39 SomeFunc();
40 return SmallArgs2(w-1, x+1, y, z, w);
43 static int F0(struct Quad Q, int i) { /* Pass Q by value */
44 struct Quad R;
45 if (i) R.SS = Q.SS;
46 Q.SSP = &R.SS;
47 Q.w = Q.y = Q.c = 1;
48 return Q.SS.Y + i + R.y - Q.c;
51 int F1(struct Quad *Q, int i) { /* Pass Q by address */
52 struct Quad R;
53 #if 0
54 if (i) R.SS = Q->SS;
55 #else
56 if (i) R = *Q;
57 #endif
58 Q->w = Q->y = Q->c = 1;
59 return Q->SS.Y+i+R.y-Q->c;
63 int BadFunc(float Val) {
64 int Result;
65 if (Val > 12.345) Result = 4;
66 return Result; /* Test use of undefined value */
69 int RealFunc(void) {
70 return SomeUndefinedFunction(1, 4, 5);
73 extern int EF1(int *, char *, int *);
75 int Func(int Param, long long Param2) {
76 int Result = Param;
78 {{{{
79 char c; int X;
80 EF1(&Result, &c, &X);
81 }}}
83 { // c & X are duplicate names!
84 char c; int X;
85 EF1(&Result, &c, &X);
89 return Result;
93 short FunFunc(long long x, char z) {
94 return x+z;
97 unsigned castTest(int X) { return X; }
99 double TestAdd(double X, float Y) {
100 return X+Y+.5;
103 int func(int i, int j) {
104 while (i != 20)
105 i += 2;
107 j += func(2, i);
108 return (i * 3 + j*2)*j;
111 int SumArray(int Array[], int Num) {
112 int i, Result = 0;
113 for (i = 0; i < Num; ++i)
114 Result += Array[i];
116 return Result;
119 int ArrayParam(int Values[100]) {
120 return EF1((int*)Values[50], (char*)1, &Values[50]);
123 int ArrayToSum(void) {
124 int A[100], i;
125 for (i = 0; i < 100; ++i)
126 A[i] = i*4;
128 return A[A[0]]; //SumArray(A, 100);
132 int ExternFunc(long long, unsigned*, short, unsigned char);
134 int main(int argc, char *argv[]) {
135 unsigned i;
136 puts("Hello world!\n");
138 ExternFunc(-1, 0, (short)argc, 2);
139 //func(argc, argc);
141 for (i = 0; i < 10; i++)
142 puts(argv[3]);
143 return 0;
146 double MathFunc(double X, double Y, double Z,
147 double AA, double BB, double CC, double DD,
148 double EE, double FF, double GG, double HH,
149 double aAA, double aBB, double aCC, double aDD,
150 double aEE, double aFF) {
151 return X + Y + Z + AA + BB + CC + DD + EE + FF + GG + HH
152 + aAA + aBB + aCC + aDD + aEE + aFF;
157 void strcpy(char *s1, char *s2) {
158 while (*s1++ = *s2++);
161 void strcat(char *s1, char *s2) {
162 while (*s1++);
163 s1--;
164 while (*s1++ = *s2++);
167 int strcmp(char *s1, char *s2) {
168 while (*s1++ == *s2++);
169 if (*s1 == 0) {
170 if (*s2 == 0) {
171 return 0;
172 } else {
173 return -1;
175 } else {
176 if (*s2 == 0) {
177 return 1;
178 } else {
179 return (*(--s1) - *(--s2));