forked from OSchip/llvm-project
Fix <rdar://problem/6333904> [sema] message lookup on super is incorrect
Missing special lookup rule in Sema::ActOnInstanceMessage(). llvm-svn: 59467
This commit is contained in:
parent
aa3d68d301
commit
773cdc7c0d
|
@ -278,7 +278,23 @@ Sema::ExprResult Sema::ActOnInstanceMessage(ExprTy *receiver, Selector Sel,
|
|||
|
||||
QualType ReceiverCType =
|
||||
Context.getCanonicalType(RExpr->getType()).getUnqualifiedType();
|
||||
|
||||
|
||||
// Handle messages to 'super'.
|
||||
if (isa<ObjCSuperExpr>(RExpr)) {
|
||||
ObjCMethodDecl *Method = 0;
|
||||
if (ObjCMethodDecl *CurMeth = getCurMethodDecl()) {
|
||||
// If we have an interface in scope, check 'super' methods.
|
||||
if (ObjCInterfaceDecl *ClassDecl = CurMeth->getClassInterface())
|
||||
if (ObjCInterfaceDecl *SuperDecl = ClassDecl->getSuperClass())
|
||||
Method = SuperDecl->lookupInstanceMethod(Sel);
|
||||
}
|
||||
if (CheckMessageArgumentTypes(ArgExprs, NumArgs, Sel, Method, "-",
|
||||
lbrac, rbrac, returnType))
|
||||
return true;
|
||||
return new ObjCMessageExpr(RExpr, Sel, returnType, Method, lbrac, rbrac,
|
||||
ArgExprs, NumArgs);
|
||||
}
|
||||
|
||||
// Handle messages to id.
|
||||
if (ReceiverCType == Context.getCanonicalType(Context.getObjCIdType()) ||
|
||||
ReceiverCType->getAsBlockPointerType()) {
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
@interface NSObject
|
||||
- (void)release;
|
||||
- dealloc;
|
||||
@end
|
||||
|
||||
@interface MyClass : NSObject {
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
// RUN: clang -fsyntax-only -verify %s
|
||||
|
||||
@interface Foo
|
||||
- iMethod;
|
||||
+ cMethod;
|
||||
@end
|
||||
|
||||
@interface A
|
||||
@end
|
||||
|
||||
@interface B : A
|
||||
- (void)instanceMethod;
|
||||
+ classMethod;
|
||||
@end
|
||||
|
||||
@implementation B
|
||||
|
||||
- (void)instanceMethod {
|
||||
[super iMethod]; // expected-warning{{method '-iMethod' not found (return type defaults to 'id')}}
|
||||
}
|
||||
|
||||
+ classMethod {
|
||||
[super cMethod]; // expected-warning{{method '+cMethod' not found (return type defaults to 'id')}}
|
||||
}
|
||||
@end
|
Loading…
Reference in New Issue