1 // RUN: %clang_cc1 -fblocks %s -emit-llvm -o %t 2 3 extern "C" int printf(const char*, ...); 4 5 template<typename T> class range { 6 public: 7 T _i; range(T i)8 range(T i) {_i = i;}; get()9 T get() {return _i;}; 10 }; 11 12 // rdar: // 7495203 13 class A { 14 public: A()15 A() : field(10), d1(3.14) {} 16 void F(); S()17 void S() { 18 printf(" field = %d\n", field); 19 printf(" field = %f\n", d1); 20 } 21 int field; 22 double d1; 23 }; 24 F()25void A::F() 26 { 27 __block A &tlc = *this; 28 // crashed in code gen (radar 7495203) 29 ^{ tlc.S(); }(); 30 } 31 main()32int main() { 33 34 // works 35 void (^bl)(range<int> ) = ^(range<int> i){printf("Hello Blocks %d\n", i.get()); }; 36 37 //crashes in godegen? 38 void (^bl2)(range<int>& ) = ^(range<int>& i){printf("Hello Blocks %d\n", i.get()); }; 39 40 A *a = new A; 41 a->F(); 42 return 0; 43 } 44