| 1 | // RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s -std=c++11 -fblocks -fobjc-arc | FileCheck %s |
| 2 | |
| 3 | // CHECK: define internal void @___Z16test_default_argi_block_invoke(i8* %[[BLOCK_DESCRIPTOR:.*]]) |
| 4 | // CHECK: %[[BLOCK:.*]] = bitcast i8* %[[BLOCK_DESCRIPTOR]] to <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32 }>* |
| 5 | // CHECK: %[[BLOCK_CAPTURE_ADDR:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32 }>, <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32 }>* %[[BLOCK]], i32 0, i32 5 |
| 6 | // CHECK: %[[V0:.*]] = load i32, i32* %[[BLOCK_CAPTURE_ADDR]] |
| 7 | // CHECK: call void @_Z4foo1i(i32 %[[V0]]) |
| 8 | |
| 9 | void foo1(int); |
| 10 | |
| 11 | void test_default_arg(const int a = 42) { |
| 12 | auto block = ^{ |
| 13 | foo1(a); |
| 14 | }; |
| 15 | block(); |
| 16 | } |
| 17 | |