xref: /minix3/external/bsd/llvm/dist/clang/test/SemaObjC/no-ivar-access-control.m (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -fsyntax-only -fdebugger-support -verify -Wno-objc-root-class %s
2*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -x objective-c++ -fdebugger-support -fsyntax-only -verify -Wno-objc-root-class %s
3*f4a2713aSLionel Sambuc// expected-no-diagnostics
4*f4a2713aSLionel Sambuc// rdar://10997647
5*f4a2713aSLionel Sambuc
6*f4a2713aSLionel Sambuc@interface I
7*f4a2713aSLionel Sambuc{
8*f4a2713aSLionel Sambuc@private
9*f4a2713aSLionel Sambucint ivar;
10*f4a2713aSLionel Sambuc}
11*f4a2713aSLionel Sambuc@end
12*f4a2713aSLionel Sambuc
13*f4a2713aSLionel Sambuc@implementation I
14*f4a2713aSLionel Sambuc- (int) meth {
15*f4a2713aSLionel Sambuc  return self->ivar;
16*f4a2713aSLionel Sambuc}
17*f4a2713aSLionel Sambucint foo1(I* p) {
18*f4a2713aSLionel Sambuc  return p->ivar;
19*f4a2713aSLionel Sambuc}
20*f4a2713aSLionel Sambuc@end
21*f4a2713aSLionel Sambuc
22*f4a2713aSLionel Sambucint foo(I* p) {
23*f4a2713aSLionel Sambuc  return p->ivar;
24*f4a2713aSLionel Sambuc}
25*f4a2713aSLionel Sambuc
26*f4a2713aSLionel Sambuc@interface B
27*f4a2713aSLionel Sambuc@end
28*f4a2713aSLionel Sambuc
29*f4a2713aSLionel Sambuc@implementation B
30*f4a2713aSLionel Sambuc- (int) meth : (I*) arg {
31*f4a2713aSLionel Sambuc  return arg->ivar;
32*f4a2713aSLionel Sambuc}
33*f4a2713aSLionel Sambuc@end
34*f4a2713aSLionel Sambuc
35*f4a2713aSLionel Sambuc
36*f4a2713aSLionel Sambuc@interface I1 {
37*f4a2713aSLionel Sambuc int protected_ivar;
38*f4a2713aSLionel Sambuc}
39*f4a2713aSLionel Sambuc@property int PROP_INMAIN;
40*f4a2713aSLionel Sambuc@end
41*f4a2713aSLionel Sambuc
42*f4a2713aSLionel Sambuc@interface I1() {
43*f4a2713aSLionel Sambuc int private_ivar;
44*f4a2713aSLionel Sambuc}
45*f4a2713aSLionel Sambuc@property int PROP_INCLASSEXT;
46*f4a2713aSLionel Sambuc@end
47*f4a2713aSLionel Sambuc
48*f4a2713aSLionel Sambuc@implementation I1
49*f4a2713aSLionel Sambuc@synthesize PROP_INMAIN, PROP_INCLASSEXT;
50*f4a2713aSLionel Sambuc
51*f4a2713aSLionel Sambuc- (int) Meth {
52*f4a2713aSLionel Sambuc   PROP_INMAIN = 1;
53*f4a2713aSLionel Sambuc   PROP_INCLASSEXT = 2;
54*f4a2713aSLionel Sambuc   protected_ivar = 1;  // OK
55*f4a2713aSLionel Sambuc   return private_ivar; // OK
56*f4a2713aSLionel Sambuc}
57*f4a2713aSLionel Sambuc@end
58*f4a2713aSLionel Sambuc
59*f4a2713aSLionel Sambuc
60*f4a2713aSLionel Sambuc@interface DER : I1
61*f4a2713aSLionel Sambuc@end
62*f4a2713aSLionel Sambuc
63*f4a2713aSLionel Sambuc@implementation DER
64*f4a2713aSLionel Sambuc- (int) Meth {
65*f4a2713aSLionel Sambuc   protected_ivar = 1;  // OK
66*f4a2713aSLionel Sambuc   PROP_INMAIN = 1;
67*f4a2713aSLionel Sambuc   PROP_INCLASSEXT = 2;
68*f4a2713aSLionel Sambuc   return private_ivar;
69*f4a2713aSLionel Sambuc}
70*f4a2713aSLionel Sambuc@end
71*f4a2713aSLionel Sambuc
72