blob: 14a182a345c37f4145489083888bd65ad9a567bf [file] [log] [blame]
Fariborz Jahanian9e0393d2012-02-04 19:06:06 +00001// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
Fariborz Jahanian7c7e3492010-03-04 21:57:21 +00002// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
Fariborz Jahaniana73165e2010-01-14 23:05:52 +00003// radar 7540194
4
5extern "C" __declspec(dllexport) void BreakTheRewriter(int i) {
6 __block int aBlockVariable = 0;
7 void (^aBlock)(void) = ^ {
8 aBlockVariable = 42;
9 };
10 aBlockVariable++;
11 if (i) {
12 __block int bbBlockVariable = 0;
13 void (^aBlock)(void) = ^ {
14 bbBlockVariable = 42;
15 };
16 }
17}
18
19__declspec(dllexport) extern "C" __declspec(dllexport) void XXXXBreakTheRewriter(void) {
20
21 __block int aBlockVariable = 0;
22 void (^aBlock)(void) = ^ {
23 aBlockVariable = 42;
24 };
25 aBlockVariable++;
26 void (^bBlocks)(void) = ^ {
27 aBlockVariable = 43;
28 };
29 void (^c)(void) = ^ {
30 aBlockVariable = 44;
31 };
32
33}
34
Fariborz Jahaniandfa4fa02010-01-16 19:36:43 +000035@interface I
36{
37 id list;
38}
39- (void) Meth;
Fariborz Jahanian0e1c99a2010-01-29 01:55:49 +000040// radar 7589385 use before definition
41- (void) allObjects;
Fariborz Jahaniandfa4fa02010-01-16 19:36:43 +000042@end
43
44@implementation I
Fariborz Jahanian0e1c99a2010-01-29 01:55:49 +000045// radar 7589385 use before definition
46- (void) allObjects {
47 __attribute__((__blocks__(byref))) id *listp;
48
49 ^(void) {
50 *listp++ = 0;
51 };
52}
Fariborz Jahaniandfa4fa02010-01-16 19:36:43 +000053- (void) Meth { __attribute__((__blocks__(byref))) void ** listp = (void **)list; }
54@end
55
Fariborz Jahanian9e0393d2012-02-04 19:06:06 +000056// $CLANG -cc1 -fms-extensions -rewrite-objc -fobjc-fragile-abi -x objective-c++ -fblocks bug.mm
Fariborz Jahaniana73165e2010-01-14 23:05:52 +000057// g++ -c -D"__declspec(X)=" bug.cpp