blob: 02e9cac62ebeca80729151ac5bbcda6420f54525 [file] [log] [blame]
John McCall4c7a6c62012-03-21 00:45:33 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s -fblocks -std=c++11
Andy Gibbs8e8fb3b2012-10-19 12:44:48 +00002// expected-no-diagnostics
Fariborz Jahanianb372b0f2010-02-18 20:31:02 +00003
4extern "C" int exit(int);
5
6typedef struct {
7 unsigned long ps[30];
8 int qs[30];
9} BobTheStruct;
10
11int 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 Gregorbf9fb882010-07-08 20:27:32 +000037
38namespace 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 McCall4c7a6c62012-03-21 00:45:33 +000047
48namespace 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}