]> granicus.if.org Git - clang/commitdiff
Fix a bug reported by Keith Bauer
authorChris Lattner <sabre@nondot.org>
Sun, 26 Aug 2007 17:32:59 +0000 (17:32 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 26 Aug 2007 17:32:59 +0000 (17:32 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41452 91177308-0d34-0410-b5e6-96231b3b80d8

Sema/SemaStmt.cpp
test/Sema/unused-expr.c

index 1895724097448a9609eb267fc989dd5be0b0020f..da2d12bfaf16383b8ed2c6004d042f2583fa33b6 100644 (file)
@@ -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;
index 245a736f58e98425e9b3cf291c7f9471c0483e2a..323df3496424110413931def53a4fc19bdeedb61 100644 (file)
@@ -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();
+}
+