diff --git a/lib/Analysis/ReachableCode.cpp b/lib/Analysis/ReachableCode.cpp index 0a9e82bb0ada1b6d64a08d57615350a6646347b3..4220000cd334794732a91bc20b7ca8cfefc2fdf1 100644 --- a/lib/Analysis/ReachableCode.cpp +++ b/lib/Analysis/ReachableCode.cpp @@ -51,7 +51,7 @@ static bool isTrivialDoWhile(const CFGBlock *B, const Stmt *S) { // condition. if (const Stmt *Term = B->getTerminator()) { if (const DoStmt *DS = dyn_cast<DoStmt>(Term)) { - const Expr *Cond = DS->getCond(); + const Expr *Cond = DS->getCond()->IgnoreParenCasts(); return Cond == S && isTrivialExpression(Cond); } } diff --git a/test/SemaCXX/warn-unreachable.cpp b/test/SemaCXX/warn-unreachable.cpp index 7f74732a630eee8013cf2f3a12a4cd2277e3829c..eab8d8e6b97150e5cb876be70a71c41c6d0ece1b 100644 --- a/test/SemaCXX/warn-unreachable.cpp +++ b/test/SemaCXX/warn-unreachable.cpp @@ -218,6 +218,14 @@ int test_treat_non_const_bool_local_as_non_config_value() { return 0; } +void test_do_while(int x) { + // Handle trivial expressions with + // implicit casts to bool. + do { + break; + } while (0); // no-warning +} + class Frobozz { public: Frobozz(int x);