mirror of
https://github.com/intel/llvm.git
synced 2026-01-26 21:53:12 +08:00
'self' is objective-c's 'self' objc pointer only in
an objc method. Fixes // rdar://9181463 llvm-svn: 128389
This commit is contained in:
@@ -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();
|
||||
|
||||
23
clang/test/SemaObjC/self-in-function.m
Normal file
23
clang/test/SemaObjC/self-in-function.m
Normal 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];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user