Chris Lattner | c6c22e2 | 2009-01-05 21:07:34 +0000 | [diff] [blame] | 1 | // RUN: %llvmgcc %s -S -emit-llvm -O2 -o - | grep {call i32 .*printf.*argc} | count 3 |
| 2 | // rdar://5865221 |
| 3 | |
| 4 | // All of these should be inlined equivalently into a single printf call. |
| 5 | |
| 6 | static int fun(int x) { |
| 7 | return x+1; |
| 8 | } |
| 9 | |
| 10 | static int block(int x) { |
| 11 | return (^(int x){return x+1;})(x); |
| 12 | } |
| 13 | |
| 14 | static void print(int result) { |
| 15 | printf("%d\n", result); |
| 16 | } |
| 17 | |
| 18 | int main (int argc, const char * argv[]) { |
| 19 | int x = argc-1; |
| 20 | print(fun(x)); |
| 21 | print(block(x)); |
| 22 | int (^block_inline)(int) = ^(int x){return x+1;}; |
| 23 | print(block_inline(x)); |
| 24 | return 0; |
| 25 | } |
| 26 | |