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