summaryrefslogtreecommitdiff
path: root/clang/test/Sema/floating-point-compare.c
blob: 60f971c6df97fe8893f4974df158a93f144c2b1f (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// RUN: %clang_cc1 -fsyntax-only -Wfloat-equal -verify %s

int f1(float x, float y) {
  return x == y; // expected-warning {{comparing floating point with ==}}
} 

int f2(float x, float y) {
  return x != y; // expected-warning {{comparing floating point with ==}}
}

int f3(float x) {
  return x == x; // no-warning
}

int f4(float x) {
  return x == 0.0; // no-warning {{comparing}}
}

int f5(float x) {
  return x == __builtin_inf(); // no-warning
}

int f7(float x) {
  return x == 3.14159; // expected-warning {{comparing}}
}