aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Sema/SemaExpr.cpp7
-rw-r--r--test/SemaObjC/provisional-ivar-lookup.m43
2 files changed, 49 insertions, 1 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index f98aefcd56..50f023abc8 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -1068,9 +1068,14 @@ static ObjCIvarDecl *SynthesizeProvisionalIvar(Sema &SemaRef,
ObjCPropertyDecl *property = SemaRef.LookupPropertyDecl(IDecl, II);
if (!property)
return 0;
- if (ObjCPropertyImplDecl *PIDecl = ClassImpDecl->FindPropertyImplDecl(II))
+ if (ObjCPropertyImplDecl *PIDecl = ClassImpDecl->FindPropertyImplDecl(II)) {
DynamicImplSeen =
(PIDecl->getPropertyImplementation() == ObjCPropertyImplDecl::Dynamic);
+ // property implementation has a designated ivar. No need to assume a new
+ // one.
+ if (!DynamicImplSeen && PIDecl->getPropertyIvarDecl())
+ return 0;
+ }
if (!DynamicImplSeen) {
QualType PropType = SemaRef.Context.getCanonicalType(property->getType());
ObjCIvarDecl *Ivar = ObjCIvarDecl::Create(SemaRef.Context, ClassImpDecl,
diff --git a/test/SemaObjC/provisional-ivar-lookup.m b/test/SemaObjC/provisional-ivar-lookup.m
new file mode 100644
index 0000000000..526748538e
--- /dev/null
+++ b/test/SemaObjC/provisional-ivar-lookup.m
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-nonfragile-abi2 -verify %s
+
+// rdar:// 8565343
+@interface Foo {
+@private
+ int _foo;
+ int _foo2;
+}
+@property (readwrite, nonatomic) int foo, foo1, foo2, foo3;
+@property (readwrite, nonatomic) int PROP;
+@end
+
+@implementation Foo
+
+@synthesize foo = _foo;
+@synthesize foo1;
+
+- (void)setFoo:(int)value {
+ _foo = foo; // expected-error {{use of undeclared identifier 'foo'}}
+}
+
+- (void)setFoo1:(int)value {
+ _foo = foo1; // OK
+}
+
+- (void)setFoo2:(int)value {
+ _foo = foo2; // expected-error {{use of undeclared identifier 'foo2'}}
+}
+
+- (void)setFoo3:(int)value {
+ _foo = foo3; // OK
+}
+
+@synthesize foo2 = _foo2;
+@synthesize foo3;
+
+@synthesize PROP=PROP;
+- (void)setPROP:(int)value {
+ PROP = PROP; // OK
+}
+
+@end
+