From: Sam McCall Date: Fri, 15 Feb 2019 09:18:49 +0000 (+0000) Subject: Revert "[Analysis] -Wunreachable-code shouldn't fire on the increment of a foreach... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8575c876d62985f4d772038bf7f2ead653b484fa;p=clang Revert "[Analysis] -Wunreachable-code shouldn't fire on the increment of a foreach loop" This reverts commit r354102. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@354109 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/ReachableCode.cpp b/lib/Analysis/ReachableCode.cpp index 6f1814deb0..cc64efa7f0 100644 --- a/lib/Analysis/ReachableCode.cpp +++ b/lib/Analysis/ReachableCode.cpp @@ -631,10 +631,6 @@ void DeadCodeScan::reportDeadCode(const CFGBlock *B, // a for/for-range loop. This is the block that contains // the increment code. if (const Stmt *LoopTarget = B->getLoopTarget()) { - // The increment on a foreach statement is not written. - if (isa(LoopTarget)) - return; - SourceLocation Loc = LoopTarget->getBeginLoc(); SourceRange R1(Loc, Loc), R2; diff --git a/test/SemaCXX/unreachable-code.cpp b/test/SemaCXX/unreachable-code.cpp index 61805837dc..fd006c099e 100644 --- a/test/SemaCXX/unreachable-code.cpp +++ b/test/SemaCXX/unreachable-code.cpp @@ -52,11 +52,6 @@ void test3() { } } -void test4() { - for (char c : "abc") // no-warning - break; -} - // PR 6130 - Don't warn about bogus unreachable code with throw's and // temporary objects. class PR6130 {