summaryrefslogtreecommitdiffstats
path: root/test/SemaObjC/id-isa-ref.m
blob: a75f2f336751283e945b7b455efd3c2fc7f3b968 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// RUN: %clang_cc1 -fsyntax-only -verify %s

typedef struct objc_object {
  struct objc_class *isa;
} *id;

@interface NSObject {
  struct objc_class *isa;
}
@end
@interface Whatever : NSObject
+self;
@end

static void func() {
 
  id x;

  [(*x).isa self];
  [x->isa self];
  
  Whatever *y;

  // GCC allows this, with the following warning: 
  //   instance variable ‘isa’ is @protected; this will be a hard error in the future
  //
  // FIXME: see if we can avoid the 2 warnings that follow the error.
  [(*y).isa self]; // expected-error {{instance variable 'isa' is protected}} \
                      expected-warning{{receiver type 'struct objc_class *' is not 'id' or interface pointer, consider casting it to 'id'}} \
                      expected-warning{{method '-self' not found (return type defaults to 'id')}}
  [y->isa self]; // expected-error {{instance variable 'isa' is protected}} \
                    expected-warning{{receiver type 'struct objc_class *' is not 'id' or interface pointer, consider casting it to 'id'}} \
                    expected-warning{{method '-self' not found (return type defaults to 'id')}}
}
OpenPOWER on IntegriCloud