Fariborz Jahanian | 104dbf9 | 2012-04-11 23:57:12 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp |
NAKAMURA Takumi | 9ff009f | 2012-05-01 10:52:06 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 -fsyntax-only -Werror -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -U__declspec -D"__declspec(X)=" %t-rw.cpp |
Fariborz Jahanian | 104dbf9 | 2012-04-11 23:57:12 +0000 | [diff] [blame] | 3 | // rdar://11230308 |
| 4 | |
Fariborz Jahanian | 8b08adb | 2012-05-03 21:44:12 +0000 | [diff] [blame] | 5 | typedef unsigned long size_t; |
Fariborz Jahanian | 104dbf9 | 2012-04-11 23:57:12 +0000 | [diff] [blame] | 6 | typedef struct { |
| 7 | char byte0; |
| 8 | char byte1; |
| 9 | } CFUUIDBytes; |
| 10 | |
| 11 | void x(void *); |
| 12 | |
| 13 | void y() { |
| 14 | __block CFUUIDBytes bytes; |
| 15 | |
| 16 | void (^bar)() = ^{ |
| 17 | x(&bytes); |
| 18 | }; |
| 19 | } |
Fariborz Jahanian | 5ce2827 | 2012-04-12 16:33:31 +0000 | [diff] [blame] | 20 | |
| 21 | // rdar://11236342 |
| 22 | int foo() { |
| 23 | __block int hello; |
Fariborz Jahanian | d3a39f0 | 2012-04-25 18:11:57 +0000 | [diff] [blame] | 24 | return hello; |
Fariborz Jahanian | 5ce2827 | 2012-04-12 16:33:31 +0000 | [diff] [blame] | 25 | } |
Fariborz Jahanian | e6e96de | 2012-04-24 18:16:20 +0000 | [diff] [blame] | 26 | |
| 27 | // rdar://7547630 |
| 28 | // rewriting multiple __block decls on wintin same decl stmt. |
Fariborz Jahanian | d3a39f0 | 2012-04-25 18:11:57 +0000 | [diff] [blame] | 29 | void radar7547630() { |
Fariborz Jahanian | e6e96de | 2012-04-24 18:16:20 +0000 | [diff] [blame] | 30 | __block int BI1, BI2; |
| 31 | |
| 32 | __block float FLOAT1, FT2, FFFFFFFF3, |
| 33 | FFFXXX4; |
| 34 | |
| 35 | __block void (^B)(), (^BB)(); |
| 36 | } |
| 37 | |
Fariborz Jahanian | 4fe261c | 2012-04-24 19:38:45 +0000 | [diff] [blame] | 38 | // rewriting multiple __block decls on wintin same decl stmt |
| 39 | // with initializers. |
Fariborz Jahanian | d3a39f0 | 2012-04-25 18:11:57 +0000 | [diff] [blame] | 40 | int rdar7547630(const char *keybuf, const char *valuebuf) { |
Fariborz Jahanian | 4fe261c | 2012-04-24 19:38:45 +0000 | [diff] [blame] | 41 | __block int BI1 = 1, BI2 = 2; |
| 42 | |
| 43 | double __block BYREFVAR = 1.34, BYREFVAR_NO_INIT, BYREFVAR2 = 1.37; |
| 44 | |
| 45 | __block const char *keys = keybuf, *values = valuebuf, *novalues; |
Fariborz Jahanian | d3a39f0 | 2012-04-25 18:11:57 +0000 | [diff] [blame] | 46 | |
| 47 | return BI2; |
Fariborz Jahanian | 4fe261c | 2012-04-24 19:38:45 +0000 | [diff] [blame] | 48 | } |
| 49 | |
Fariborz Jahanian | 65a7c68 | 2012-04-26 23:20:25 +0000 | [diff] [blame] | 50 | // rdar://11326988 |
| 51 | typedef struct _z { |
| 52 | int location; |
| 53 | int length; |
| 54 | } z; |
| 55 | |
| 56 | z w(int loc, int len); |
| 57 | |
| 58 | @interface rdar11326988 |
| 59 | @end |
| 60 | @implementation rdar11326988 |
| 61 | - (void)y:(int)options { |
| 62 | __attribute__((__blocks__(byref))) z firstRange = w(1, 0); |
| 63 | options &= ~(1 | 2); |
| 64 | } |
| 65 | @end |