Fariborz Jahanian | 2db213d | 2009-09-16 23:49:04 +0000 | [diff] [blame^] | 1 | // RUN: clang-cc -fnext-runtime -fobjc-gc -fobjc-newgc-api -emit-llvm -o %t %s && |
| 2 | // RUN: grep -F '@objc_assign_global' %t | count 7 && |
| 3 | // RUN: grep -F '@objc_assign_ivar' %t | count 4 && |
| 4 | // RUN: grep -F '@objc_assign_strongCast' %t | count 4 && |
| 5 | // RUN: true |
| 6 | |
| 7 | extern id **somefunc(void); |
| 8 | extern id *somefunc2(void); |
| 9 | |
| 10 | |
| 11 | // Globals |
| 12 | |
| 13 | id W, *X, **Y; |
| 14 | |
| 15 | void func(id a, id *b, id **c) { |
| 16 | static id w, *x, **y; |
| 17 | W = a; /* { dg-warning "global\\/static variable assignment" } */ |
| 18 | w = a; /* { dg-warning "global\\/static variable assignment" } */ |
| 19 | X = b; /* { dg-warning "global\\/static variable assignment" } */ |
| 20 | x = b; /* { dg-warning "global\\/static variable assignment" } */ |
| 21 | Y = c; /* { dg-warning "global\\/static variable assignment" } */ |
| 22 | y = c; /* { dg-warning "global\\/static variable assignment" } */ |
| 23 | } |
| 24 | |
| 25 | // Instances |
| 26 | |
| 27 | @interface something { |
| 28 | id w, *x, **y; |
| 29 | } |
| 30 | @end |
| 31 | |
| 32 | @implementation something |
| 33 | - (void)amethod { |
| 34 | id badIdea = *somefunc2(); |
| 35 | w = badIdea; /* { dg-warning "instance variable assignment" } */ |
| 36 | x = &badIdea; /* { dg-warning "instance variable assignment" } */ |
| 37 | y = &x; /* { dg-warning "instance variable assignment" } */ |
| 38 | } |
| 39 | @end |
| 40 | |
| 41 | typedef struct { |
| 42 | int junk; |
| 43 | id alfred; |
| 44 | } AStruct; |
| 45 | |
| 46 | void funct2(AStruct *aptr) { |
| 47 | id **ppptr = somefunc(); |
| 48 | aptr->alfred = 0; /* { dg-warning "strong\\-cast assignment" } */ |
| 49 | **ppptr = aptr->alfred; /* { dg-warning "strong\\-cast assignment" } */ |
| 50 | *ppptr = somefunc2(); /* { dg-warning "strong\\-cast assignment" } */ |
| 51 | } |
| 52 | |