warn when attribute warn_unused_result is applied to void functions.
while at it, remove an outdated FIXME
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91946 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
index 718db04..e95f479 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -730,13 +730,18 @@
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());
}