diff options
author | Nuno Lopes <nunoplopes@sapo.pt> | 2009-12-22 23:59:52 +0000 |
---|---|---|
committer | Nuno Lopes <nunoplopes@sapo.pt> | 2009-12-22 23:59:52 +0000 |
commit | 56abcbdb4781e094ae7f19662ba1e59339a75bdb (patch) | |
tree | 0757878654f2a560cbd49f6ba5960aa62c0b46e4 /clang/lib/Sema/SemaDeclAttr.cpp | |
parent | b10c69edd075b2e1d9a20cb7b86568edb0145c81 (diff) | |
download | bcm5719-llvm-56abcbdb4781e094ae7f19662ba1e59339a75bdb.tar.gz bcm5719-llvm-56abcbdb4781e094ae7f19662ba1e59339a75bdb.zip |
warn when attribute warn_unused_result is applied to void functions.
while at it, remove an outdated FIXME
llvm-svn: 91946
Diffstat (limited to 'clang/lib/Sema/SemaDeclAttr.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDeclAttr.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 718db0437f4..e95f479bd8e 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -730,13 +730,18 @@ static void HandleWarnUnusedResult(Decl *D, const AttributeList &Attr, Sema &S) return; } - // TODO: could also be applied to methods? if (!isFunctionOrMethod(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(); + return; + } + D->addAttr(::new (S.Context) WarnUnusedResultAttr()); } |