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