John McCall | 260611a | 2012-06-20 06:18:46 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp |
Fariborz Jahanian | 5bfc536 | 2010-01-25 20:50:02 +0000 | [diff] [blame] | 2 | // RUN: FileCheck -check-prefix LP --input-file=%t-rw.cpp %s |
| 3 | // radar 7575882 |
| 4 | |
| 5 | @interface F { |
| 6 | int supervar; |
| 7 | } |
| 8 | @end |
| 9 | |
| 10 | @interface G : F { |
| 11 | @public |
| 12 | int ivar; |
| 13 | } |
| 14 | @end |
| 15 | |
| 16 | @implementation G |
| 17 | - (void)foo:(F *)arg { |
| 18 | int q = arg->supervar; |
| 19 | int v = ((G *)arg)->ivar; |
| 20 | } |
| 21 | @end |
| 22 | |
Fariborz Jahanian | a5d5fbc | 2010-01-26 00:29:22 +0000 | [diff] [blame] | 23 | void objc_assign_strongCast(id); |
| 24 | void __CFAssignWithWriteBarrier(void **location, void *value) { |
| 25 | objc_assign_strongCast((id)value); |
| 26 | } |
| 27 | |
Fariborz Jahanian | 2b9b0b2 | 2010-02-05 01:35:00 +0000 | [diff] [blame] | 28 | // radar 7607605 |
| 29 | @interface RealClass { |
| 30 | @public |
| 31 | int f; |
| 32 | } |
| 33 | @end |
| 34 | |
| 35 | @implementation RealClass |
| 36 | @end |
| 37 | |
| 38 | @interface Foo { |
| 39 | id reserved; |
| 40 | } |
| 41 | @end |
| 42 | |
| 43 | @implementation Foo |
| 44 | - (void)bar { |
| 45 | ((RealClass*)reserved)->f = 99; |
| 46 | } |
| 47 | @end |
| 48 | |
Fariborz Jahanian | 5bfc536 | 2010-01-25 20:50:02 +0000 | [diff] [blame] | 49 | // CHECK-LP: ((struct G_IMPL *)arg)->ivar |
| 50 | |
Fariborz Jahanian | a5d5fbc | 2010-01-26 00:29:22 +0000 | [diff] [blame] | 51 | // CHECK-LP: objc_assign_strongCast((id)value) |
Fariborz Jahanian | 2b9b0b2 | 2010-02-05 01:35:00 +0000 | [diff] [blame] | 52 | |
| 53 | // CHECK-LP: ((struct RealClass_IMPL *)((RealClass *)((struct Foo_IMPL *)self)->reserved))->f |