In non-gc, non-arc mode, property of 'Class' type
authorFariborz Jahanian <fjahanian@apple.com>
Wed, 4 Jan 2012 00:31:53 +0000 (00:31 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Wed, 4 Jan 2012 00:31:53 +0000 (00:31 +0000)
variety is treated as a 'void *'. No need to issue
warning reserved for objc object properties.
// rdar://10565506

llvm-svn: 147504

clang/lib/Sema/SemaObjCProperty.cpp
clang/test/SemaObjC/ClassPropertyNotObject.m [new file with mode: 0644]

index a15fc7d..efef7ca 100644 (file)
@@ -1797,6 +1797,14 @@ void Sema::CheckObjCPropertyAttributes(Decl *PDecl,
         // not specified; including when property is 'readonly'.
         PropertyDecl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_strong);
       else if (!(Attributes & ObjCDeclSpec::DQ_PR_readonly)) {
+        bool isAnyClassTy = 
+          (PropertyTy->isObjCClassType() || 
+           PropertyTy->isObjCQualifiedClassType());
+        // In non-gc, non-arc mode, 'Class' is treated as a 'void *' no need to
+        // issue any warning.
+        if (isAnyClassTy && getLangOptions().getGC() == LangOptions::NonGC)
+          ;
+        else {
           // Skip this warning in gc-only mode.
           if (getLangOptions().getGC() != LangOptions::GCOnly)
             Diag(Loc, diag::warn_objc_property_no_assignment_attribute);
@@ -1804,6 +1812,7 @@ void Sema::CheckObjCPropertyAttributes(Decl *PDecl,
           // If non-gc code warn that this is likely inappropriate.
           if (getLangOptions().getGC() == LangOptions::NonGC)
             Diag(Loc, diag::warn_objc_property_default_assign_on_object);
+        }
       }
 
     // FIXME: Implement warning dependent on NSCopying being
diff --git a/clang/test/SemaObjC/ClassPropertyNotObject.m b/clang/test/SemaObjC/ClassPropertyNotObject.m
new file mode 100644 (file)
index 0000000..df2f835
--- /dev/null
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify %s
+// rdar://10565506
+
+@protocol P @end
+
+@interface I
+@property Class<P> MyClass;
+@property Class MyClass1;
+@property void * VOIDSTAR;
+@end
+
+@implementation I
+@synthesize MyClass, MyClass1, VOIDSTAR;
+@end