]> granicus.if.org Git - clang/commitdiff
Prevent bogus warning on unimplemented setter/getter when user
authorFariborz Jahanian <fjahanian@apple.com>
Tue, 9 Dec 2008 22:43:22 +0000 (22:43 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Tue, 9 Dec 2008 22:43:22 +0000 (22:43 +0000)
has added declaration of these methods in its @interface.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60803 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclObjC.h
lib/AST/DeclObjC.cpp
test/SemaObjC/property-redundant-decl-accessor.m [new file with mode: 0644]

index ba415f90df8a2ea4374adf016938240964c11641..81f8f611207470cc8e65ef4e1be86be175cd45b6 100644 (file)
@@ -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) { 
index 1b098b5f894d80beef72f441aead652a05c422e2..84f0d98bf2ebbade2d1e140879a2d77a03ac5d2d 100644 (file)
@@ -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/test/SemaObjC/property-redundant-decl-accessor.m b/test/SemaObjC/property-redundant-decl-accessor.m
new file mode 100644 (file)
index 0000000..8817787
--- /dev/null
@@ -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