1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s -fblocks -std=c++1y 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambuc extern "C" int exit(int); 4*f4a2713aSLionel Sambuc 5*f4a2713aSLionel Sambuc typedef struct { 6*f4a2713aSLionel Sambuc unsigned long ps[30]; 7*f4a2713aSLionel Sambuc int qs[30]; 8*f4a2713aSLionel Sambuc } BobTheStruct; 9*f4a2713aSLionel Sambuc main(int argc,const char * argv[])10*f4a2713aSLionel Sambucint main (int argc, const char * argv[]) { 11*f4a2713aSLionel Sambuc BobTheStruct inny; 12*f4a2713aSLionel Sambuc BobTheStruct outty; 13*f4a2713aSLionel Sambuc BobTheStruct (^copyStruct)(BobTheStruct); 14*f4a2713aSLionel Sambuc int i; 15*f4a2713aSLionel Sambuc 16*f4a2713aSLionel Sambuc for(i=0; i<30; i++) { 17*f4a2713aSLionel Sambuc inny.ps[i] = i * i * i; 18*f4a2713aSLionel Sambuc inny.qs[i] = -i * i * i; 19*f4a2713aSLionel Sambuc } 20*f4a2713aSLionel Sambuc 21*f4a2713aSLionel Sambuc copyStruct = ^(BobTheStruct aBigStruct){ return aBigStruct; }; // pass-by-value intrinsically copies the argument 22*f4a2713aSLionel Sambuc 23*f4a2713aSLionel Sambuc outty = copyStruct(inny); 24*f4a2713aSLionel Sambuc 25*f4a2713aSLionel Sambuc if ( &inny == &outty ) { 26*f4a2713aSLionel Sambuc exit(1); 27*f4a2713aSLionel Sambuc } 28*f4a2713aSLionel Sambuc for(i=0; i<30; i++) { 29*f4a2713aSLionel Sambuc if ( (inny.ps[i] != outty.ps[i]) || (inny.qs[i] != outty.qs[i]) ) { 30*f4a2713aSLionel Sambuc exit(1); 31*f4a2713aSLionel Sambuc } 32*f4a2713aSLionel Sambuc } 33*f4a2713aSLionel Sambuc 34*f4a2713aSLionel Sambuc return 0; 35*f4a2713aSLionel Sambuc } 36*f4a2713aSLionel Sambuc 37*f4a2713aSLionel Sambuc namespace rdar8134521 { foo()38*f4a2713aSLionel Sambuc void foo() { 39*f4a2713aSLionel Sambuc int (^P)(int) = reinterpret_cast<int(^)(int)>(1); 40*f4a2713aSLionel Sambuc P = (int(^)(int))(1); 41*f4a2713aSLionel Sambuc 42*f4a2713aSLionel Sambuc P = reinterpret_cast<int(^)(int)>((void*)1); 43*f4a2713aSLionel Sambuc P = (int(^)(int))((void*)1); 44*f4a2713aSLionel Sambuc } 45*f4a2713aSLionel Sambuc } 46*f4a2713aSLionel Sambuc 47*f4a2713aSLionel Sambuc namespace rdar11055105 { 48*f4a2713aSLionel Sambuc struct A { 49*f4a2713aSLionel Sambuc void foo(); 50*f4a2713aSLionel Sambuc }; 51*f4a2713aSLionel Sambuc 52*f4a2713aSLionel Sambuc template <class T> void foo(T &x) noexcept(noexcept(x.foo())); 53*f4a2713aSLionel Sambuc 54*f4a2713aSLionel Sambuc void (^block)() = ^{ 55*f4a2713aSLionel Sambuc A a; 56*f4a2713aSLionel Sambuc foo(a); 57*f4a2713aSLionel Sambuc }; 58*f4a2713aSLionel Sambuc } 59*f4a2713aSLionel Sambuc 60*f4a2713aSLionel Sambuc namespace LocalDecls { f()61*f4a2713aSLionel Sambuc void f() { 62*f4a2713aSLionel Sambuc (void) ^{ 63*f4a2713aSLionel Sambuc extern int a; // expected-note {{previous}} 64*f4a2713aSLionel Sambuc extern int b(); // expected-note {{previous}} 65*f4a2713aSLionel Sambuc }; 66*f4a2713aSLionel Sambuc } g()67*f4a2713aSLionel Sambuc void g() { 68*f4a2713aSLionel Sambuc (void) ^{ 69*f4a2713aSLionel Sambuc extern float a; // expected-error {{different type}} 70*f4a2713aSLionel Sambuc extern float b(); // expected-error {{cannot be overloaded}} 71*f4a2713aSLionel Sambuc }; 72*f4a2713aSLionel Sambuc } 73*f4a2713aSLionel Sambuc } 74