bugprone-terminating-continue.cpp
1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// RUN: %check_clang_tidy %s bugprone-terminating-continue %t
void f() {
do {
continue;
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'continue' in loop with false condition is equivalent to 'break' [bugprone-terminating-continue]
// CHECK-FIXES: break;
} while(false);
do {
continue;
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'continue' in loop with false condition is equivalent to 'break' [bugprone-terminating-continue]
// CHECK-FIXES: break;
} while(0);
do {
continue;
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'continue' in loop with false condition is equivalent to 'break' [bugprone-terminating-continue]
// CHECK-FIXES: break;
} while(nullptr);
do {
continue;
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'continue' in loop with false condition is equivalent to 'break' [bugprone-terminating-continue]
// CHECK-FIXES: break;
} while(__null);
do {
int x = 1;
if (x > 0) continue;
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'continue' in loop with false condition is equivalent to 'break' [bugprone-terminating-continue]
// CHECK-FIXES: if (x > 0) break;
} while (false);
}
void g() {
do {
do {
continue;
int x = 1;
} while (1 == 1);
} while (false);
do {
for (int i = 0; i < 1; ++i) {
continue;
int x = 1;
}
} while (false);
do {
while (true) {
continue;
int x = 1;
}
} while (false);
int v[] = {1,2,3,34};
do {
for (int n : v) {
if (n>2) continue;
}
} while (false);
}