blob: 9a76c6eb8208c2d5b72b7a993caa436dd13ae621 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-gc -emit-llvm -o %t %s
Daniel Dunbar4fcfde42009-11-08 01:45:36 +00002// 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
Fariborz Jahanian2db213d2009-09-16 23:49:04 +00005
6extern id **somefunc(void);
7extern id *somefunc2(void);
8
9
10// Globals
11
12id W, *X, **Y;
13
14void func(id a, id *b, id **c) {
15 static id w, *x, **y;
Fariborz Jahanianf08bf1f2009-09-16 23:52:53 +000016 W = a;
17 w = a;
18 X = b;
19 x = b;
20 Y = c;
21 y = c;
Fariborz Jahanian2db213d2009-09-16 23:49:04 +000022}
23
24// Instances
25
26@interface something {
27 id w, *x, **y;
28}
29@end
30
31@implementation something
32- (void)amethod {
33 id badIdea = *somefunc2();
Fariborz Jahanianf08bf1f2009-09-16 23:52:53 +000034 w = badIdea;
35 x = &badIdea;
36 y = &x;
Fariborz Jahanian2db213d2009-09-16 23:49:04 +000037}
38@end
39
40typedef struct {
41 int junk;
42 id alfred;
43} AStruct;
44
45void funct2(AStruct *aptr) {
46 id **ppptr = somefunc();
Fariborz Jahanianf08bf1f2009-09-16 23:52:53 +000047 aptr->alfred = 0;
48 **ppptr = aptr->alfred;
49 *ppptr = somefunc2();
Fariborz Jahanian2db213d2009-09-16 23:49:04 +000050}
51
Fariborz Jahanian1c1afc42009-09-18 00:04:00 +000052typedef const struct __CFString * CFStringRef;
53@interface DSATextSearch {
54__strong CFStringRef *_documentNames;
55 struct {
56 id *innerNames;
57 struct {
58 id *nestedDeeperNames;
59 struct I {
60 id *is1;
61 id is2[5];
62 } arrI [3];
63 } inner_most;
64 } inner;
65
66}
67- filter;
68@end
69@implementation DSATextSearch
70- filter {
71 int filteredPos = 0;
72 _documentNames[filteredPos] = 0; // storing into an element of array ivar. objc_assign_strongCast is needed.
73 inner.innerNames[filteredPos] = 0;
74 inner.inner_most.nestedDeeperNames[filteredPos] = 0;
75 inner.inner_most.arrI[3].is1[5] = 0;
76 inner.inner_most.arrI[3].is2[5] = 0;
77}
78@end
79