John McCall | 260611a | 2012-06-20 06:18:46 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -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 |
John McCall | 260611a | 2012-06-20 06:18:46 +0000 | [diff] [blame] | 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 |
Fariborz Jahanian | 27b7aa0 | 2010-05-20 18:22:28 +0000 | [diff] [blame] | 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 |
Fariborz Jahanian | 2db213d | 2009-09-16 23:49:04 +0000 | [diff] [blame] | 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; |
Fariborz Jahanian | f08bf1f | 2009-09-16 23:52:53 +0000 | [diff] [blame] | 20 | W = a; |
| 21 | w = a; |
| 22 | X = b; |
| 23 | x = b; |
| 24 | Y = c; |
| 25 | y = c; |
Fariborz Jahanian | 2db213d | 2009-09-16 23:49:04 +0000 | [diff] [blame] | 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(); |
Fariborz Jahanian | f08bf1f | 2009-09-16 23:52:53 +0000 | [diff] [blame] | 38 | w = badIdea; |
| 39 | x = &badIdea; |
| 40 | y = &x; |
Fariborz Jahanian | 2db213d | 2009-09-16 23:49:04 +0000 | [diff] [blame] | 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(); |
Fariborz Jahanian | f08bf1f | 2009-09-16 23:52:53 +0000 | [diff] [blame] | 51 | aptr->alfred = 0; |
| 52 | **ppptr = aptr->alfred; |
| 53 | *ppptr = somefunc2(); |
Fariborz Jahanian | 2db213d | 2009-09-16 23:49:04 +0000 | [diff] [blame] | 54 | } |
| 55 | |
Fariborz Jahanian | 1c1afc4 | 2009-09-18 00:04:00 +0000 | [diff] [blame] | 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 | |