• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
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
3// rdar://11230308
4
5typedef unsigned long size_t;
6typedef struct {
7    char byte0;
8    char byte1;
9} CFUUIDBytes;
10
11void x(void *);
12
13void y() {
14    __block CFUUIDBytes bytes;
15
16    void (^bar)() = ^{
17        x(&bytes);
18    };
19}
20
21// rdar://11236342
22int foo() {
23    __block int hello;
24    return hello;
25}
26
27// rdar://7547630
28// rewriting multiple __block decls on wintin same decl stmt.
29void radar7547630() {
30  __block int BI1, BI2;
31
32  __block float FLOAT1, FT2, FFFFFFFF3,
33   FFFXXX4;
34
35  __block void (^B)(), (^BB)();
36}
37
38// rewriting multiple __block decls on wintin same decl stmt
39// with initializers.
40int  rdar7547630(const char *keybuf, const char *valuebuf) {
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;
46
47  return BI2;
48}
49
50// rdar://11326988
51typedef struct _z {
52    int location;
53    int length;
54} z;
55
56z 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
66
67// rdar://18799145
68int Test18799145() { return ^(){return 0;}(); }
69