blob: 3301b29135d6bc662a20bf60123bf566c5c9476d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
// RUN: %clang_cc1 -std=c++11 -fblocks %s -verify
void block_capture_errors() {
__block int var; // expected-note 2{{'var' declared here}}
(void)[var] { }; // expected-error{{__block variable 'var' cannot be captured in a lambda}}
(void)[=] { var = 17; }; // expected-error{{__block variable 'var' cannot be captured in a lambda}}
}
void conversion_to_block(int captured) {
int (^b1)(int) = [=](int x) { return x + captured; };
const auto lambda = [=](int x) { return x + captured; };
int (^b2)(int) = lambda;
}
template<typename T>
class ConstCopyConstructorBoom {
public:
ConstCopyConstructorBoom(ConstCopyConstructorBoom&);
ConstCopyConstructorBoom(const ConstCopyConstructorBoom&) {
T *ptr = 1; // expected-error{{cannot initialize a variable of type 'float *' with an rvalue of type 'int'}}
}
void foo() const;
};
void conversion_to_block_init(ConstCopyConstructorBoom<int> boom,
ConstCopyConstructorBoom<float> boom2) {
const auto& lambda1([=] { boom.foo(); }); // okay
const auto& lambda2([=] { boom2.foo(); }); // expected-note{{in instantiation of member function}}
void (^block)(void) = lambda2;
}
|