blob: 72af74f1ebf76aef35b02a60ab03e684d4530397 [file] [log] [blame]
John McCall260611a2012-06-20 06:18:46 +00001// RUN: %clang_cc1 -x objective-c++ -fblocks -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.5 %s -verify -emit-llvm -o %t
Fariborz Jahaniane3c8c642011-02-12 19:07:46 +00002// rdar://8979379
3
4@interface A
5@end
6
7@interface B : A
8@end
9
10void f(int (^bl)(B* b));
11
12// Test1
13void g() {
14 f(^(A* a) { return 0; });
15}
16
17// Test2
18void g1() {
19 int (^bl)(B* b) = ^(A* a) { return 0; };
20}
21
22// Test3
23@protocol NSObject;
24
25void bar(id(^)(void));
26
27void foo(id <NSObject>(^objectCreationBlock)(void)) {
28 return bar(objectCreationBlock);
29}
30
Richard Smith7a614d82011-06-11 17:19:42 +000031// Test4
32struct S {
Douglas Gregorb3df1382011-10-12 19:26:40 +000033 S *(^a)() = ^{ // expected-warning {{C++11}}
Richard Smith7a614d82011-06-11 17:19:42 +000034 return this;
35 };
36};
37S s;
38
39// Test5
40struct X {
41 void f() {
42 ^ {
Douglas Gregorb3df1382011-10-12 19:26:40 +000043 struct Nested { Nested *ptr = this; }; // expected-warning {{C++11}}
Richard Smith7a614d82011-06-11 17:19:42 +000044 } ();
45 };
46};