NAKAMURA Takumi | bb1a899 | 2012-05-01 10:51:55 +0000 | [diff] [blame] | 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 |
Fariborz Jahanian | 76a98be | 2012-04-17 18:40:53 +0000 | [diff] [blame] | 3 | // rdar://11131490 |
| 4 | |
Fariborz Jahanian | 8b08adb | 2012-05-03 21:44:12 +0000 | [diff] [blame] | 5 | typedef unsigned long size_t; |
Fariborz Jahanian | 76a98be | 2012-04-17 18:40:53 +0000 | [diff] [blame] | 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 | } |
Fariborz Jahanian | b75f8de | 2012-04-19 00:50:01 +0000 | [diff] [blame] | 47 | |
| 48 | // rdar://11275241 |
| 49 | static char stringtype; |
| 50 | char CFStringGetTypeID(); |
| 51 | void x(void (^)()); |
| 52 | |
Fariborz Jahanian | b5863da | 2012-04-19 16:30:28 +0000 | [diff] [blame] | 53 | static void initStatics(int arg, ...) { |
Fariborz Jahanian | b75f8de | 2012-04-19 00:50:01 +0000 | [diff] [blame] | 54 | x(^{ |
| 55 | stringtype = CFStringGetTypeID(); |
| 56 | }); |
| 57 | } |
Fariborz Jahanian | b5863da | 2012-04-19 16:30:28 +0000 | [diff] [blame] | 58 | static void initStatics1(...) { |
| 59 | x(^{ |
| 60 | stringtype = CFStringGetTypeID(); |
| 61 | }); |
| 62 | } |
| 63 | static void initStatics2() { |
| 64 | x(^{ |
| 65 | stringtype = CFStringGetTypeID(); |
| 66 | }); |
| 67 | } |
| 68 | |
Fariborz Jahanian | 0418953 | 2012-04-25 17:56:48 +0000 | [diff] [blame] | 69 | // rdar://11314329 |
| 70 | static inline const void *auto_zone_base_pointer(void *zone, const void *ptr) { return 0; } |
Fariborz Jahanian | df407c3 | 2012-04-25 20:48:00 +0000 | [diff] [blame] | 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 | |