| 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 -std=gnu++98 -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 |
|
| 4 |
typedef unsigned long size_t; |
| 5 |
extern "C" __declspec(dllexport) void BreakTheRewriter(void) { |
| 6 |
__block int aBlockVariable = 0; |
| 7 |
void (^aBlock)(void) = ^ { |
| 8 |
aBlockVariable = 42; |
| 9 |
}; |
| 10 |
aBlockVariable++; |
| 11 |
void (^bBlocks)(void) = ^ { |
| 12 |
aBlockVariable = 43; |
| 13 |
}; |
| 14 |
void (^c)(void) = ^ { |
| 15 |
aBlockVariable = 44; |
| 16 |
}; |
| 17 |
|
| 18 |
} |
| 19 |
__declspec(dllexport) extern "C" void AnotherBreakTheRewriter(int *p1, double d) { |
| 20 |
|
| 21 |
__block int bBlockVariable = 0; |
| 22 |
void (^aBlock)(void) = ^ { |
| 23 |
bBlockVariable = 42; |
| 24 |
}; |
| 25 |
bBlockVariable++; |
| 26 |
void (^bBlocks)(void) = ^ { |
| 27 |
bBlockVariable = 43; |
| 28 |
}; |
| 29 |
void (^c)(void) = ^ { |
| 30 |
bBlockVariable = 44; |
| 31 |
}; |
| 32 |
|
| 33 |
} |
| 34 |
|
| 35 |
int |
| 36 |
|
| 37 |
__declspec (dllexport) |
| 38 |
|
| 39 |
main (int argc, char *argv[]) |
| 40 |
{ |
| 41 |
__block int bBlockVariable = 0; |
| 42 |
void (^aBlock)(void) = ^ { |
| 43 |
bBlockVariable = 42; |
| 44 |
}; |
| 45 |
} |
| 46 |
|
| 47 |
static char stringtype; |
| 48 |
char CFStringGetTypeID(); |
| 49 |
void x(void (^)()); |
| 50 |
|
| 51 |
static void initStatics(int arg, ...) { |
| 52 |
x(^{ |
| 53 |
stringtype = CFStringGetTypeID(); |
| 54 |
}); |
| 55 |
} |
| 56 |
static void initStatics1(...) { |
| 57 |
x(^{ |
| 58 |
stringtype = CFStringGetTypeID(); |
| 59 |
}); |
| 60 |
} |
| 61 |
static void initStatics2() { |
| 62 |
x(^{ |
| 63 |
stringtype = CFStringGetTypeID(); |
| 64 |
}); |
| 65 |
} |
| 66 |
|
| 67 |
static inline const void *auto_zone_base_pointer(void *zone, const void *ptr) { return 0; } |
| 68 |
|
| 69 |
@interface I |
| 70 |
{ |
| 71 |
id list; |
| 72 |
} |
| 73 |
- (void) Meth; |
| 74 |
// use before definition |
| 75 |
- (void) allObjects; |
| 76 |
@end |
| 77 |
|
| 78 |
@implementation I |
| 79 |
// use before definition |
| 80 |
- (void) allObjects { |
| 81 |
__attribute__((__blocks__(byref))) id *listp; |
| 82 |
|
| 83 |
void (^B)(void) = ^(void) { |
| 84 |
*listp++ = 0; |
| 85 |
}; |
| 86 |
|
| 87 |
B(); |
| 88 |
} |
| 89 |
- (void) Meth { __attribute__((__blocks__(byref))) void ** listp = (void **)list; } |
| 90 |
@end |
| 91 |
|