]> granicus.if.org Git - clang/commitdiff
Make the unused expression warning a bit less aggressive (found in PHP
authorEli Friedman <eli.friedman@gmail.com>
Mon, 19 May 2008 21:24:43 +0000 (21:24 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Mon, 19 May 2008 21:24:43 +0000 (21:24 +0000)
code).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51276 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/Expr.cpp
test/Sema/unused-expr.c

index cd495bc63e43aaca2129082dc2f721ea41ce3aad..e327ffb91177e300981d2955b8d568c322c902fe 100644 (file)
@@ -336,6 +336,10 @@ bool Expr::hasLocalSideEffect() const {
       return cast<CastExpr>(this)->getSubExpr()->hasLocalSideEffect();
     return false;
 
+  case ImplicitCastExprClass:
+    // Check the operand, since implicit casts are inserted by Sema
+    return cast<ImplicitCastExpr>(this)->getSubExpr()->hasLocalSideEffect();
+
   case CXXDefaultArgExprClass:
     return cast<CXXDefaultArgExpr>(this)->getExpr()->hasLocalSideEffect();
   }     
index 305c2be06b575c76f02ae5a6cf7a2b0e57c63ad5..b14daa702dd632df8a84482ae2f2c454d621cdde 100644 (file)
@@ -35,3 +35,8 @@ int stmt_expr(int x, int y) {
   return ({int _a = x, _b = y; _a > _b ? _a : _b; });
 }
 
+void nowarn(unsigned char* a, unsigned char* b)
+{
+  unsigned char c = 1;
+  *a |= c, *b += c;
+}