blob: c2debb0bc3c3d149a72e4a010e20c64fdf243f5c [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Steve Naroffc70e8d92009-07-16 00:25:06 +00002
3typedef struct objc_object {
4 struct objc_class *isa;
5} *id;
6
Steve Narofff242b1b2009-07-24 17:54:45 +00007@interface NSObject {
8 struct objc_class *isa;
9}
10@end
11@interface Whatever : NSObject
Steve Naroffc70e8d92009-07-16 00:25:06 +000012+self;
13@end
14
15static void func() {
16
17 id x;
18
Fariborz Jahanian556b1d02012-01-18 19:08:56 +000019 // rdar://8290002
20 [(*x).isa self]; // expected-warning {{direct access to objective-c's isa is deprecated in favor of object_setClass() and object_getClass()}}
21 [x->isa self]; // expected-warning {{direct access to objective-c's isa is deprecated in favor of object_setClass() and object_getClass()}}
Steve Narofff242b1b2009-07-24 17:54:45 +000022
23 Whatever *y;
24
25 // GCC allows this, with the following warning:
NAKAMURA Takumiddddd482011-08-12 05:49:51 +000026 // instance variable 'isa' is @protected; this will be a hard error in the future
Steve Narofff242b1b2009-07-24 17:54:45 +000027 //
28 // FIXME: see if we can avoid the 2 warnings that follow the error.
29 [(*y).isa self]; // expected-error {{instance variable 'isa' is protected}} \
30 expected-warning{{receiver type 'struct objc_class *' is not 'id' or interface pointer, consider casting it to 'id'}} \
31 expected-warning{{method '-self' not found (return type defaults to 'id')}}
32 [y->isa self]; // expected-error {{instance variable 'isa' is protected}} \
33 expected-warning{{receiver type 'struct objc_class *' is not 'id' or interface pointer, consider casting it to 'id'}} \
34 expected-warning{{method '-self' not found (return type defaults to 'id')}}
Steve Naroffc70e8d92009-07-16 00:25:06 +000035}