[cfe-commits] r72225 - in /cfe/trunk: lib/Sema/SemaExprObjC.cpp test/SemaObjC/nsobject-attribute-1.m
Fariborz Jahanian
fjahanian at apple.com
Thu May 21 14:04:29 PDT 2009
Author: fjahanian
Date: Thu May 21 16:04:28 2009
New Revision: 72225
URL: http://llvm.org/viewvc/llvm-project?rev=72225&view=rev
Log:
Fixed a warning bug when receiver is an object via
setting of NSObject attribute.
Added:
cfe/trunk/test/SemaObjC/nsobject-attribute-1.m
Modified:
cfe/trunk/lib/Sema/SemaExprObjC.cpp
Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=72225&r1=72224&r2=72225&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Thu May 21 16:04:28 2009
@@ -506,7 +506,8 @@
// Handle messages to id.
if (ReceiverCType == Context.getCanonicalType(Context.getObjCIdType()) ||
- ReceiverCType->isBlockPointerType()) {
+ ReceiverCType->isBlockPointerType() ||
+ Context.isObjCNSObjectType(RExpr->getType())) {
ObjCMethodDecl *Method = LookupInstanceMethodInGlobalPool(
Sel, SourceRange(lbrac,rbrac));
if (!Method)
Added: cfe/trunk/test/SemaObjC/nsobject-attribute-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/nsobject-attribute-1.m?rev=72225&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjC/nsobject-attribute-1.m (added)
+++ cfe/trunk/test/SemaObjC/nsobject-attribute-1.m Thu May 21 16:04:28 2009
@@ -0,0 +1,48 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+ at interface NSObject
+- (id)self;
+- (id)copy;
+ at end
+
+typedef struct _foo *__attribute__((NSObject)) Foo_ref;
+
+ at interface TestObject {
+ Foo_ref dict;
+}
+ at property(retain) Foo_ref dict;
+ at end
+
+ at implementation TestObject
+ at synthesize dict;
+ at end
+
+ at interface NSDictionary
+- (int)retainCount;
+ at end
+
+int main(int argc, char *argv[]) {
+ NSDictionary *dictRef;
+ Foo_ref foo = (Foo_ref)dictRef;
+
+ // do Properties retain?
+ int before = [dictRef retainCount];
+ int after = [dictRef retainCount];
+
+ if ([foo retainCount] != [dictRef retainCount]) {
+ }
+
+ // do Blocks retain?
+ {
+ void (^block)(void) = ^{
+ [foo self];
+ };
+ before = [foo retainCount];
+ id save = [block copy];
+ after = [foo retainCount];
+ if (after <= before) {
+ ;
+ }
+ }
+ return 0;
+}
More information about the cfe-commits
mailing list