blob: d0f29a849ab1ca63c920e0e6b5940ad56060aaff (
plain)
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
|
// RUN: %clang_analyze_cc1 -analyzer-checker=core.DivideZero -verify %s
int div0LogicalOpInTernary(bool b1) {
int y = (b1 || b1) ? 0 : 1;
return 1 / y; // expected-warning {{Division by zero}}
}
int div0LogicalAndArith(bool b1, int x) {
int y = (b1 || (x < 3)) ? 0 : 1;
return 1 / y; // expected-warning {{Division by zero}}
}
int div0NestedLogicalOp(bool b1) {
int y = (b1 && b1 || b1 && b1) ? 0 : 1;
return 1 / y; // expected-warning {{Division by zero}}
}
int div0TernaryInTernary(bool b) {
int y = ((b || b) ? false : true) ? 0 : 1;
return 1 / y; // expected-warning {{Division by zero}}
}
int div0LogicalOpParensInTernary(bool b1) {
int y = ((((b1)) || ((b1)))) ? 0 : 1;
return 1 / y; // expected-warning {{Division by zero}}
}
int div0LogicalOpInsideStExpr(bool b1) {
int y = ({1; (b1 || b1);}) ? 0 : 1;
// expected-warning@-1 {{expression result unused}}
return 1 / y; // expected-warning {{Division by zero}}
}
int div0StExprInsideLogicalOp(bool b1) {
int y = (({1; b1;}) || ({1; b1;})) ? 0 : 1;
// expected-warning@-1 {{expression result unused}}
// expected-warning@-2 {{expression result unused}}
return 1 / y; // expected-warning {{Division by zero}}
}
|