]> granicus.if.org Git - clang/commitdiff
Fix <rdar://problem/6253149> property declaration doesn't declare getter and setter.
authorSteve Naroff <snaroff@apple.com>
Mon, 29 Sep 2008 14:20:56 +0000 (14:20 +0000)
committerSteve Naroff <snaroff@apple.com>
Mon, 29 Sep 2008 14:20:56 +0000 (14:20 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56785 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 024165502658938898526fe75799801d011ef182..4e05a137a507dcbdae055c4a966ada19619a6430 100644 (file)
@@ -874,6 +874,9 @@ void Sema::ActOnAtEnd(SourceLocation AtEndLoc, DeclTy *classDecl,
       }
     }
   }
+  // Save the size so we can detect if we've added any property methods.
+  unsigned int insMethodsSizePriorToPropAdds = insMethods.size();
+  unsigned int clsMethodsSizePriorToPropAdds = clsMethods.size();
   
   if (ObjCInterfaceDecl *I = dyn_cast<ObjCInterfaceDecl>(ClassDecl)) {
     // Compares properties declared in this class to those of its 
@@ -925,6 +928,24 @@ void Sema::ActOnAtEnd(SourceLocation AtEndLoc, DeclTy *classDecl,
       }
     }
   }
+  // Add any synthesized methods to the global pool. This allows us to 
+  // handle the following, which is supported by GCC (and part of the design).
+  //
+  // @interface Foo
+  // @property double bar;
+  // @end
+  //
+  // void thisIsUnfortunate() {
+  //   id foo;
+  //   double bar = [foo bar];
+  // }
+  //
+  if (insMethodsSizePriorToPropAdds < insMethods.size())
+    for (unsigned i = insMethodsSizePriorToPropAdds; i < insMethods.size(); i++)
+      AddInstanceMethodToGlobalPool(insMethods[i]);     
+  if (clsMethodsSizePriorToPropAdds < clsMethods.size())
+    for (unsigned i = clsMethodsSizePriorToPropAdds; i < clsMethods.size(); i++)
+      AddFactoryMethodToGlobalPool(clsMethods[i]);     
 }
 
 
index 2641105162301dd5ac94fe95482777259ac06441..6d13a7b8c6a9ef002407d3934a12d812b5af811f 100644 (file)
 @dynamic d;            // expected-error {{property implementation in a category with no category declaration}}
 @end
 
+@interface Foo
+@property double bar;
+@end
 
+int main() {
+   id foo;
+   double bar = [foo bar];
+   return 0;
+}