summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Sema/SemaDeclAttr.cpp9
-rw-r--r--clang/test/SemaObjC/nsobject-attribute.m3
2 files changed, 10 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index f0fcd6e91c2..4f3b03f6e51 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -1794,8 +1794,15 @@ static void handleObjCNSObject(Sema &S, Decl *D, const AttributeList &Attr) {
return;
}
}
- else
+ else if (!isa<ObjCPropertyDecl>(D)) {
+ // It is okay to include this attribute on properties, e.g.:
+ //
+ // @property (retain, nonatomic) struct Bork *Q __attribute__((NSObject));
+ //
+ // In this case it follows tradition and suppresses an error in the above
+ // case.
S.Diag(D->getLocation(), diag::warn_nsobject_attribute);
+ }
D->addAttr(::new (S.Context) ObjCNSObjectAttr(Attr.getRange(), S.Context));
}
diff --git a/clang/test/SemaObjC/nsobject-attribute.m b/clang/test/SemaObjC/nsobject-attribute.m
index 46e84d207cb..bbeb31a8596 100644
--- a/clang/test/SemaObjC/nsobject-attribute.m
+++ b/clang/test/SemaObjC/nsobject-attribute.m
@@ -45,7 +45,8 @@ int main(int argc, char *argv[]) {
{
__attribute__((NSObject)) void * color; // expected-warning {{__attribute ((NSObject)) may be put on a typedef only, attribute is ignored}}
}
-@property (nonatomic, retain) __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
@end
void test_10453342() {
char* __attribute__((NSObject)) string2 = 0; // expected-warning {{__attribute ((NSObject)) may be put on a typedef only, attribute is ignored}}
OpenPOWER on IntegriCloud