aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Sema/SemaExpr.cpp18
-rw-r--r--test/SemaObjC/synth-provisional-ivars.m5
2 files changed, 20 insertions, 3 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index a934adfb0c..1dffa0e64c 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -1005,8 +1005,8 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
}
static ObjCPropertyDecl *OkToSynthesizeProvisionalIvar(Sema &SemaRef,
- IdentifierInfo *II,
- SourceLocation NameLoc) {
+ IdentifierInfo *II,
+ SourceLocation NameLoc) {
ObjCMethodDecl *CurMeth = SemaRef.getCurMethodDecl();
ObjCInterfaceDecl *IDecl = CurMeth->getClassInterface();
if (!IDecl)
@@ -1024,9 +1024,21 @@ static ObjCPropertyDecl *OkToSynthesizeProvisionalIvar(Sema &SemaRef,
}
static ObjCIvarDecl *SynthesizeProvisionalIvar(Sema &SemaRef,
+ LookupResult &Lookup,
IdentifierInfo *II,
SourceLocation NameLoc) {
ObjCMethodDecl *CurMeth = SemaRef.getCurMethodDecl();
+ bool LookForIvars;
+ if (Lookup.empty())
+ LookForIvars = true;
+ else if (CurMeth->isClassMethod())
+ LookForIvars = false;
+ else
+ LookForIvars = (Lookup.isSingleResult() &&
+ Lookup.getFoundDecl()->isDefinedOutsideFunctionOrMethod());
+ if (!LookForIvars)
+ return 0;
+
ObjCInterfaceDecl *IDecl = CurMeth->getClassInterface();
if (!IDecl)
return 0;
@@ -1122,7 +1134,7 @@ Sema::OwningExprResult Sema::ActOnIdExpression(Scope *S,
if (Ex) return Owned(Ex);
// Synthesize ivars lazily
if (getLangOptions().ObjCNonFragileABI2) {
- if (SynthesizeProvisionalIvar(*this, II, NameLoc))
+ if (SynthesizeProvisionalIvar(*this, R, II, NameLoc))
return ActOnIdExpression(S, SS, Id, HasTrailingLParen,
isAddressOfOperand);
}
diff --git a/test/SemaObjC/synth-provisional-ivars.m b/test/SemaObjC/synth-provisional-ivars.m
index 6ed424dae8..973c771ad7 100644
--- a/test/SemaObjC/synth-provisional-ivars.m
+++ b/test/SemaObjC/synth-provisional-ivars.m
@@ -43,3 +43,8 @@ int bar;
- (int) Meth { return PROP1; } // expected-error {{use of undeclared identifier 'PROP1'}}
@end
+@implementation I(r8251648)
+- (int) Meth1: (int) bar {
+ return bar; // expected-warning {{local declaration of 'bar' hides instance variable}}
+}
+@end