diff options
author | Ted Kremenek <kremenek@apple.com> | 2010-04-18 04:59:38 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2010-04-18 04:59:38 +0000 |
commit | 36712b2ac198fa3615155ce6b9c460cd2f8acfab (patch) | |
tree | 027c26fee1f7bd2d1445d81fbf41b4233db9ce32 | |
parent | a50738abba3c0e1c4f0eec06686c3d226f014a2f (diff) | |
download | bcm5719-llvm-36712b2ac198fa3615155ce6b9c460cd2f8acfab.tar.gz bcm5719-llvm-36712b2ac198fa3615155ce6b9c460cd2f8acfab.zip |
Allow the 'ibaction' attribute to be attached to method declarations (and not issue a warning).
llvm-svn: 101699
-rw-r--r-- | clang/lib/Sema/SemaDeclObjC.cpp | 14 | ||||
-rw-r--r-- | clang/test/SemaObjC/ibaction.m | 15 |
2 files changed, 27 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index ba6c8bb8866..cc1aab4d89d 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -1492,6 +1492,16 @@ CvtQTToAstBitMask(ObjCDeclSpec::ObjCDeclQualifier PQTVal) { return ret; } +static inline +bool containsInvalidMethodImplAttribute(const AttributeList *A) { + // The 'ibaction' attribute is allowed on method definitions because of + // how the IBAction macro is used on both method declarations and definitions. + // If the method definitions contains any other attributes, return true. + while (A && A->getKind() == AttributeList::AT_IBAction) + A = A->getNext(); + return A != NULL; +} + Sema::DeclPtrTy Sema::ActOnMethodDeclaration( SourceLocation MethodLoc, SourceLocation EndLoc, tok::TokenKind MethodType, DeclPtrTy classDecl, @@ -1618,7 +1628,7 @@ Sema::DeclPtrTy Sema::ActOnMethodDeclaration( } InterfaceMD = ImpDecl->getClassInterface()->getMethod(Sel, MethodType == tok::minus); - if (AttrList) + if (containsInvalidMethodImplAttribute(AttrList)) Diag(EndLoc, diag::warn_attribute_method_def); } else if (ObjCCategoryImplDecl *CatImpDecl = dyn_cast<ObjCCategoryImplDecl>(ClassDecl)) { @@ -1629,7 +1639,7 @@ Sema::DeclPtrTy Sema::ActOnMethodDeclaration( PrevMethod = CatImpDecl->getClassMethod(Sel); CatImpDecl->addClassMethod(ObjCMethod); } - if (AttrList) + if (containsInvalidMethodImplAttribute(AttrList)) Diag(EndLoc, diag::warn_attribute_method_def); } if (PrevMethod) { diff --git a/clang/test/SemaObjC/ibaction.m b/clang/test/SemaObjC/ibaction.m new file mode 100644 index 00000000000..b97e002833c --- /dev/null +++ b/clang/test/SemaObjC/ibaction.m @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 %s -verify + +@interface Foo +{ + __attribute__((iboutlet)) id myoutlet; +} +- (void) __attribute__((ibaction)) myMessage:(id)msg; +@end + +@implementation Foo +// Normally attributes should not be attached to method definitions, but +// we allow 'ibaction' to be attached because it can be expanded from +// the IBAction macro. +- (void) __attribute__((ibaction)) myMessage:(id)msg {} // no-warning +@end |