| 1 |
// RUN: %clang_analyze_cc1 -analyzer-output=text \ |
| 2 |
// RUN: -analyzer-checker=core -verify %s |
| 3 |
|
| 4 |
int assuming_unsigned_ge_0(unsigned arg) { |
| 5 |
// TODO This testcase demonstrates the current incorrect behavior of Clang |
| 6 |
// Static Analyzer: here 'arg' is unsigned, so "arg >= 0" is not a fresh |
| 7 |
// assumption, but it still appears in the diagnostics as if it's fresh: |
| 8 |
// expected-note@+2 {{Assuming 'arg' is >= 0}} |
| 9 |
// expected-note@+1 {{Taking false branch}} |
| 10 |
if (arg < 0) |
| 11 |
return 0; |
| 12 |
// expected-note@+2 {{Assuming 'arg' is <= 0}} |
| 13 |
// expected-note@+1 {{Taking false branch}} |
| 14 |
if (arg > 0) |
| 15 |
return 0; |
| 16 |
// expected-note@+2 {{Division by zero}} |
| 17 |
// expected-warning@+1 {{Division by zero}} |
| 18 |
return 100 / arg; |
| 19 |
} |