diff options
author | Steve Naroff <snaroff@apple.com> | 2008-09-18 16:44:58 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2008-09-18 16:44:58 +0000 |
commit | 9eae5761c0691c0f11d7a823b8ee54f05786cbbe (patch) | |
tree | 9be72b3382a492cf9bb122ba84e53ce478ead81a /lib/Sema/SemaDeclAttr.cpp | |
parent | 13188956909438cdbdac835860428578cc1aba78 (diff) |
Finish pushing blocks attribute through the clang attribute machinery.
Also added a couple simple tests from the "gcc.apple" test suite.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56309 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDeclAttr.cpp')
-rw-r--r-- | lib/Sema/SemaDeclAttr.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index b5737d8b3c..c014e35569 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -509,6 +509,34 @@ static void HandleObjCGCAttr(Decl *d, const AttributeList &Attr, Sema &S) { d->addAttr(new ObjCGCAttr(type)); } +static void HandleBlocksAttr(Decl *d, const AttributeList &Attr, Sema &S) { + if (!Attr.getParameterName()) { + S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_not_string, + "blocks", std::string("1")); + return; + } + + if (Attr.getNumArgs() != 0) { + S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments, + std::string("1")); + return; + } + const char *TypeStr = Attr.getParameterName()->getName(); + unsigned TypeLen = Attr.getParameterName()->getLength(); + + BlocksAttr::BlocksAttrTypes type; + + if (TypeLen == 5 && !memcmp(TypeStr, "byref", 5)) + type = BlocksAttr::ByRef; + else { + S.Diag(Attr.getLoc(), diag::warn_attribute_type_not_supported, + "blocks", TypeStr); + return; + } + + d->addAttr(new BlocksAttr(type)); +} + static void HandleWeakAttr(Decl *d, const AttributeList &Attr, Sema &S) { // check the attribute arguments. if (Attr.getNumArgs() != 0) { @@ -968,6 +996,7 @@ static void ProcessDeclAttribute(Decl *D, const AttributeList &Attr, Sema &S) { HandleTransparentUnionAttr(D, Attr, S); break; case AttributeList::AT_objc_gc: HandleObjCGCAttr (D, Attr, S); break; + case AttributeList::AT_blocks: HandleBlocksAttr (D, Attr, S); break; default: #if 0 // TODO: when we have the full set of attributes, warn about unknown ones. |