diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2011-12-20 22:21:08 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2011-12-20 22:21:08 +0000 |
commit | b5ea9db3cf47e8d4bc60d922331773dbfd265c6f (patch) | |
tree | 9c701cf3f72213d2fb9dcd88d9ac58578edc69c2 /lib/Sema/SemaExpr.cpp | |
parent | 1d4c1137c314cfb9ced32006cacdb80deffb66d4 (diff) |
objc/c++: Issue diagnostic when free-standing ivar is accessed
in class method instead of crash. // rdar://10593227
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146998 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 62ee9f554d..65439032f2 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -2010,6 +2010,12 @@ Sema::LookupInObjCMethod(LookupResult &Lookup, Scope *S, Diag(Loc, diag::warn_ivar_use_hidden) << IV->getDeclName(); } } + } else if (Lookup.isSingleResult() && + Lookup.getFoundDecl()->isDefinedOutsideFunctionOrMethod()) { + // If accessing a stand-alone ivar in a class method, this is an error. + if (const ObjCIvarDecl *IV = dyn_cast<ObjCIvarDecl>(Lookup.getFoundDecl())) + return ExprError(Diag(Loc, diag::error_ivar_use_in_class_method) + << IV->getDeclName()); } if (Lookup.empty() && II && AllowBuiltinCreation) { |