summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-03-12 07:11:26 +0000
committerJohn McCall <rjmccall@apple.com>2010-03-12 07:11:26 +0000
commitc493a7324003732b845be1fee11df312d2846207 (patch)
tree7bb5d249e72a29e796ac65bdc600e59fd5594902 /clang/lib/Sema
parent399f1f4fd3d3873f979dc3fb727094dc57f7f80e (diff)
downloadbcm5719-llvm-c493a7324003732b845be1fee11df312d2846207.tar.gz
bcm5719-llvm-c493a7324003732b845be1fee11df312d2846207.zip
Improve the unused-value check to look into comma expressions and filter out
voids in sub-expressions. Patch by Mike M! Fixes PR4806. llvm-svn: 98335
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaStmt.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 75d9f67ad9d..fd65c32c203 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -76,10 +76,6 @@ void Sema::DiagnoseUnusedExprResult(const Stmt *S) {
if (!E)
return;
- // Ignore expressions that have void type.
- if (E->getType()->isVoidType())
- return;
-
SourceLocation Loc;
SourceRange R1, R2;
if (!E->isUnusedResultAWarning(Loc, R1, R2, Context))
@@ -103,6 +99,9 @@ void Sema::DiagnoseUnusedExprResult(const Stmt *S) {
}
if (const CallExpr *CE = dyn_cast<CallExpr>(E)) {
+ if (E->getType()->isVoidType())
+ return;
+
// If the callee has attribute pure, const, or warn_unused_result, warn with
// a more specific message to make it clear what is happening.
if (const Decl *FD = CE->getCalleeDecl()) {
OpenPOWER on IntegriCloud