blob: a493c11849672a2464c8a8b80e48c58722c16f1b [file] [log] [blame]
Fariborz Jahanian653b7cf2012-04-13 18:00:54 +00001// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
2// RUN: FileCheck -check-prefix LP --input-file=%t-rw.cpp %s
3// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -Wno-attributes -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
4
Fariborz Jahanian8b08adb2012-05-03 21:44:12 +00005typedef unsigned long size_t;
Fariborz Jahanian653b7cf2012-04-13 18:00:54 +00006extern "C" {
7extern "C" void *_Block_copy(const void *aBlock);
8extern "C" void _Block_release(const void *aBlock);
9}
10
11int main() {
12 __attribute__((__blocks__(byref))) int a = 42;
13 int save_a = a;
14
15 void (^b)(void) = ^{
16 ((__typeof(^{ a = 2; }))_Block_copy((const void *)(^{ a = 2; })));
17 };
18
19 ((__typeof(b))_Block_copy((const void *)(b)));
20
21 return 0;
22}
23
24// CHECK-LP: ((void (^)(void))_Block_copy((const void *)(b)))
25
26// radar 7628153
27void f() {
28 int a;
29 __typeof__(a) aVal = a;
30 char *a1t = (char *)@encode(__typeof__(a));
31 __typeof__(aVal) bVal;
32 char *a2t = (char *)@encode(__typeof__(bVal));
33 __typeof__(bVal) cVal = bVal;
34 char *a3t = (char *)@encode(__typeof__(cVal));
35
36}
37
38// rdar://11239324
39void x() {
40 id y;
41 void (^z)() = ^{ };
42 y = (id)((__typeof(z))_Block_copy((const void *)(z)));
43}
44
45// CHECK-LP: int aVal = a;
46
47// CHECK-LP: int bVal;