From: Fariborz Jahanian Date: Mon, 17 Sep 2012 23:57:35 +0000 (+0000) Subject: objective-C: don't warn about class extension property's X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f224fb5de15e10cecd2d87fee73b0e39b503d924;p=clang objective-C: don't warn about class extension property's missing 'assign' attribute as it is determined by its overridden property in primary class. // rdar://12214070 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164080 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp index 131c48f012..0f6ae4c7c7 100644 --- a/lib/Sema/SemaObjCProperty.cpp +++ b/lib/Sema/SemaObjCProperty.cpp @@ -2159,7 +2159,9 @@ void Sema::CheckObjCPropertyAttributes(Decl *PDecl, // issue any warning. if (isAnyClassTy && getLangOpts().getGC() == LangOptions::NonGC) ; - else { + else if (propertyInPrimaryClass) { + // Don't issue warning on property with no life time in class + // extension as it is inherited from property in primary class. // Skip this warning in gc-only mode. if (getLangOpts().getGC() != LangOptions::GCOnly) Diag(Loc, diag::warn_objc_property_no_assignment_attribute); diff --git a/test/SemaObjC/property-in-class-extension-1.m b/test/SemaObjC/property-in-class-extension-1.m index 18eae24cc1..ab461ef6c1 100644 --- a/test/SemaObjC/property-in-class-extension-1.m +++ b/test/SemaObjC/property-in-class-extension-1.m @@ -35,17 +35,13 @@ @property (nonatomic, copy) NSString* addingMemoryModel; @property (nonatomic, copy) NSString* matchingMemoryModel; -@property () NSString* addingNoNewMemoryModel; // expected-warning {{no 'assign', 'retain', or 'copy' attribute is specified - 'assign' is assumed}} \ - // expected-warning {{default property attribute 'assign' not appropriate for non-GC object}} -@property () NSString* none; // expected-warning {{no 'assign', 'retain', or 'copy' attribute is specified - 'assign' is assumed}} \ - // expected-warning {{default property attribute 'assign' not appropriate for non-GC object}} +@property () NSString* addingNoNewMemoryModel; +@property () NSString* none; @property (readwrite, retain) NSString* none1; @property (retain) NSString* changeMemoryModel; // expected-warning {{property attribute in class extension does not match the primary class}} -@property () __weak id weak_prop; // expected-warning {{no 'assign', 'retain', or 'copy' attribute is specified - 'assign' is assumed}} \ - // expected-warning {{default property attribute 'assign' not appropriate for non-GC object}} -@property (readwrite) __weak id weak_prop1; // expected-warning {{no 'assign', 'retain', or 'copy' attribute is specified - 'assign' is assumed}}\ - // expected-warning {{default property attribute 'assign' not appropriate for non-GC object}} +@property () __weak id weak_prop; +@property (readwrite) __weak id weak_prop1; @property (assign, readwrite) NSString* assignProperty; @property (assign) NSString* readonlyProp;