aboutsummaryrefslogtreecommitdiff
path: root/test/Analysis/identical-expressions.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/Analysis/identical-expressions.cpp')
-rw-r--r--test/Analysis/identical-expressions.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/Analysis/identical-expressions.cpp b/test/Analysis/identical-expressions.cpp
index 46dd56289c4e..138cd7ce9887 100644
--- a/test/Analysis/identical-expressions.cpp
+++ b/test/Analysis/identical-expressions.cpp
@@ -1530,3 +1530,35 @@ void test_nowarn_long() {
c = 0LL;
}
}
+
+// Identical inner conditions
+
+void test_warn_inner_if_1(int x) {
+ if (x == 1) {
+ if (x == 1) // expected-warning {{conditions of the inner and outer statements are identical}}
+ ;
+ }
+
+ // FIXME: Should warn here. The warning is currently not emitted because there
+ // is code between the conditions.
+ if (x == 1) {
+ int y = x;
+ if (x == 1)
+ ;
+ }
+}
+
+void test_nowarn_inner_if_1(int x) {
+ // Don't warn when condition has side effects.
+ if (x++ == 1) {
+ if (x++ == 1)
+ ;
+ }
+
+ // Don't warn when x is changed before inner condition.
+ if (x < 10) {
+ x++;
+ if (x < 10)
+ ;
+ }
+}