xref: /minix3/external/bsd/llvm/dist/clang/test/SemaCXX/warn-implicit-conversion-floating-point-to-bool.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -verify -fsyntax-only %s
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc float foof(float x);
4*f4a2713aSLionel Sambuc double food(double x);
5*f4a2713aSLionel Sambuc void foo(bool b, float f);
6*f4a2713aSLionel Sambuc 
bar()7*f4a2713aSLionel Sambuc void bar() {
8*f4a2713aSLionel Sambuc 
9*f4a2713aSLionel Sambuc   float c = 1.7;
10*f4a2713aSLionel Sambuc   bool b = c;
11*f4a2713aSLionel Sambuc 
12*f4a2713aSLionel Sambuc   double e = 1.7;
13*f4a2713aSLionel Sambuc   b = e;
14*f4a2713aSLionel Sambuc 
15*f4a2713aSLionel Sambuc   b = foof(4.0);
16*f4a2713aSLionel Sambuc 
17*f4a2713aSLionel Sambuc   b = foof(c < 1); // expected-warning {{implicit conversion turns floating-point number into bool: 'float' to 'bool'}}
18*f4a2713aSLionel Sambuc 
19*f4a2713aSLionel Sambuc   b = food(e < 2); // expected-warning {{implicit conversion turns floating-point number into bool: 'double' to 'bool'}}
20*f4a2713aSLionel Sambuc 
21*f4a2713aSLionel Sambuc   foo(c, b);    // expected-warning {{implicit conversion turns floating-point number into bool: 'float' to 'bool'}}
22*f4a2713aSLionel Sambuc   foo(c, c);
23*f4a2713aSLionel Sambuc 
24*f4a2713aSLionel Sambuc }
25