brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.0 KiB · d9db5e9 Raw
27 lines · c
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:   -verify6 7unsigned char U8;8signed char S8;9 10void 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 19void 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}27