xref: /minix3/external/bsd/llvm/dist/clang/test/Sema/floating-point-compare.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -Wfloat-equal -verify %s
2*f4a2713aSLionel Sambuc 
f1(float x,float y)3*f4a2713aSLionel Sambuc int f1(float x, float y) {
4*f4a2713aSLionel Sambuc   return x == y; // expected-warning {{comparing floating point with ==}}
5*f4a2713aSLionel Sambuc }
6*f4a2713aSLionel Sambuc 
f2(float x,float y)7*f4a2713aSLionel Sambuc int f2(float x, float y) {
8*f4a2713aSLionel Sambuc   return x != y; // expected-warning {{comparing floating point with ==}}
9*f4a2713aSLionel Sambuc }
10*f4a2713aSLionel Sambuc 
f3(float x)11*f4a2713aSLionel Sambuc int f3(float x) {
12*f4a2713aSLionel Sambuc   return x == x; // no-warning
13*f4a2713aSLionel Sambuc }
14*f4a2713aSLionel Sambuc 
f4(float x)15*f4a2713aSLionel Sambuc int f4(float x) {
16*f4a2713aSLionel Sambuc   return x == 0.0; // no-warning {{comparing}}
17*f4a2713aSLionel Sambuc }
18*f4a2713aSLionel Sambuc 
f5(float x)19*f4a2713aSLionel Sambuc int f5(float x) {
20*f4a2713aSLionel Sambuc   return x == __builtin_inf(); // no-warning
21*f4a2713aSLionel Sambuc }
22*f4a2713aSLionel Sambuc 
f7(float x)23*f4a2713aSLionel Sambuc int f7(float x) {
24*f4a2713aSLionel Sambuc   return x == 3.14159; // expected-warning {{comparing}}
25*f4a2713aSLionel Sambuc }
26