Reid Kleckner | 395dad8 | 2015-01-22 01:19:19 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -triple x86_64-linux -emit-llvm -fblocks -o - | FileCheck %s |
Eric Christopher | 85e5156 | 2011-07-26 22:17:02 +0000 | [diff] [blame] | 2 | // rdar://5865221 |
| 3 | |
| 4 | // These will be inlined by the optimizers provided the block descriptors |
| 5 | // and block literals are internal constants. |
| 6 | // CHECK: @__block_descriptor_tmp = internal constant |
| 7 | // CHECK: @__block_literal_global = internal constant |
Sunil Srivastava | 3acf627 | 2015-05-12 16:48:43 +0000 | [diff] [blame] | 8 | // CHECK: @__block_descriptor_tmp.2 = internal constant |
| 9 | // CHECK: @__block_literal_global.3 = internal constant |
Eric Christopher | 85e5156 | 2011-07-26 22:17:02 +0000 | [diff] [blame] | 10 | static int fun(int x) { |
| 11 | return x+1; |
| 12 | } |
| 13 | |
| 14 | static int block(int x) { |
| 15 | return (^(int x){return x+1;})(x); |
| 16 | } |
| 17 | |
| 18 | static void print(int result) { |
| 19 | printf("%d\n", result); |
| 20 | } |
| 21 | |
| 22 | int main (int argc, const char * argv[]) { |
| 23 | int x = argc-1; |
| 24 | print(fun(x)); |
| 25 | print(block(x)); |
| 26 | int (^block_inline)(int) = ^(int x){return x+1;}; |
| 27 | print(block_inline(x)); |
| 28 | return 0; |
| 29 | } |