diff options
| author | Fariborz Jahanian <fjahanian@apple.com> | 2012-05-31 23:18:32 +0000 |
|---|---|---|
| committer | Fariborz Jahanian <fjahanian@apple.com> | 2012-05-31 23:18:32 +0000 |
| commit | bebd0ba549d9d8b268e124bd98ff3a3fdaea421e (patch) | |
| tree | 9ec4c5b5a42d3fe9e930a7e93f23681eec535511 | |
| parent | 4c0de496a07bff47c174841d422b20b28631b668 (diff) | |
| download | bcm5719-llvm-bebd0ba549d9d8b268e124bd98ff3a3fdaea421e.tar.gz bcm5719-llvm-bebd0ba549d9d8b268e124bd98ff3a3fdaea421e.zip | |
objc: properties of NSObject attribute must
have correct pointer type or issue error,
instead of crashing in IRGen. // rdar:// 11569860
llvm-svn: 157780
| -rw-r--r-- | clang/lib/Sema/SemaDeclAttr.cpp | 10 | ||||
| -rw-r--r-- | clang/test/SemaObjC/nsobject-attribute.m | 12 |
2 files changed, 20 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 4175ec1a26e..c98d2bb9f4d 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -2085,7 +2085,15 @@ static void handleObjCNSObject(Sema &S, Decl *D, const AttributeList &Attr) { return; } } - else if (!isa<ObjCPropertyDecl>(D)) { + else if (ObjCPropertyDecl *PD = dyn_cast<ObjCPropertyDecl>(D)) { + QualType T = PD->getType(); + if (!T->isPointerType() || + !T->getAs<PointerType>()->getPointeeType()->isRecordType()) { + S.Diag(PD->getLocation(), diag::err_nsobject_attribute); + return; + } + } + else { // It is okay to include this attribute on properties, e.g.: // // @property (retain, nonatomic) struct Bork *Q __attribute__((NSObject)); diff --git a/clang/test/SemaObjC/nsobject-attribute.m b/clang/test/SemaObjC/nsobject-attribute.m index f41df893288..e3f28740dc8 100644 --- a/clang/test/SemaObjC/nsobject-attribute.m +++ b/clang/test/SemaObjC/nsobject-attribute.m @@ -46,9 +46,19 @@ int main(int argc, char *argv[]) { __attribute__((NSObject)) void * color; // expected-warning {{__attribute ((NSObject)) may be put on a typedef only, attribute is ignored}} } // <rdar://problem/10930507> -@property (nonatomic, retain) __attribute__((NSObject)) void * color; // // no-warning +@property (nonatomic, retain) __attribute__((NSObject)) CGColorRefNoNSObject color; // // no-warning @end void test_10453342() { char* __attribute__((NSObject)) string2 = 0; // expected-warning {{__attribute ((NSObject)) may be put on a typedef only, attribute is ignored}} } +// rdar://11569860 +@interface A { int i; } +@property(retain) __attribute__((NSObject)) int i; // expected-error {{__attribute ((NSObject)) is for pointer types only}} \ + // expected-error {{property with 'retain (or strong)' attribute must be of object type}} +@end + +@implementation A +@synthesize i; +@end + |

