diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Parse/AttributeList.cpp | 1 | ||||
-rw-r--r-- | lib/Parse/ParseObjc.cpp | 6 | ||||
-rw-r--r-- | lib/Sema/Sema.h | 3 | ||||
-rw-r--r-- | lib/Sema/SemaDeclAttr.cpp | 11 | ||||
-rw-r--r-- | lib/Sema/SemaDeclObjC.cpp | 17 |
5 files changed, 32 insertions, 6 deletions
diff --git a/lib/Parse/AttributeList.cpp b/lib/Parse/AttributeList.cpp index 342c87f1fe..0a418bb9cc 100644 --- a/lib/Parse/AttributeList.cpp +++ b/lib/Parse/AttributeList.cpp @@ -94,6 +94,7 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo *Name) { case 11: if (!memcmp(Str, "vector_size", 11)) return AT_vector_size; if (!memcmp(Str, "constructor", 11)) return AT_constructor; + if (!memcmp(Str, "unavailable", 11)) return AT_unavailable; break; case 13: if (!memcmp(Str, "address_space", 13)) return AT_address_space; diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp index 5f2ebad6db..e70d2024c7 100644 --- a/lib/Parse/ParseObjc.cpp +++ b/lib/Parse/ParseObjc.cpp @@ -936,7 +936,8 @@ Parser::DeclTy *Parser::ParseObjCAtProtocolDeclaration(SourceLocation AtLoc, if (Tok.is(tok::semi)) { // forward declaration of one protocol. IdentifierLocPair ProtoInfo(protocolName, nameLoc); ConsumeToken(); - return Actions.ActOnForwardProtocolDeclaration(AtLoc, &ProtoInfo, 1); + return Actions.ActOnForwardProtocolDeclaration(AtLoc, &ProtoInfo, 1, + attrList); } if (Tok.is(tok::comma)) { // list of forward declarations. @@ -964,7 +965,8 @@ Parser::DeclTy *Parser::ParseObjCAtProtocolDeclaration(SourceLocation AtLoc, return Actions.ActOnForwardProtocolDeclaration(AtLoc, &ProtocolRefs[0], - ProtocolRefs.size()); + ProtocolRefs.size(), + attrList); } // Last, and definitely not least, parse a protocol declaration. diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h index 89d9ebb583..66230314c0 100644 --- a/lib/Sema/Sema.h +++ b/lib/Sema/Sema.h @@ -1063,7 +1063,8 @@ public: virtual DeclTy *ActOnForwardProtocolDeclaration(SourceLocation AtProtocolLoc, const IdentifierLocPair *IdentList, - unsigned NumElts); + unsigned NumElts, + AttributeList *attrList); virtual void FindProtocolDeclaration(bool WarnOnDeclarations, const IdentifierLocPair *ProtocolId, diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index 5c2b49472b..dbeedb10c6 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -501,6 +501,16 @@ static void HandleDeprecatedAttr(Decl *d, const AttributeList &Attr, Sema &S) { d->addAttr(new DeprecatedAttr()); } +static void HandleUnavailableAttr(Decl *d, const AttributeList &Attr, Sema &S) { + // check the attribute arguments. + if (Attr.getNumArgs() != 0) { + S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0; + return; + } + + d->addAttr(new UnavailableAttr()); +} + static void HandleVisibilityAttr(Decl *d, const AttributeList &Attr, Sema &S) { // check the attribute arguments. if (Attr.getNumArgs() != 1) { @@ -1126,6 +1136,7 @@ static void ProcessDeclAttribute(Decl *D, const AttributeList &Attr, Sema &S) { case AttributeList::AT_nothrow: HandleNothrowAttr (D, Attr, S); break; case AttributeList::AT_packed: HandlePackedAttr (D, Attr, S); break; case AttributeList::AT_stdcall: HandleStdCallAttr (D, Attr, S); break; + case AttributeList::AT_unavailable: HandleUnavailableAttr(D, Attr, S); break; case AttributeList::AT_unused: HandleUnusedAttr (D, Attr, S); break; case AttributeList::AT_vector_size: HandleVectorSizeAttr(D, Attr, S); break; case AttributeList::AT_visibility: HandleVisibilityAttr(D, Attr, S); break; diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index 25d1334ab5..b9a63fda26 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -207,7 +207,8 @@ Sema::ActOnStartProtocolInterface(SourceLocation AtProtoInterfaceLoc, PDecl->setForwardDecl(false); ObjCProtocols[ProtocolName] = PDecl; } - + if (AttrList) + ProcessDeclAttributeList(PDecl, AttrList); if (NumProtoRefs) { /// Check then save referenced protocols. PDecl->addReferencedProtocols((ObjCProtocolDecl**)ProtoRefs, NumProtoRefs); @@ -233,6 +234,14 @@ Sema::FindProtocolDeclaration(bool WarnOnDeclarations, << ProtocolId[i].first; continue; } + for (const Attr *attr = PDecl->getAttrs(); attr; attr = attr->getNext()) { + if (attr->hasKind(Attr::Unavailable)) + Diag(ProtocolId[i].second, diag::warn_unavailable) << + PDecl->getDeclName(); + if (attr->hasKind(Attr::Deprecated)) + Diag(ProtocolId[i].second, diag::warn_deprecated) << + PDecl->getDeclName(); + } // If this is a forward declaration and we are supposed to warn in this // case, do it. @@ -417,7 +426,8 @@ Sema::MergeProtocolPropertiesIntoClass(Decl *CDecl, Action::DeclTy * Sema::ActOnForwardProtocolDeclaration(SourceLocation AtProtocolLoc, const IdentifierLocPair *IdentList, - unsigned NumElts) { + unsigned NumElts, + AttributeList *attrList) { llvm::SmallVector<ObjCProtocolDecl*, 32> Protocols; for (unsigned i = 0; i != NumElts; ++i) { @@ -425,7 +435,8 @@ Sema::ActOnForwardProtocolDeclaration(SourceLocation AtProtocolLoc, ObjCProtocolDecl *&PDecl = ObjCProtocols[Ident]; if (PDecl == 0) // Not already seen? PDecl = ObjCProtocolDecl::Create(Context, IdentList[i].second, Ident); - + if (attrList) + ProcessDeclAttributeList(PDecl, attrList); Protocols.push_back(PDecl); } |