mirror of https://github.com/microsoft/clang.git
Objective-C: When using super.prop, property should be
looked up the current class's super class. // rdar://13349296 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176832 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
77b72231a0
commit
6fc9e7ad35
|
@ -1561,8 +1561,15 @@ ActOnClassPropertyRefExpr(IdentifierInfo &receiverName,
|
||||||
|
|
||||||
if (ObjCMethodDecl *CurMethod = tryCaptureObjCSelf(receiverNameLoc)) {
|
if (ObjCMethodDecl *CurMethod = tryCaptureObjCSelf(receiverNameLoc)) {
|
||||||
if (CurMethod->isInstanceMethod()) {
|
if (CurMethod->isInstanceMethod()) {
|
||||||
QualType T =
|
ObjCInterfaceDecl *Super =
|
||||||
Context.getObjCInterfaceType(CurMethod->getClassInterface());
|
CurMethod->getClassInterface()->getSuperClass();
|
||||||
|
if (!Super) {
|
||||||
|
// The current class does not have a superclass.
|
||||||
|
Diag(receiverNameLoc, diag::error_root_class_cannot_use_super)
|
||||||
|
<< CurMethod->getClassInterface()->getIdentifier();
|
||||||
|
return ExprError();
|
||||||
|
}
|
||||||
|
QualType T = Context.getObjCInterfaceType(Super);
|
||||||
T = Context.getObjCObjectPointerType(T);
|
T = Context.getObjCObjectPointerType(T);
|
||||||
|
|
||||||
return HandleExprPropertyRefExpr(T->getAsObjCInterfacePointerType(),
|
return HandleExprPropertyRefExpr(T->getAsObjCInterfacePointerType(),
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
@class B;
|
@class B;
|
||||||
|
|
||||||
@interface Root
|
@interface Root
|
||||||
|
@property(readonly) int p0;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface A : Root <P1> {
|
@interface A : Root <P1> {
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
// RUN: %clang_cc1 -fsyntax-only -fobjc-default-synthesize-properties -verify %s
|
||||||
// expected-no-diagnostics
|
|
||||||
|
|
||||||
@interface B
|
@interface B
|
||||||
+(int) classGetter;
|
+(int) classGetter;
|
||||||
|
@ -29,3 +28,25 @@ void f0() {
|
||||||
int l2 = [A classGetter2];
|
int l2 = [A classGetter2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// rdar://13349296
|
||||||
|
__attribute__((objc_root_class)) @interface ClassBase
|
||||||
|
@property (nonatomic, retain) ClassBase * foo;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation ClassBase
|
||||||
|
- (void) Meth:(ClassBase*)foo {
|
||||||
|
super.foo = foo; // expected-error {{'ClassBase' cannot use 'super' because it is a root class}}
|
||||||
|
[super setFoo:foo]; // expected-error {{'ClassBase' cannot use 'super' because it is a root class}}
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface ClassDerived : ClassBase
|
||||||
|
@property (nonatomic, retain) ClassDerived * foo;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation ClassDerived
|
||||||
|
- (void) Meth:(ClassBase*)foo {
|
||||||
|
super.foo = foo; // issues compile warning
|
||||||
|
[super setFoo:foo]; // works with no warning
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
Loading…
Reference in New Issue