blob: dfc0a5b9fdac8938558abe9f7618b32fdf79b42e [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
Steve Narofff242b1b2009-07-24 17:54:45 +000019 [(*x).isa self];
20 [x->isa self];
21
22 Whatever *y;
23
24 // GCC allows this, with the following warning:
NAKAMURA Takumiddddd482011-08-12 05:49:51 +000025 // instance variable 'isa' is @protected; this will be a hard error in the future
Steve Narofff242b1b2009-07-24 17:54:45 +000026 //
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 Naroffc70e8d92009-07-16 00:25:06 +000034}