From: Daniel Marjamaki Date: Mon, 3 Oct 2016 09:45:35 +0000 (+0000) Subject: [StaticAnalyser] Add test case to ensure that unreachable code is found. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cd374e5edd1a4d38428f3da431a7c436818832f8;p=clang [StaticAnalyser] Add test case to ensure that unreachable code is found. https://reviews.llvm.org/D24905 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@283096 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Analysis/unreachable-code-path.c b/test/Analysis/unreachable-code-path.c index 7879240d42..f0db575ba4 100644 --- a/test/Analysis/unreachable-code-path.c +++ b/test/Analysis/unreachable-code-path.c @@ -161,7 +161,7 @@ void testInlined() { // Don't warn about unreachable VarDecl. void dostuff(int*A); -void varDecl(int X) { +void varDecl1(int X) { switch (X) { int A; // No warning here. case 1: @@ -172,6 +172,17 @@ void varDecl(int X) { break; } } +void varDecl2(int X) { + switch (X) { + int A=1; // expected-warning {{never executed}} + case 1: + dostuff(&A); + break; + case 2: + dostuff(&A); + break; + } +} // Ensure that ExplodedGraph and unoptimized CFG match. void test12(int x) {