blob: 6bc2f509083bcc8f76f4e9e07d279a6c94ba3171 [file] [log] [blame]
John McCall260611a2012-06-20 06:18:46 +00001// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -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
John McCall260611a2012-06-20 06:18:46 +00005// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s
Fariborz Jahanian27b7aa02010-05-20 18:22:28 +00006// 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
Fariborz Jahanian2db213d2009-09-16 23:49:04 +00009
10extern id **somefunc(void);
11extern id *somefunc2(void);
12
13
14// Globals
15
16id W, *X, **Y;
17
18void func(id a, id *b, id **c) {
19 static id w, *x, **y;
Fariborz Jahanianf08bf1f2009-09-16 23:52:53 +000020 W = a;
21 w = a;
22 X = b;
23 x = b;
24 Y = c;
25 y = c;
Fariborz Jahanian2db213d2009-09-16 23:49:04 +000026}
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();
Fariborz Jahanianf08bf1f2009-09-16 23:52:53 +000038 w = badIdea;
39 x = &badIdea;
40 y = &x;
Fariborz Jahanian2db213d2009-09-16 23:49:04 +000041}
42@end
43
44typedef struct {
45 int junk;
46 id alfred;
47} AStruct;
48
49void funct2(AStruct *aptr) {
50 id **ppptr = somefunc();
Fariborz Jahanianf08bf1f2009-09-16 23:52:53 +000051 aptr->alfred = 0;
52 **ppptr = aptr->alfred;
53 *ppptr = somefunc2();
Fariborz Jahanian2db213d2009-09-16 23:49:04 +000054}
55
Fariborz Jahanian1c1afc42009-09-18 00:04:00 +000056typedef 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