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