[-Wunreachable-code] Handle idiomatic do...while() with an uninteresting condition.
Sometimes do..while() is used to create a scope that can be left early.
In such cases, the unreachable 'while()' test is not usually interesting
unless it actually does something that is observable.
llvm-svn: 203051
diff --git a/clang/test/SemaCXX/unreachable-code.cpp b/clang/test/SemaCXX/unreachable-code.cpp
index 743290e..b6b8ab4 100644
--- a/clang/test/SemaCXX/unreachable-code.cpp
+++ b/clang/test/SemaCXX/unreachable-code.cpp
@@ -1,7 +1,7 @@
// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -Wunreachable-code -fblocks -verify %s
int j;
-void bar() { }
+int bar();
int test1() {
for (int i = 0;
i != 10;
@@ -11,7 +11,19 @@
return 1;
}
return 0;
- return 1; // expected-warning {{will never be executed}}
+ return 1; // expected-warning {{will never be executed}}
+}
+
+int test1_B() {
+ for (int i = 0;
+ i != 10;
+ ++i) { // expected-warning {{will never be executed}}
+ if (j == 23) // missing {}'s
+ bar();
+ return 1;
+ }
+ return 0;
+ return bar(); // expected-warning {{will never be executed}}
}
void test2(int i) {