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