| 1 |
// RUN: %clang_analyze_cc1 %s \ |
| 2 |
// RUN: -Wno-conversion -Wno-tautological-constant-compare \ |
| 3 |
// RUN: -analyzer-checker=core,apiModeling,alpha.core.Conversion \ |
| 4 |
// RUN: -analyzer-output=text \ |
| 5 |
// RUN: -verify |
| 6 |
|
| 7 |
unsigned char U8; |
| 8 |
signed char S8; |
| 9 |
|
| 10 |
void track_assign(void) { |
| 11 |
unsigned long L = 1000; // expected-note {{'L' initialized to 1000}} |
| 12 |
int I = -1; // expected-note {{'I' initialized to -1}} |
| 13 |
U8 *= L; // expected-warning {{Loss of precision in implicit conversion}} |
| 14 |
// expected-note@-1 {{Loss of precision in implicit conversion}} |
| 15 |
L *= I; // expected-warning {{Loss of sign in implicit conversion}} |
| 16 |
// expected-note@-1 {{Loss of sign in implicit conversion}} |
| 17 |
} |
| 18 |
|
| 19 |
void track_relational(unsigned U, signed S) { |
| 20 |
if (S < -10) { // expected-note {{Taking true branch}} |
| 21 |
// expected-note@-1 {{Assuming the condition is true}} |
| 22 |
if (U < S) { // expected-warning {{Loss of sign in implicit conversion}} |
| 23 |
// expected-note@-1 {{Loss of sign in implicit conversion}} |
| 24 |
} |
| 25 |
} |
| 26 |
} |