1 // RUN: %clang_analyze_cc1 -analyzer-checker=core.DivideZero -verify %s
3 int div0LogicalOpInTernary(bool b1
) {
4 int y
= (b1
|| b1
) ? 0 : 1;
5 return 1 / y
; // expected-warning {{Division by zero}}
8 int div0LogicalAndArith(bool b1
, int x
) {
9 int y
= (b1
|| (x
< 3)) ? 0 : 1;
10 return 1 / y
; // expected-warning {{Division by zero}}
13 int div0NestedLogicalOp(bool b1
) {
14 int y
= (b1
&& b1
|| b1
&& b1
) ? 0 : 1;
15 return 1 / y
; // expected-warning {{Division by zero}}
18 int div0TernaryInTernary(bool b
) {
19 int y
= ((b
|| b
) ? false : true) ? 0 : 1;
20 return 1 / y
; // expected-warning {{Division by zero}}
23 int div0LogicalOpParensInTernary(bool b1
) {
24 int y
= ((((b1
)) || ((b1
)))) ? 0 : 1;
25 return 1 / y
; // expected-warning {{Division by zero}}
28 int div0LogicalOpInsideStExpr(bool b1
) {
29 int y
= ({1; (b1
|| b1
);}) ? 0 : 1;
30 // expected-warning@-1 {{expression result unused}}
31 return 1 / y
; // expected-warning {{Division by zero}}
34 int div0StExprInsideLogicalOp(bool b1
) {
35 int y
= (({1; b1
;}) || ({1; b1
;})) ? 0 : 1;
36 // expected-warning@-1 {{expression result unused}}
37 // expected-warning@-2 {{expression result unused}}
38 return 1 / y
; // expected-warning {{Division by zero}}