1 // This test checks that intersecting ranges does not cause 'system is over constrained' assertions in the case of eg: 32 bits unsigned integers getting their range from 64 bits signed integers.
2 // RUN: %clang_analyze_cc1 -triple x86_64-pc-linux-gnu -analyzer-checker=core,debug.ExprInspection -verify %s
4 void clang_analyzer_warnIfReached(void);
9 if (index
< foo
) index
= foo
;
10 if (index
+ 1 == 0) // because of foo range, index is in range [0; UINT_MAX]
11 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
13 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
16 void f2(unsigned long foo
)
19 if (index
< foo
) index
= foo
; // index equals ULONG_MAX
21 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
23 clang_analyzer_warnIfReached(); // no-warning
26 void f3(unsigned long foo
)
29 if (index
< foo
) index
= foo
;
31 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
33 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
39 if (index
< foo
) index
= foo
;
41 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
43 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
49 if (index
< foo
) index
= foo
;
51 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
53 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
59 if (index
< foo
) index
= foo
;
61 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
63 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
69 if (index
< foo
) index
= foo
;
70 if (index
- 1 == 0) // Was not reached prior fix.
71 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
73 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
79 if (index
< foo
) index
= foo
;
81 clang_analyzer_warnIfReached(); // no-warning
83 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
89 if (index
< foo
) index
= foo
;
90 if (index
- 1L == 0L) // Was not reached prior fix.
91 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
93 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
99 if (index
< foo
) index
= foo
;
101 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
103 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
109 if (index
< foo
) index
= foo
;
110 if (index
+ 1UL == 0L)
111 clang_analyzer_warnIfReached(); // no-warning
113 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
119 if (index
< foo
) index
= foo
;
120 if (index
- 1UL == 0L) // Was not reached prior fix.
121 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
123 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
128 unsigned short index
= -1;
129 if (index
< foo
) index
= foo
;
131 clang_analyzer_warnIfReached(); // no-warning
133 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
139 if (index
< foo
) index
= foo
;
142 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
144 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
150 if (index
< foo
) index
= foo
;
151 unsigned int tmp
= index
+ 1;
153 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
155 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}