]> granicus.if.org Git - clang/commitdiff
Patch to remove bogus warning in case of @dynamic
authorFariborz Jahanian <fjahanian@apple.com>
Mon, 22 Dec 2008 19:05:31 +0000 (19:05 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Mon, 22 Dec 2008 19:05:31 +0000 (19:05 +0000)
property in a category and to issue diagnostics
for mismatch method in some other cases.

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

lib/Sema/SemaDeclObjC.cpp
test/SemaObjC/property-1.m
test/SemaObjC/property-category-3.m

index 7759bac681fed1ba18278a9f56b4fdca742144eb..3f86e52e64fd7d5edd668a91f67f143d963c2ea2 100644 (file)
@@ -737,13 +737,16 @@ void Sema::ImplMethodsVsClassMethods(ObjCImplementationDecl* IMPDecl,
        E = IDecl->instmeth_end(); I != E; ++I)
     if (!(*I)->isSynthesized() && !InsMap.count((*I)->getSelector()))
       WarnUndefinedMethod(IMPDecl->getLocation(), *I, IncompleteImpl);
-    else if (!(*I)->isSynthesized()){
+    else {
       ObjCMethodDecl *ImpMethodDecl = 
         IMPDecl->getInstanceMethod((*I)->getSelector());
       ObjCMethodDecl *IntfMethodDecl = 
         IDecl->getInstanceMethod((*I)->getSelector());
-      WarnConflictingTypedMethods(ImpMethodDecl, IntfMethodDecl);
-      
+      assert(IntfMethodDecl && 
+             "IntfMethodDecl is null in ImplMethodsVsClassMethods");
+      // ImpMethodDecl may be null as in a @dynamic property.
+      if (ImpMethodDecl)
+        WarnConflictingTypedMethods(ImpMethodDecl, IntfMethodDecl);
     }
       
   llvm::DenseSet<Selector> ClsMap;
@@ -790,14 +793,18 @@ void Sema::ImplCategoryMethodsVsIntfMethods(ObjCCategoryImplDecl *CatImplDecl,
   bool IncompleteImpl = false;
   for (ObjCCategoryDecl::instmeth_iterator I = CatClassDecl->instmeth_begin(),
        E = CatClassDecl->instmeth_end(); I != E; ++I)
-    if (!InsMap.count((*I)->getSelector()))
+    if (!(*I)->isSynthesized() && !InsMap.count((*I)->getSelector()))
       WarnUndefinedMethod(CatImplDecl->getLocation(), *I, IncompleteImpl);
     else {
       ObjCMethodDecl *ImpMethodDecl = 
         CatImplDecl->getInstanceMethod((*I)->getSelector());
       ObjCMethodDecl *IntfMethodDecl = 
         CatClassDecl->getInstanceMethod((*I)->getSelector());
-      WarnConflictingTypedMethods(ImpMethodDecl, IntfMethodDecl);
+      assert(IntfMethodDecl && 
+             "IntfMethodDecl is null in ImplCategoryMethodsVsIntfMethods");
+      // ImpMethodDecl may be null as in a @dynamic property.
+      if (ImpMethodDecl)        
+        WarnConflictingTypedMethods(ImpMethodDecl, IntfMethodDecl);
     }
 
   llvm::DenseSet<Selector> ClsMap;
index 7e015d01b7489211e64709ff983f976a19c84e95..24c036b55fe1cb4ebd750c73197390383893d2a0 100644 (file)
@@ -22,7 +22,7 @@
 @synthesize name;      // OK! property with same name as an accessible ivar of same name
 @end
 
-@implementation I(CAT)  // expected-warning {{incomplete implementation}}, expected-warning {{method definition for 'd1' not found}}, // expected-warning {{method definition for 'setD1:' not found}} 
+@implementation I(CAT)  
 @synthesize d1;                // expected-error {{@synthesize not allowed in a category's implementation}}
 @dynamic bad;          // expected-error {{property implementation must have its declaration in the category 'CAT'}}
 @end
index d651b855bf4f6fe4cd8bfdda6b2109c41fb89287..e45e0fdda8531c030d824b99500a38421317285d 100644 (file)
 @end
 
 
+@interface A 
+@property(assign) int categoryProperty;
+@end
+
+// Don't issue warning on unimplemented setter/getter
+// because property is @dynamic.
+@implementation A 
+@dynamic categoryProperty;
+@end
+