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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
@interface MySuperClass
{
int unmarked;
@private
int private;
@protected
int protected;
@public
int public;
}
@end
@implementation MySuperClass
- (void) test {
int access;
MySuperClass *s = 0;
access = s->unmarked;
access = s->private;
access = s->protected;
}
@end
@interface MyClass : MySuperClass
@end
@implementation MyClass
- (void) test {
int access;
MySuperClass *s = 0;
access = s->unmarked;
access = s->private; // expected-error {{instance variable 'private' is private}}
access = s->protected;
MyClass *m=0;
access = m->unmarked;
access = m->private; // expected-error {{instance variable 'private' is private}}
access = m->protected;
}
@end
@interface Deeper : MyClass
@end
@implementation Deeper
- (void) test {
int access;
MySuperClass *s = 0;
access = s->unmarked;
access = s->private; // expected-error {{instance variable 'private' is private}}
access = s->protected;
MyClass *m=0;
access = m->unmarked;
access = m->private; // expected-error {{instance variable 'private' is private}}
access = m->protected;
}
@end
@interface Unrelated
@end
@implementation Unrelated
- (void) test {
int access;
MySuperClass *s = 0;
access = s->unmarked; // expected-error {{instance variable 'unmarked' is protected}}
access = s->private; // expected-error {{instance variable 'private' is private}}
access = s->protected; // expected-error {{instance variable 'protected' is protected}}
MyClass *m=0;
access = m->unmarked; // expected-error {{instance variable 'unmarked' is protected}}
access = m->private; // expected-error {{instance variable 'private' is private}}
access = m->protected; // expected-error {{instance variable 'protected' is protected}}
}
@end
int main (void)
{
MySuperClass *s = 0;
int access;
access = s->unmarked; // expected-error {{instance variable 'unmarked' is protected}}
access = s->private; // expected-error {{instance variable 'private' is private}}
access = s->protected; // expected-error {{instance variable 'protected' is protected}}
return 0;
}
typedef signed char BOOL;
typedef unsigned int NSUInteger;
typedef struct _NSZone NSZone;
@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
@protocol NSObject - (BOOL)isEqual:(id)object;
@end
@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder;
@end
@interface NSObject <NSObject> {}
@end
extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
@interface NSResponder : NSObject <NSCoding> {}
@end
@protocol NSAnimatablePropertyContainer
- (id)animator;
@end
extern NSString *NSAnimationTriggerOrderIn ;
@interface NSView : NSResponder <NSAnimatablePropertyContainer> {
struct __VFlags2 {
}
_vFlags2;
}
@end
@class NSFontDescriptor, NSAffineTransform, NSGraphicsContext;
@interface NSScrollView : NSView {}
@end
@class CasperMixerView;
@interface CasperDiffScrollView : NSScrollView {
@private
CasperMixerView *_comparatorView;
NSView *someField;
}
@end
@implementation CasperDiffScrollView
+ (void)initialize {}
static void _CasperDiffScrollViewInstallMixerView(CasperDiffScrollView *scrollView) {
if (scrollView->someField != ((void *)0)) {
}
}
@end
|