From: Chris Lattner Date: Sun, 26 Aug 2007 17:32:59 +0000 (+0000) Subject: Fix a bug reported by Keith Bauer X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6e844adbe981e549ac0ad2300ea942832aad5ef6;p=clang Fix a bug reported by Keith Bauer git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41452 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Sema/SemaStmt.cpp b/Sema/SemaStmt.cpp index 1895724097..da2d12bfaf 100644 --- a/Sema/SemaStmt.cpp +++ b/Sema/SemaStmt.cpp @@ -27,7 +27,7 @@ Sema::StmtResult Sema::ParseExprStmt(ExprTy *expr) { // Exprs are statements, so there is no need to do a conversion here. However, // diagnose some potentially bad code. - if (!E->hasLocalSideEffect()) + if (!E->hasLocalSideEffect() && !E->getType()->isVoidType()) Diag(E->getExprLoc(), diag::warn_unused_expr, E->getSourceRange()); return E; diff --git a/test/Sema/unused-expr.c b/test/Sema/unused-expr.c index 245a736f58..323df34964 100644 --- a/test/Sema/unused-expr.c +++ b/test/Sema/unused-expr.c @@ -7,7 +7,7 @@ void bar(volatile int *VP, int *P, int A, VP == P; // expected-warning {{expression result unused}} \ expected-warning {{comparison}} - (void)A; // expected-warning {{expression result unused}} + (void)A; (void)foo(1,2); // no warning. A == foo(1, 2); // expected-warning {{expression result unused}} @@ -25,3 +25,9 @@ void bar(volatile int *VP, int *P, int A, //__real__ VC; } +extern void t1(); +extern void t2(); +void t3(int c) { + c ? t1() : t2(); +} +