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