John McCall | 4c7a6c6 | 2012-03-21 00:45:33 +0000 | [diff] [blame^] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s -fblocks -std=c++11 |
Fariborz Jahanian | b372b0f | 2010-02-18 20:31:02 +0000 | [diff] [blame] | 2 | |
| 3 | extern "C" int exit(int); |
| 4 | |
| 5 | typedef struct { |
| 6 | unsigned long ps[30]; |
| 7 | int qs[30]; |
| 8 | } BobTheStruct; |
| 9 | |
| 10 | int main (int argc, const char * argv[]) { |
| 11 | BobTheStruct inny; |
| 12 | BobTheStruct outty; |
| 13 | BobTheStruct (^copyStruct)(BobTheStruct); |
| 14 | int i; |
| 15 | |
| 16 | for(i=0; i<30; i++) { |
| 17 | inny.ps[i] = i * i * i; |
| 18 | inny.qs[i] = -i * i * i; |
| 19 | } |
| 20 | |
| 21 | copyStruct = ^(BobTheStruct aBigStruct){ return aBigStruct; }; // pass-by-value intrinsically copies the argument |
| 22 | |
| 23 | outty = copyStruct(inny); |
| 24 | |
| 25 | if ( &inny == &outty ) { |
| 26 | exit(1); |
| 27 | } |
| 28 | for(i=0; i<30; i++) { |
| 29 | if ( (inny.ps[i] != outty.ps[i]) || (inny.qs[i] != outty.qs[i]) ) { |
| 30 | exit(1); |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | return 0; |
| 35 | } |
Douglas Gregor | bf9fb88 | 2010-07-08 20:27:32 +0000 | [diff] [blame] | 36 | |
| 37 | namespace rdar8134521 { |
| 38 | void foo() { |
| 39 | int (^P)(int) = reinterpret_cast<int(^)(int)>(1); |
| 40 | P = (int(^)(int))(1); |
| 41 | |
| 42 | P = reinterpret_cast<int(^)(int)>((void*)1); |
| 43 | P = (int(^)(int))((void*)1); |
| 44 | } |
| 45 | } |
John McCall | 4c7a6c6 | 2012-03-21 00:45:33 +0000 | [diff] [blame^] | 46 | |
| 47 | namespace rdar11055105 { |
| 48 | struct A { |
| 49 | void foo(); |
| 50 | }; |
| 51 | |
| 52 | template <class T> void foo(T &x) noexcept(noexcept(x.foo())); |
| 53 | |
| 54 | void (^block)() = ^{ |
| 55 | A a; |
| 56 | foo(a); |
| 57 | }; |
| 58 | } |