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