"local declaration of %0 hides instance variable">;
def error_ivar_use_in_class_method : Error<
"instance variable %0 accessed in class method">;
+def error_implicit_ivar_access : Error<
+ "instance variable %0 cannot be accessed because 'self' has been redeclared">;
def error_private_ivar_access : Error<"instance variable %0 is private">,
AccessControl;
def error_protected_ivar_access : Error<"instance variable %0 is protected">,
return ExprError();
MarkDeclarationReferenced(Loc, IV);
+ Expr *base = SelfExpr.take();
+ base = base->IgnoreParenImpCasts();
+ if (const DeclRefExpr *DE = dyn_cast<DeclRefExpr>(base)) {
+ const NamedDecl *ND = DE->getDecl();
+ if (!isa<ImplicitParamDecl>(ND)) {
+ 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,
SelfExpr.take(), true, true));
--- /dev/null
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-darwin10 -fblocks -fobjc-nonfragile-abi -verify %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -triple x86_64-apple-darwin10 -fblocks -fobjc-nonfragile-abi -verify %s
+// rdar://9154582
+
+@interface Blocky @end
+
+@implementation Blocky {
+ int _a;
+}
+- (void)doAThing {
+ ^{
+ char self; // expected-note {{declared here}}
+ _a; // expected-error {{instance variable '_a' cannot be accessed because 'self' has been redeclared}}
+ }();
+}
+
+@end
+