2012-04-12 07:57:12 +08:00
|
|
|
// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
|
2012-05-01 18:52:06 +08:00
|
|
|
// 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
|
2012-04-12 07:57:12 +08:00
|
|
|
// rdar://11230308
|
|
|
|
|
2012-05-04 05:44:12 +08:00
|
|
|
typedef unsigned long size_t;
|
2012-04-12 07:57:12 +08:00
|
|
|
typedef struct {
|
|
|
|
char byte0;
|
|
|
|
char byte1;
|
|
|
|
} CFUUIDBytes;
|
|
|
|
|
|
|
|
void x(void *);
|
|
|
|
|
|
|
|
void y() {
|
|
|
|
__block CFUUIDBytes bytes;
|
|
|
|
|
|
|
|
void (^bar)() = ^{
|
|
|
|
x(&bytes);
|
|
|
|
};
|
|
|
|
}
|
2012-04-13 00:33:31 +08:00
|
|
|
|
|
|
|
// rdar://11236342
|
|
|
|
int foo() {
|
|
|
|
__block int hello;
|
2012-04-26 02:11:57 +08:00
|
|
|
return hello;
|
2012-04-13 00:33:31 +08:00
|
|
|
}
|
2012-04-25 02:16:20 +08:00
|
|
|
|
|
|
|
// rdar://7547630
|
|
|
|
// rewriting multiple __block decls on wintin same decl stmt.
|
2012-04-26 02:11:57 +08:00
|
|
|
void radar7547630() {
|
2012-04-25 02:16:20 +08:00
|
|
|
__block int BI1, BI2;
|
|
|
|
|
|
|
|
__block float FLOAT1, FT2, FFFFFFFF3,
|
|
|
|
FFFXXX4;
|
|
|
|
|
|
|
|
__block void (^B)(), (^BB)();
|
|
|
|
}
|
|
|
|
|
2012-04-25 03:38:45 +08:00
|
|
|
// rewriting multiple __block decls on wintin same decl stmt
|
|
|
|
// with initializers.
|
2012-04-26 02:11:57 +08:00
|
|
|
int rdar7547630(const char *keybuf, const char *valuebuf) {
|
2012-04-25 03:38:45 +08:00
|
|
|
__block int BI1 = 1, BI2 = 2;
|
|
|
|
|
|
|
|
double __block BYREFVAR = 1.34, BYREFVAR_NO_INIT, BYREFVAR2 = 1.37;
|
|
|
|
|
|
|
|
__block const char *keys = keybuf, *values = valuebuf, *novalues;
|
2012-04-26 02:11:57 +08:00
|
|
|
|
|
|
|
return BI2;
|
2012-04-25 03:38:45 +08:00
|
|
|
}
|
|
|
|
|
2012-04-27 07:20:25 +08:00
|
|
|
// rdar://11326988
|
|
|
|
typedef struct _z {
|
|
|
|
int location;
|
|
|
|
int length;
|
|
|
|
} z;
|
|
|
|
|
|
|
|
z w(int loc, int len);
|
|
|
|
|
|
|
|
@interface rdar11326988
|
|
|
|
@end
|
|
|
|
@implementation rdar11326988
|
|
|
|
- (void)y:(int)options {
|
|
|
|
__attribute__((__blocks__(byref))) z firstRange = w(1, 0);
|
|
|
|
options &= ~(1 | 2);
|
|
|
|
}
|
|
|
|
@end
|
2014-10-29 07:46:58 +08:00
|
|
|
|
|
|
|
// rdar://18799145
|
|
|
|
int Test18799145() { return ^(){return 0;}(); }
|