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,
--- /dev/null
+// 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
+