Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Steve Naroff | c70e8d9 | 2009-07-16 00:25:06 +0000 | [diff] [blame] | 2 | |
| 3 | typedef struct objc_object { |
| 4 | struct objc_class *isa; |
| 5 | } *id; |
| 6 | |
Steve Naroff | f242b1b | 2009-07-24 17:54:45 +0000 | [diff] [blame] | 7 | @interface NSObject { |
| 8 | struct objc_class *isa; |
| 9 | } |
| 10 | @end |
| 11 | @interface Whatever : NSObject |
Steve Naroff | c70e8d9 | 2009-07-16 00:25:06 +0000 | [diff] [blame] | 12 | +self; |
| 13 | @end |
| 14 | |
| 15 | static void func() { |
| 16 | |
| 17 | id x; |
| 18 | |
Steve Naroff | f242b1b | 2009-07-24 17:54:45 +0000 | [diff] [blame] | 19 | [(*x).isa self]; |
| 20 | [x->isa self]; |
| 21 | |
| 22 | Whatever *y; |
| 23 | |
| 24 | // GCC allows this, with the following warning: |
NAKAMURA Takumi | ddddd48 | 2011-08-12 05:49:51 +0000 | [diff] [blame] | 25 | // instance variable 'isa' is @protected; this will be a hard error in the future |
Steve Naroff | f242b1b | 2009-07-24 17:54:45 +0000 | [diff] [blame] | 26 | // |
| 27 | // FIXME: see if we can avoid the 2 warnings that follow the error. |
| 28 | [(*y).isa self]; // expected-error {{instance variable 'isa' is protected}} \ |
| 29 | expected-warning{{receiver type 'struct objc_class *' is not 'id' or interface pointer, consider casting it to 'id'}} \ |
| 30 | expected-warning{{method '-self' not found (return type defaults to 'id')}} |
| 31 | [y->isa self]; // expected-error {{instance variable 'isa' is protected}} \ |
| 32 | expected-warning{{receiver type 'struct objc_class *' is not 'id' or interface pointer, consider casting it to 'id'}} \ |
| 33 | expected-warning{{method '-self' not found (return type defaults to 'id')}} |
Steve Naroff | c70e8d9 | 2009-07-16 00:25:06 +0000 | [diff] [blame] | 34 | } |