Nico Weber | 8951067 | 2012-07-11 22:50:15 +0000 | [diff] [blame^] | 1 | // RUN: %clang_cc1 -x objective-c++ -fblocks -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.5 %s -verify -std=c++11 -emit-llvm -o %t |
Fariborz Jahanian | e3c8c64 | 2011-02-12 19:07:46 +0000 | [diff] [blame] | 2 | // rdar://8979379 |
| 3 | |
| 4 | @interface A |
| 5 | @end |
| 6 | |
| 7 | @interface B : A |
| 8 | @end |
| 9 | |
| 10 | void f(int (^bl)(B* b)); |
| 11 | |
| 12 | // Test1 |
| 13 | void g() { |
| 14 | f(^(A* a) { return 0; }); |
| 15 | } |
| 16 | |
| 17 | // Test2 |
| 18 | void g1() { |
| 19 | int (^bl)(B* b) = ^(A* a) { return 0; }; |
| 20 | } |
| 21 | |
| 22 | // Test3 |
| 23 | @protocol NSObject; |
| 24 | |
| 25 | void bar(id(^)(void)); |
| 26 | |
| 27 | void foo(id <NSObject>(^objectCreationBlock)(void)) { |
| 28 | return bar(objectCreationBlock); |
| 29 | } |
| 30 | |
Richard Smith | 7a614d8 | 2011-06-11 17:19:42 +0000 | [diff] [blame] | 31 | // Test4 |
| 32 | struct S { |
Nico Weber | 8951067 | 2012-07-11 22:50:15 +0000 | [diff] [blame^] | 33 | S *(^a)() = ^{ |
Richard Smith | 7a614d8 | 2011-06-11 17:19:42 +0000 | [diff] [blame] | 34 | return this; |
| 35 | }; |
| 36 | }; |
| 37 | S s; |
| 38 | |
| 39 | // Test5 |
| 40 | struct X { |
| 41 | void f() { |
| 42 | ^ { |
Nico Weber | 8951067 | 2012-07-11 22:50:15 +0000 | [diff] [blame^] | 43 | struct Nested { Nested *ptr = this; }; |
Richard Smith | 7a614d8 | 2011-06-11 17:19:42 +0000 | [diff] [blame] | 44 | } (); |
| 45 | }; |
| 46 | }; |
Nico Weber | 8951067 | 2012-07-11 22:50:15 +0000 | [diff] [blame^] | 47 | |
| 48 | // Regression test for PR13314 |
| 49 | class FooClass { }; |
| 50 | void fun() { |
| 51 | FooClass foovar; |
| 52 | ^() { // expected-warning {{expression result unused}} |
| 53 | return foovar; |
| 54 | }; |
| 55 | } |
| 56 | void gun() { |
| 57 | FooClass foovar; |
| 58 | [=]() { // expected-warning {{expression result unused}} |
| 59 | return foovar; |
| 60 | }; |
| 61 | } |