xref: /llvm-project/clang/test/Rewriter/rewrite-modern-extern-c-func-decl.mm (revision 0f1c1be1968076d6f96f8a7bcc4a15cf195ecd97)
1// RUN: %clang_cc1 -fms-extensions -U__declspec -rewrite-objc -x objective-c++ -fblocks -o %t-rw.cpp %s
2// RUN: %clang_cc1 -fsyntax-only -std=gnu++98 -Werror -Wno-address-of-temporary -Wno-attributes -D"Class=void*" -D"id=void*" -D"SEL=void*" -U__declspec -D"__declspec(X)=" %t-rw.cpp
3
4typedef unsigned long size_t;
5extern "C" __declspec(dllexport) void BreakTheRewriter(void) {
6        __block int aBlockVariable = 0;
7        void (^aBlock)(void) = ^ {
8                aBlockVariable = 42;
9        };
10        aBlockVariable++;
11        void (^bBlocks)(void) = ^ {
12                aBlockVariable = 43;
13        };
14        void (^c)(void) = ^ {
15                aBlockVariable = 44;
16        };
17
18}
19__declspec(dllexport) extern "C" void AnotherBreakTheRewriter(int *p1, double d) {
20
21        __block int bBlockVariable = 0;
22        void (^aBlock)(void) = ^ {
23                bBlockVariable = 42;
24        };
25        bBlockVariable++;
26        void (^bBlocks)(void) = ^ {
27                bBlockVariable = 43;
28        };
29        void (^c)(void) = ^ {
30                bBlockVariable = 44;
31        };
32
33}
34
35int
36
37__declspec (dllexport)
38
39main (int argc, char *argv[])
40{
41        __block int bBlockVariable = 0;
42        void (^aBlock)(void) = ^ {
43                bBlockVariable = 42;
44        };
45}
46
47static char stringtype;
48char CFStringGetTypeID();
49void x(void (^)());
50
51static void initStatics(int arg, ...) {
52    x(^{
53        stringtype = CFStringGetTypeID();
54    });
55}
56static void initStatics1(...) {
57    x(^{
58        stringtype = CFStringGetTypeID();
59    });
60}
61static void initStatics2() {
62    x(^{
63        stringtype = CFStringGetTypeID();
64    });
65}
66
67static inline const void *auto_zone_base_pointer(void *zone, const void *ptr) { return 0; }
68
69@interface I
70{
71   id list;
72}
73- (void) Meth;
74// use before definition
75- (void) allObjects;
76@end
77
78@implementation I
79// use before definition
80- (void) allObjects {
81    __attribute__((__blocks__(byref))) id *listp;
82
83    void (^B)(void) = ^(void) {
84      *listp++ = 0;
85    };
86
87    B();
88}
89- (void) Meth { __attribute__((__blocks__(byref))) void ** listp = (void **)list; }
90@end
91
92