diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2010-03-30 18:22:15 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2010-03-30 18:22:15 +0000 |
commit | f031774aa2638b4d3f487e7e44180c1f89b867ef (patch) | |
tree | f10e7c7f6cbd9d25c33d0648258f7d450f80bb05 /lib/Sema/SemaDeclAttr.cpp | |
parent | e0f38678f01291e68fc70ea6056260b54d529307 (diff) |
Add Support for 'warn_unused_result" attribute on
objective-c methods. (radar 7418262).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99903 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDeclAttr.cpp')
-rw-r--r-- | lib/Sema/SemaDeclAttr.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index b3041129db..d12dec4561 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -837,18 +837,24 @@ static void HandleWarnUnusedResult(Decl *D, const AttributeList &Attr, Sema &S) return; } - if (!isFunction(D)) { + if (!isFunction(D) && !isa<ObjCMethodDecl>(D)) { S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) << Attr.getName() << 0 /*function*/; return; } - if (getFunctionType(D)->getResultType()->isVoidType()) { - S.Diag(Attr.getLoc(), diag::warn_attribute_void_function) - << Attr.getName(); + if (isFunction(D) && getFunctionType(D)->getResultType()->isVoidType()) { + S.Diag(Attr.getLoc(), diag::warn_attribute_void_function_method) + << Attr.getName() << 0; return; } - + if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D)) + if (MD->getResultType()->isVoidType()) { + S.Diag(Attr.getLoc(), diag::warn_attribute_void_function_method) + << Attr.getName() << 1; + return; + } + D->addAttr(::new (S.Context) WarnUnusedResultAttr()); } |