From fd1b3814b321544aff5b7ab1609130b48b88bef7 Mon Sep 17 00:00:00 2001 From: Daniel Marjamaki Date: Mon, 3 Oct 2016 09:45:35 +0000 Subject: [PATCH] [StaticAnalyser] Add test case to ensure that unreachable code is found. https://reviews.llvm.org/D24905 llvm-svn: 283096 --- clang/test/Analysis/unreachable-code-path.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/clang/test/Analysis/unreachable-code-path.c b/clang/test/Analysis/unreachable-code-path.c index 7879240d4292..f0db575ba490 100644 --- a/clang/test/Analysis/unreachable-code-path.c +++ b/clang/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) {