Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-gc -emit-llvm -o %t %s |
Daniel Dunbar | 4fcfde4 | 2009-11-08 01:45:36 +0000 | [diff] [blame] | 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 |
Fariborz Jahanian | 2db213d | 2009-09-16 23:49:04 +0000 | [diff] [blame] | 5 | |
| 6 | extern id **somefunc(void); |
| 7 | extern id *somefunc2(void); |
| 8 | |
| 9 | |
| 10 | // Globals |
| 11 | |
| 12 | id W, *X, **Y; |
| 13 | |
| 14 | void func(id a, id *b, id **c) { |
| 15 | static id w, *x, **y; |
Fariborz Jahanian | f08bf1f | 2009-09-16 23:52:53 +0000 | [diff] [blame] | 16 | W = a; |
| 17 | w = a; |
| 18 | X = b; |
| 19 | x = b; |
| 20 | Y = c; |
| 21 | y = c; |
Fariborz Jahanian | 2db213d | 2009-09-16 23:49:04 +0000 | [diff] [blame] | 22 | } |
| 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 Jahanian | f08bf1f | 2009-09-16 23:52:53 +0000 | [diff] [blame] | 34 | w = badIdea; |
| 35 | x = &badIdea; |
| 36 | y = &x; |
Fariborz Jahanian | 2db213d | 2009-09-16 23:49:04 +0000 | [diff] [blame] | 37 | } |
| 38 | @end |
| 39 | |
| 40 | typedef struct { |
| 41 | int junk; |
| 42 | id alfred; |
| 43 | } AStruct; |
| 44 | |
| 45 | void funct2(AStruct *aptr) { |
| 46 | id **ppptr = somefunc(); |
Fariborz Jahanian | f08bf1f | 2009-09-16 23:52:53 +0000 | [diff] [blame] | 47 | aptr->alfred = 0; |
| 48 | **ppptr = aptr->alfred; |
| 49 | *ppptr = somefunc2(); |
Fariborz Jahanian | 2db213d | 2009-09-16 23:49:04 +0000 | [diff] [blame] | 50 | } |
| 51 | |
Fariborz Jahanian | 1c1afc4 | 2009-09-18 00:04:00 +0000 | [diff] [blame] | 52 | typedef 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 | |