Fix problem executing the CBE
[oota-llvm.git] / test / CFrontend / 2002-07-14-MiscTests.c
1 /* These are random tests that I used when working on the GCC frontend 
2    originally. */
3
4 // test floating point comparison!
5 int floatcomptest(double *X, double *Y, float *x, float *y) {
6   return *X < *Y || *x < *y;
7 }
8
9 extern void *malloc(unsigned);
10
11 // Exposed a bug
12 void *memset_impl(void *dstpp, int c, unsigned len) {
13   long long int dstp = (long long int) dstpp;
14
15   while (dstp % 4 != 0)
16     {
17       ((unsigned char *) dstp)[0] = c;
18       dstp += 1;
19       len -= 1;
20     }
21   return dstpp;
22 }
23
24 // TEST problem with signed/unsigned versions of the same constants being shared
25 // incorrectly!
26 //
27 static char *temp;
28 static int remaining;
29 static char *localmalloc(int size) {
30   char *blah;
31   
32   if (size>remaining) 
33     {
34       temp = (char *) malloc(32768);
35       remaining = 32768;
36       return temp;
37     }
38   return 0;
39 }
40
41 typedef struct { double X; double Y; int Z; } PBVTest;
42
43 PBVTest testRetStruct(float X, double Y, int Z) {
44   PBVTest T = { X, Y, Z };
45   return T;
46 }
47 PBVTest testRetStruct2(void);  // external func no inlining
48
49
50 double CallRetStruct(float X, double Y, int Z) {
51   PBVTest T = testRetStruct2();
52   return T.X+X+Y+Z;
53 }
54
55