brintos

brintos / llvm-project-archived public Read only

0
0
Text · 734 B · 553e68c Raw
20 lines · c
1// RUN: %clang_analyze_cc1 -analyzer-output=text        \2// RUN:     -analyzer-checker=core -verify %s3 4int assuming_unsigned_ge_0(unsigned arg) {5  // TODO This testcase demonstrates the current incorrect behavior of Clang6  // Static Analyzer: here 'arg' is unsigned, so "arg >= 0" is not a fresh7  // 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}20