1// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
2
3@interface SomeClass  @end
4
5int fn1(SomeClass *obj) {
6        obj->privateIvar = 1; // expected-error {{'SomeClass' does not have a member named 'privateIvar}}
7        return obj->publicIvar;     // expected-error {{'SomeClass' does not have a member named 'publicIvar'}}
8}
9
10@interface SomeClass () {
11// @private by default
12        int privateIvar;
13@public
14        int publicIvar;
15}
16@end
17
18int fn2(SomeClass *obj) {
19	obj->publicIvar = 1;
20        return obj->publicIvar    // ok
21             + obj->privateIvar;  // expected-error {{instance variable 'privateIvar' is private}}
22}
23
24@implementation SomeClass
25
26int fn3(SomeClass *obj) {
27	obj->privateIvar = 2;
28        return obj->publicIvar    // ok
29             + obj->privateIvar;  // ok
30    }
31@end
32
33@interface SomeClass (Category)
34    {
35        int categoryIvar; // expected-error {{instance variables may not be placed in categories}}
36    }
37@end
38
39@interface SomeClass (Category1)
40    {
41    }
42@end
43