forked from OSchip/llvm-project
reverse patch in r139818 to focus on 'self'
instead of 'Class'. llvm-svn: 139834
This commit is contained in:
parent
dff0e892db
commit
d923eb0d1e
|
@ -5227,35 +5227,6 @@ checkBlockPointerTypesForAssignment(Sema &S, QualType LHSType,
|
|||
return ConvTy;
|
||||
}
|
||||
|
||||
static Sema::AssignConvertType
|
||||
checkObjCPointerTypesForAssignment(Sema &S, QualType LHSType,
|
||||
QualType RHSType);
|
||||
/// checkClassTypes - Routine checks for conversion of "Class" type.
|
||||
// Conversion from type Class to any root class type in a class method
|
||||
// is allowed.
|
||||
static Sema::AssignConvertType
|
||||
checkClassTypes(Sema &S, QualType LHSType) {
|
||||
// Conversion from type Class to any root class type is allowed.
|
||||
DeclContext *DC = S.CurContext;
|
||||
while (isa<BlockDecl>(DC))
|
||||
DC = DC->getParent();
|
||||
ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(DC);
|
||||
if (MD && MD->isClassMethod()) {
|
||||
ObjCInterfaceDecl *Root = 0;
|
||||
if (ObjCInterfaceDecl * IDecl = MD->getClassInterface())
|
||||
do
|
||||
Root = IDecl;
|
||||
while ((IDecl = IDecl->getSuperClass()));
|
||||
if (Root){
|
||||
QualType RHSType =
|
||||
S.Context.getObjCObjectPointerType(
|
||||
S.Context.getObjCInterfaceType(Root));
|
||||
return checkObjCPointerTypesForAssignment(S, LHSType, RHSType);
|
||||
}
|
||||
}
|
||||
return Sema::IncompatiblePointer;
|
||||
}
|
||||
|
||||
/// checkObjCPointerTypesForAssignment - Compares two objective-c pointer types
|
||||
/// for assignment compatibility.
|
||||
static Sema::AssignConvertType
|
||||
|
@ -5274,7 +5245,7 @@ checkObjCPointerTypesForAssignment(Sema &S, QualType LHSType,
|
|||
if (RHSType->isObjCBuiltinType()) {
|
||||
if (RHSType->isObjCClassType() && !LHSType->isObjCBuiltinType() &&
|
||||
!LHSType->isObjCQualifiedClassType())
|
||||
return checkClassTypes(S, LHSType);
|
||||
return Sema::IncompatiblePointer;
|
||||
return Sema::Compatible;
|
||||
}
|
||||
QualType lhptee = LHSType->getAs<ObjCObjectPointerType>()->getPointeeType();
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
||||
// rdar://10109725
|
||||
|
||||
@interface NSObject {
|
||||
Class isa;
|
||||
}
|
||||
- (id)addObserver:(NSObject *)observer; // expected-note 2 {{passing argument to parameter 'observer' here}}
|
||||
@end
|
||||
|
||||
@interface MyClass : NSObject {
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation NSObject
|
||||
+ (void)initialize
|
||||
{
|
||||
NSObject *obj = 0;
|
||||
[obj addObserver:self];
|
||||
[obj addObserver:(Class)0];
|
||||
}
|
||||
|
||||
- init
|
||||
{
|
||||
NSObject *obj = 0;
|
||||
[obj addObserver:self];
|
||||
return [obj addObserver:(Class)0]; // expected-warning {{incompatible pointer types sending 'Class' to parameter of type 'NSObject *'}}
|
||||
}
|
||||
- (id)addObserver:(NSObject *)observer { return 0; }
|
||||
@end
|
||||
|
||||
@implementation MyClass
|
||||
|
||||
+ (void)initialize
|
||||
{
|
||||
NSObject *obj = 0;
|
||||
[obj addObserver:self];
|
||||
[obj addObserver:(Class)0];
|
||||
}
|
||||
|
||||
- init
|
||||
{
|
||||
NSObject *obj = 0;
|
||||
[obj addObserver:self];
|
||||
return [obj addObserver:(Class)0]; // expected-warning {{incompatible pointer types sending 'Class' to parameter of type 'NSObject *'}}
|
||||
}
|
||||
@end
|
Loading…
Reference in New Issue