Home | History | Annotate | Download | only in Rewriter
      1 // RUN: %clang_cc1 -fms-extensions -U__declspec -rewrite-objc -x objective-c++ -fblocks -o %t-rw.cpp %s
      2 // RUN: %clang_cc1 -fsyntax-only -Werror -Wno-address-of-temporary -Wno-attributes -D"Class=void*" -D"id=void*" -D"SEL=void*" -U__declspec -D"__declspec(X)=" %t-rw.cpp
      3 // rdar://11131490
      4 
      5 typedef unsigned long size_t;
      6 extern "C" __declspec(dllexport) void BreakTheRewriter(void) {
      7         __block int aBlockVariable = 0;
      8         void (^aBlock)(void) = ^ {
      9                 aBlockVariable = 42;
     10         };
     11         aBlockVariable++;
     12         void (^bBlocks)(void) = ^ {
     13                 aBlockVariable = 43;
     14         };
     15         void (^c)(void) = ^ {
     16                 aBlockVariable = 44;
     17         };
     18 
     19 }
     20 __declspec(dllexport) extern "C" void AnotherBreakTheRewriter(int *p1, double d) {
     21 
     22         __block int bBlockVariable = 0;
     23         void (^aBlock)(void) = ^ {
     24                 bBlockVariable = 42;
     25         };
     26         bBlockVariable++;
     27         void (^bBlocks)(void) = ^ {
     28                 bBlockVariable = 43;
     29         };
     30         void (^c)(void) = ^ {
     31                 bBlockVariable = 44;
     32         };
     33 
     34 }
     35 
     36 int
     37 
     38 __declspec (dllexport)
     39 
     40 main (int argc, char *argv[])
     41 {
     42         __block int bBlockVariable = 0;
     43         void (^aBlock)(void) = ^ {
     44                 bBlockVariable = 42;
     45         };
     46 }
     47 
     48 // rdar://11275241
     49 static char stringtype;
     50 char CFStringGetTypeID();
     51 void x(void (^)());
     52 
     53 static void initStatics(int arg, ...) {
     54     x(^{
     55         stringtype = CFStringGetTypeID();
     56     });
     57 }
     58 static void initStatics1(...) {
     59     x(^{
     60         stringtype = CFStringGetTypeID();
     61     });
     62 }
     63 static void initStatics2() {
     64     x(^{
     65         stringtype = CFStringGetTypeID();
     66     });
     67 }
     68 
     69 // rdar://11314329
     70 static inline const void *auto_zone_base_pointer(void *zone, const void *ptr) { return 0; }
     71 
     72 @interface I
     73 {
     74    id list;
     75 }
     76 - (void) Meth;
     77 // radar 7589385 use before definition
     78 - (void) allObjects;
     79 @end
     80 
     81 @implementation I
     82 // radar 7589385 use before definition
     83 - (void) allObjects {
     84     __attribute__((__blocks__(byref))) id *listp;
     85 
     86     void (^B)(void) = ^(void) {
     87       *listp++ = 0;
     88     };
     89 
     90     B();
     91 }
     92 - (void) Meth { __attribute__((__blocks__(byref))) void ** listp = (void **)list; }
     93 @end
     94 
     95