summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2008-12-09 22:43:22 +0000
committerFariborz Jahanian <fjahanian@apple.com>2008-12-09 22:43:22 +0000
commitea831ee11ca47817dc3436ddd8ae59e99d0488ba (patch)
tree699578efaf34b5b7b823c1fffad91d935f39a2cd
parentdb8ec2d75a90ef7f0b8ab8b0e5bc78075c4dbe5c (diff)
downloadbcm5719-llvm-ea831ee11ca47817dc3436ddd8ae59e99d0488ba.tar.gz
bcm5719-llvm-ea831ee11ca47817dc3436ddd8ae59e99d0488ba.zip
Prevent bogus warning on unimplemented setter/getter when user
has added declaration of these methods in its @interface. llvm-svn: 60803
-rw-r--r--clang/include/clang/AST/DeclObjC.h1
-rw-r--r--clang/lib/AST/DeclObjC.cpp8
-rw-r--r--clang/test/SemaObjC/property-redundant-decl-accessor.m18
3 files changed, 27 insertions, 0 deletions
diff --git a/clang/include/clang/AST/DeclObjC.h b/clang/include/clang/AST/DeclObjC.h
index ba415f90df8..81f8f611207 100644
--- a/clang/include/clang/AST/DeclObjC.h
+++ b/clang/include/clang/AST/DeclObjC.h
@@ -225,6 +225,7 @@ public:
bool isVariadic() const { return IsVariadic; }
bool isSynthesized() const { return IsSynthesized; }
+ void setIsSynthesized() { IsSynthesized = true; }
// Related to protocols declared in @protocol
void setDeclImplementation(ImplementationControl ic) {
diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp
index 1b098b5f894..84f0d98bf2e 100644
--- a/clang/lib/AST/DeclObjC.cpp
+++ b/clang/lib/AST/DeclObjC.cpp
@@ -456,6 +456,10 @@ addPropertyMethods(Decl *D,
insMethods.push_back(GetterDecl);
InsMap[property->getGetterName()] = GetterDecl;
}
+ else
+ // A user declared getter will be synthesize when @synthesize of
+ // the property with the same name is seen in the @implementation
+ GetterDecl->setIsSynthesized();
property->setGetterMethodDecl(GetterDecl);
// Skip setter if property is read-only.
@@ -487,6 +491,10 @@ addPropertyMethods(Decl *D,
0, 0);
SetterDecl->setMethodParams(&Argument, 1);
}
+ else
+ // A user declared setter will be synthesize when @synthesize of
+ // the property with the same name is seen in the @implementation
+ SetterDecl->setIsSynthesized();
property->setSetterMethodDecl(SetterDecl);
}
diff --git a/clang/test/SemaObjC/property-redundant-decl-accessor.m b/clang/test/SemaObjC/property-redundant-decl-accessor.m
new file mode 100644
index 00000000000..8817787ddbe
--- /dev/null
+++ b/clang/test/SemaObjC/property-redundant-decl-accessor.m
@@ -0,0 +1,18 @@
+// RUN: clang -fsyntax-only -Werror -verify %s
+
+@interface MyClass {
+ const char *_myName;
+}
+
+@property const char *myName;
+
+- (const char *)myName;
+- (void)setMyName:(const char *)name;
+
+@end
+
+@implementation MyClass
+
+@synthesize myName = _myName;
+
+@end
OpenPOWER on IntegriCloud