1 | // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s |
2 | // RUN: grep -F '@objc_assign_global' %t | count 7 |
3 | // RUN: grep -F '@objc_assign_ivar' %t | count 5 |
4 | // RUN: grep -F '@objc_assign_strongCast' %t | count 8 |
5 | // RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s |
6 | // RUN: grep -F '@objc_assign_global' %t | count 7 |
7 | // RUN: grep -F '@objc_assign_ivar' %t | count 5 |
8 | // RUN: grep -F '@objc_assign_strongCast' %t | count 8 |
9 | |
10 | extern id **somefunc(void); |
11 | extern id *somefunc2(void); |
12 | |
13 | |
14 | // Globals |
15 | |
16 | id W, *X, **Y; |
17 | |
18 | void func(id a, id *b, id **c) { |
19 | static id w, *x, **y; |
20 | W = a; |
21 | w = a; |
22 | X = b; |
23 | x = b; |
24 | Y = c; |
25 | y = c; |
26 | } |
27 | |
28 | // Instances |
29 | |
30 | @interface something { |
31 | id w, *x, **y; |
32 | } |
33 | @end |
34 | |
35 | @implementation something |
36 | - (void)amethod { |
37 | id badIdea = *somefunc2(); |
38 | w = badIdea; |
39 | x = &badIdea; |
40 | y = &x; |
41 | } |
42 | @end |
43 | |
44 | typedef struct { |
45 | int junk; |
46 | id alfred; |
47 | } AStruct; |
48 | |
49 | void funct2(AStruct *aptr) { |
50 | id **ppptr = somefunc(); |
51 | aptr->alfred = 0; |
52 | **ppptr = aptr->alfred; |
53 | *ppptr = somefunc2(); |
54 | } |
55 | |
56 | typedef const struct __CFString * CFStringRef; |
57 | @interface DSATextSearch { |
58 | __strong CFStringRef *_documentNames; |
59 | struct { |
60 | id *innerNames; |
61 | struct { |
62 | id *nestedDeeperNames; |
63 | struct I { |
64 | id *is1; |
65 | id is2[5]; |
66 | } arrI [3]; |
67 | } inner_most; |
68 | } inner; |
69 | |
70 | } |
71 | - filter; |
72 | @end |
73 | @implementation DSATextSearch |
74 | - filter { |
75 | int filteredPos = 0; |
76 | _documentNames[filteredPos] = 0; // storing into an element of array ivar. objc_assign_strongCast is needed. |
77 | inner.innerNames[filteredPos] = 0; |
78 | inner.inner_most.nestedDeeperNames[filteredPos] = 0; |
79 | inner.inner_most.arrI[3].is1[5] = 0; |
80 | inner.inner_most.arrI[3].is2[5] = 0; |
81 | } |
82 | @end |
83 | |
84 | |