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,
}
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)) {
PrevMethod = CatImpDecl->getClassMethod(Sel);
CatImpDecl->addClassMethod(ObjCMethod);
}
- if (AttrList)
+ if (containsInvalidMethodImplAttribute(AttrList))
Diag(EndLoc, diag::warn_attribute_method_def);
}
if (PrevMethod) {
--- /dev/null
+// 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