Home | History | Annotate | Download | only in SemaObjC
      1 // RUN: %clang_cc1 -fsyntax-only -verify %s
      2 
      3 typedef struct objc_object {
      4   struct objc_class *isa;
      5 } *id;
      6 
      7 @interface NSObject {
      8   struct objc_class *isa;
      9 }
     10 @end
     11 @interface Whatever : NSObject
     12 +self;
     13 @end
     14 
     15 static void func() {
     16  
     17   id x;
     18 
     19   [(*x).isa self];
     20   [x->isa self];
     21   
     22   Whatever *y;
     23 
     24   // GCC allows this, with the following warning: 
     25   //   instance variable 'isa' is @protected; this will be a hard error in the future
     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')}}
     34 }
     35