From 6fc9e7ad3576dcbee3028a42ef5dac931df8754c Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Mon, 11 Mar 2013 22:26:33 +0000 Subject: 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 --- lib/Sema/SemaExprObjC.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lib/Sema/SemaExprObjC.cpp') diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp index 75f8c48022..b0d5453808 100644 --- a/lib/Sema/SemaExprObjC.cpp +++ b/lib/Sema/SemaExprObjC.cpp @@ -1561,8 +1561,15 @@ ActOnClassPropertyRefExpr(IdentifierInfo &receiverName, if (ObjCMethodDecl *CurMethod = tryCaptureObjCSelf(receiverNameLoc)) { if (CurMethod->isInstanceMethod()) { - QualType T = - Context.getObjCInterfaceType(CurMethod->getClassInterface()); + ObjCInterfaceDecl *Super = + 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); return HandleExprPropertyRefExpr(T->getAsObjCInterfacePointerType(), -- cgit v1.2.3