view clang/test/SemaObjC/no-ivar-access-control.m @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents 1d019706d866
children
line wrap: on
line source

// RUN: %clang_cc1 -fsyntax-only -fdebugger-support -verify -Wno-objc-root-class %s
// RUN: %clang_cc1 -x objective-c++ -fdebugger-support -fsyntax-only -verify -Wno-objc-root-class %s
// expected-no-diagnostics
// rdar://10997647

@interface I
{
@private
int ivar;
}
@end

@implementation I
- (int) meth {
  return self->ivar;
}
int foo1(I* p) {
  return p->ivar;
}
@end

int foo(I* p) {
  return p->ivar;
}

@interface B 
@end

@implementation B 
- (int) meth : (I*) arg {
  return arg->ivar;
}
@end


@interface I1 {
 int protected_ivar;
}
@property int PROP_INMAIN;
@end

@interface I1() {
 int private_ivar;
}
@property int PROP_INCLASSEXT;
@end

@implementation I1
@synthesize PROP_INMAIN, PROP_INCLASSEXT;

- (int) Meth {
   PROP_INMAIN = 1;
   PROP_INCLASSEXT = 2;
   protected_ivar = 1;  // OK
   return private_ivar; // OK
}
@end


@interface DER : I1
@end

@implementation DER
- (int) Meth {
   protected_ivar = 1;  // OK
   PROP_INMAIN = 1;
   PROP_INCLASSEXT = 2; 
   return private_ivar;
}
@end