| 1 |
// RUN: %clang_cc1 -emit-llvm-only -std=c++11 -fblocks -o - -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 %s |
| 2 |
|
| 3 |
@class DYFuture; |
| 4 |
@interface NSCache |
| 5 |
- (void)setObject:(id)obj forKey:(id)key; |
| 6 |
@end |
| 7 |
|
| 8 |
template <typename T> |
| 9 |
class ResourceManager |
| 10 |
{ |
| 11 |
public: |
| 12 |
~ResourceManager(); |
| 13 |
DYFuture* XXX(); |
| 14 |
NSCache* _spDeviceCache; |
| 15 |
}; |
| 16 |
|
| 17 |
template <typename T> |
| 18 |
DYFuture* ResourceManager<T>::XXX() |
| 19 |
{ |
| 20 |
^ { |
| 21 |
[_spDeviceCache setObject:0 forKey:0]; |
| 22 |
}(); |
| 23 |
|
| 24 |
return 0; |
| 25 |
} |
| 26 |
|
| 27 |
struct AnalyzerBaseObjectTypes { }; |
| 28 |
|
| 29 |
void FUNC() |
| 30 |
{ |
| 31 |
ResourceManager<AnalyzerBaseObjectTypes> *rm; |
| 32 |
^(void) { rm->XXX(); }(); |
| 33 |
} |
| 34 |
|
| 35 |
namespace PR9982 { |
| 36 |
template<typename T> struct Curry; |
| 37 |
|
| 38 |
template<typename R, typename Arg0, typename Arg1, typename Arg2> |
| 39 |
struct Curry<R (^)(Arg0, Arg1, Arg2)> |
| 40 |
{ |
| 41 |
typedef R (^FType)(Arg0, Arg1, Arg2); |
| 42 |
|
| 43 |
Curry(FType _f) : f(_f) {} |
| 44 |
~Curry() {;} |
| 45 |
|
| 46 |
R (^(^operator()(Arg0 a))(Arg1))(Arg2) |
| 47 |
{ |
| 48 |
auto block = ^(Arg1 b) { |
| 49 |
auto inner_block = ^(Arg2 c) { |
| 50 |
return f(a, b, c); |
| 51 |
}; |
| 52 |
return inner_block; |
| 53 |
}; |
| 54 |
return block; |
| 55 |
} |
| 56 |
|
| 57 |
private: |
| 58 |
FType f; |
| 59 |
}; |
| 60 |
|
| 61 |
auto add = ^(int a, int b, int c) |
| 62 |
{ |
| 63 |
return a + b + c; |
| 64 |
}; |
| 65 |
|
| 66 |
void curry() { |
| 67 |
Curry<__decltype(add)> c = Curry<__decltype(add)>(add); |
| 68 |
auto t = c(1)(10)(100); |
| 69 |
} |
| 70 |
} |