Debian Codegraph @

clang/test/Rewriter/rewrite-modern-typeof.mm

raw
1 // RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
2 // RUN: FileCheck -check-prefix CHECK-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
5 typedef unsigned long size_t;
6 extern "C" {
7 extern "C" void *_Block_copy(const void *aBlock);
8 extern "C" void _Block_release(const void *aBlock);
9 }
10
11 int 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 void f() {
27 int a;
28 __typeof__(a) aVal = a;
29 char *a1t = (char *)@encode(__typeof__(a));
30 __typeof__(aVal) bVal;
31 char *a2t = (char *)@encode(__typeof__(bVal));
32 __typeof__(bVal) cVal = bVal;
33 char *a3t = (char *)@encode(__typeof__(cVal));
34
35 }
36
37 void x() {
38 id y;
39 void (^z)() = ^{ };
40 y = (id)((__typeof(z))_Block_copy((const void *)(z)));
41 }
42
43 // CHECK-LP: int aVal = a;
44
45 // CHECK-LP: int bVal;