mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-26 17:56:05 +00:00

This warns in two specific situations: 1) For potentially swapped function arguments, e.g. void foo(bool, float); foo(1.7, false); 2) Misplaced brackets around function call arguments, e.g. bool InRange = fabs(a - b < delta); Where the last argument in a function call is implicitly converted from bool to float, and the function returns a float which gets implicitly converted to bool. Patch by Andreas Eckleder! llvm-svn: 162763
25 lines
585 B
C++
25 lines
585 B
C++
// RUN: %clang_cc1 -verify -fsyntax-only %s
|
|
|
|
float foof(float x);
|
|
double food(double x);
|
|
void foo(bool b, float f);
|
|
|
|
void bar() {
|
|
|
|
float c = 1.7;
|
|
bool b = c;
|
|
|
|
double e = 1.7;
|
|
b = e;
|
|
|
|
b = foof(4.0);
|
|
|
|
b = foof(c < 1); // expected-warning {{implicit conversion turns floating-point number into bool: 'float' to 'bool'}}
|
|
|
|
b = food(e < 2); // expected-warning {{implicit conversion turns floating-point number into bool: 'double' to 'bool'}}
|
|
|
|
foo(c, b); // expected-warning {{implicit conversion turns floating-point number into bool: 'float' to 'bool'}}
|
|
foo(c, c);
|
|
|
|
}
|