Chris Lattner | 3cc5e5b | 2008-06-27 22:48:56 +0000 | [diff] [blame] | 1 | // RUN: clang %s -emit-llvm -o - |
Chris Lattner | efdd157 | 2008-01-02 21:54:09 +0000 | [diff] [blame] | 2 | |
| 3 | // PR1895 |
| 4 | // sizeof function |
| 5 | int zxcv(void); |
| 6 | int x=sizeof(zxcv); |
| 7 | int y=__alignof__(zxcv); |
| 8 | |
Chris Lattner | 8f92528 | 2008-01-03 06:36:51 +0000 | [diff] [blame] | 9 | |
| 10 | void *test(int *i) { |
| 11 | short a = 1; |
| 12 | i += a; |
| 13 | i + a; |
| 14 | a + i; |
| 15 | } |
| 16 | |
Chris Lattner | 01e3c9e | 2008-01-30 07:01:17 +0000 | [diff] [blame] | 17 | _Bool test2b; |
| 18 | int test2() {if (test2b);} |
| 19 | |
Chris Lattner | 6860f3c | 2008-01-31 04:12:50 +0000 | [diff] [blame] | 20 | // PR1921 |
| 21 | int test3() { |
| 22 | const unsigned char *bp; |
| 23 | bp -= (short)1; |
| 24 | } |
| 25 | |
Chris Lattner | a269ebf | 2008-02-21 05:45:29 +0000 | [diff] [blame] | 26 | // PR2080 - sizeof void |
| 27 | int t1 = sizeof(void); |
| 28 | int t2 = __alignof__(void); |
| 29 | void test4() { |
| 30 | t1 = sizeof(void); |
| 31 | t2 = __alignof__(void); |
| 32 | |
| 33 | t1 = sizeof(test4()); |
| 34 | t2 = __alignof__(test4()); |
| 35 | } |
| 36 | |
Chris Lattner | 3cc5e5b | 2008-06-27 22:48:56 +0000 | [diff] [blame] | 37 | // 'const float' promotes to double in varargs. |
| 38 | int test5(const float x, float float_number) { |
| 39 | return __builtin_isless(x, float_number); |
| 40 | } |
| 41 | |
Nuno Lopes | f9ef0c6 | 2008-11-16 20:09:07 +0000 | [diff] [blame] | 42 | // this one shouldn't fold |
| 43 | int ola() { |
| 44 | int a=2; |
| 45 | if ((0, (int)a) & 2) { return 1; } |
| 46 | return 2; |
| 47 | } |
Nuno Lopes | a468d34 | 2008-11-19 17:44:31 +0000 | [diff] [blame] | 48 | |
| 49 | // this one shouldn't fold as well |
| 50 | void eMaisUma() { |
| 51 | double t[1]; |
| 52 | if (*t) |
| 53 | return; |
| 54 | } |
Chris Lattner | e5ed151 | 2009-02-11 07:21:43 +0000 | [diff] [blame] | 55 | |
| 56 | // rdar://6520707 |
| 57 | void f0(void (*fp)(void), void (*fp2)(void)) { |
| 58 | int x = fp - fp2; |
| 59 | } |
| 60 | |
| 61 | |