summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/warn-loop-analysis.cpp
diff options
context:
space:
mode:
authorEli Friedman <efriedma@codeaurora.org>2017-07-04 00:52:24 +0000
committerEli Friedman <efriedma@codeaurora.org>2017-07-04 00:52:24 +0000
commite91b2e682cde043537d16a766ee246d756bb2476 (patch)
treead4b821371c5972f98157d36274a9c848bf6ab4d /clang/test/SemaCXX/warn-loop-analysis.cpp
parentfa6e67526780ec76b39f511f348376d1d8d421a2 (diff)
downloadbcm5719-llvm-e91b2e682cde043537d16a766ee246d756bb2476.tar.gz
bcm5719-llvm-e91b2e682cde043537d16a766ee246d756bb2476.zip
[Sema] Make BreakContinueFinder handle nested loops.
We don't care about break or continue statements that aren't associated with the current loop, so make sure the visitor doesn't find them. Fixes https://bugs.llvm.org/show_bug.cgi?id=32648 . Differential Revision: https://reviews.llvm.org/D34568 llvm-svn: 307051
Diffstat (limited to 'clang/test/SemaCXX/warn-loop-analysis.cpp')
-rw-r--r--clang/test/SemaCXX/warn-loop-analysis.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/warn-loop-analysis.cpp b/clang/test/SemaCXX/warn-loop-analysis.cpp
index 25ec7a7862e..2934003848a 100644
--- a/clang/test/SemaCXX/warn-loop-analysis.cpp
+++ b/clang/test/SemaCXX/warn-loop-analysis.cpp
@@ -202,6 +202,12 @@ void test7() {
if (true) continue;
i--;
}
+
+ // But do warn if the continue is in a nested loop.
+ for (;;i--) { // expected-note{{decremented here}}
+ for (int j = 0; j < 10; ++j) continue;
+ i--; // expected-warning{{decremented both}}
+ }
}
struct iterator {
@@ -259,6 +265,12 @@ void test8() {
if (true) continue;
i--;
}
+
+ // But do warn if the continue is in a nested loop.
+ for (;;i--) { // expected-note{{decremented here}}
+ for (int j = 0; j < 10; ++j) continue;
+ i--; // expected-warning{{decremented both}}
+ }
}
int f(int);
OpenPOWER on IntegriCloud