aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2011-04-15 17:04:42 +0000
committerFariborz Jahanian <fjahanian@apple.com>2011-04-15 17:04:42 +0000
commiteefa76e29e9f4a6c01e8c1e8d2f1a1d34a98817c (patch)
treebf78a1de55ce273883b8580b97cef06e66e33635 /lib/Sema
parenta391a4642c5eb98aae606f2a2b7219b1a3619d11 (diff)
Allow shadowin of 'self' in objc methods in
cases where stand-alone ivar can be looked up in shadowed object. To fix gcc compatibility breakage. // rdar://9284603 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129576 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema')
-rw-r--r--lib/Sema/SemaExpr.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index d2a3441f4c..9415673a77 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -2089,11 +2089,21 @@ Sema::LookupInObjCMethod(LookupResult &Lookup, Scope *S,
if (const DeclRefExpr *DE = dyn_cast<DeclRefExpr>(base)) {
const NamedDecl *ND = DE->getDecl();
if (!isa<ImplicitParamDecl>(ND)) {
+ // relax the rule such that it is allowed to have a shadow 'self'
+ // where stand-alone ivar can be found in this 'self' object.
+ // This is to match gcc's behavior.
+ ObjCInterfaceDecl *selfIFace = 0;
+ if (const ObjCObjectPointerType *OPT =
+ base->getType()->getAsObjCInterfacePointerType())
+ selfIFace = OPT->getInterfaceDecl();
+ if (!selfIFace ||
+ !selfIFace->lookupInstanceVariable(IV->getIdentifier())) {
Diag(Loc, diag::error_implicit_ivar_access)
<< IV->getDeclName();
Diag(ND->getLocation(), diag::note_declared_at);
return ExprError();
}
+ }
}
return Owned(new (Context)
ObjCIvarRefExpr(IV, IV->getType(), Loc,