'self' is objective-c's 'self' objc pointer only in

an objc method. Fixes // rdar://9181463

llvm-svn: 128389
This commit is contained in:
Fariborz Jahanian 2011-03-27 19:53:47 +00:00
parent 8544228d5a
commit b3b1e17645
2 changed files with 26 additions and 0 deletions

View File

@ -324,6 +324,9 @@ bool Sema::CheckMessageArgumentTypes(Expr **Args, unsigned NumArgs,
}
bool Sema::isSelfExpr(Expr *RExpr) {
// 'self' is objc 'self' in an objc method only.
if (!isa<ObjCMethodDecl>(CurContext))
return false;
if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(RExpr))
if (ICE->getCastKind() == CK_LValueToRValue)
RExpr = ICE->getSubExpr();

View File

@ -0,0 +1,23 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// rdar://9181463
typedef struct objc_class *Class;
typedef struct objc_object {
Class isa;
} *id;
@interface NSObject
+ (id) alloc;
@end
void foo(Class self) {
[self alloc];
}
void bar(Class self) {
Class y = self;
[y alloc];
}