Home | History | Annotate | Download | only in Rewriter
      1 // 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 
      5 extern "C" {
      6 extern "C" void *_Block_copy(const void *aBlock);
      7 extern "C" void _Block_release(const void *aBlock);
      8 }
      9 
     10 int main() {
     11     __attribute__((__blocks__(byref))) int a = 42;
     12     int save_a = a;
     13 
     14     void (^b)(void) = ^{
     15         ((__typeof(^{ a = 2; }))_Block_copy((const void *)(^{ a = 2; })));
     16     };
     17 
     18     ((__typeof(b))_Block_copy((const void *)(b)));
     19 
     20     return 0;
     21 }
     22 
     23 // CHECK-LP: ((void (^)(void))_Block_copy((const void *)(b)))
     24 
     25 // radar 7628153
     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 // rdar://11239324
     38 void x() {
     39     id y;
     40     void (^z)() = ^{ };
     41     y = (id)((__typeof(z))_Block_copy((const void *)(z)));
     42 }
     43 
     44 // CHECK-LP: int aVal =  a;
     45 
     46 // CHECK-LP: int bVal;
     47