blob: c3bfec9e228cdb6d417821e817a4763d18043c7e [file] [log] [blame]
NAKAMURA Takumibb1a8992012-05-01 10:51:55 +00001// 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 Jahanian76a98be2012-04-17 18:40:53 +00003// rdar://11131490
4
Fariborz Jahanian8b08adb2012-05-03 21:44:12 +00005typedef unsigned long size_t;
Fariborz Jahanian76a98be2012-04-17 18:40:53 +00006extern "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
36int
37
38__declspec (dllexport)
39
40main (int argc, char *argv[])
41{
42 __block int bBlockVariable = 0;
43 void (^aBlock)(void) = ^ {
44 bBlockVariable = 42;
45 };
46}
Fariborz Jahanianb75f8de2012-04-19 00:50:01 +000047
48// rdar://11275241
49static char stringtype;
50char CFStringGetTypeID();
51void x(void (^)());
52
Fariborz Jahanianb5863da2012-04-19 16:30:28 +000053static void initStatics(int arg, ...) {
Fariborz Jahanianb75f8de2012-04-19 00:50:01 +000054 x(^{
55 stringtype = CFStringGetTypeID();
56 });
57}
Fariborz Jahanianb5863da2012-04-19 16:30:28 +000058static void initStatics1(...) {
59 x(^{
60 stringtype = CFStringGetTypeID();
61 });
62}
63static void initStatics2() {
64 x(^{
65 stringtype = CFStringGetTypeID();
66 });
67}
68
Fariborz Jahanian04189532012-04-25 17:56:48 +000069// rdar://11314329
70static inline const void *auto_zone_base_pointer(void *zone, const void *ptr) { return 0; }
Fariborz Jahaniandf407c32012-04-25 20:48:00 +000071
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