if (lType->isRealType() && rType->isRealType())
return Context.IntTy;
} else {
- if (lType->isFloatingType() && rType->isFloatingType())
- Diag(loc, diag::warn_floatingpoint_eq);
-
+ if (lType->isFloatingType() && rType->isFloatingType()) {
+ // Special case: check for x == x (which is OK).
+ bool EmitWarning = true;
+
+ if (DeclRefExpr* DRL = dyn_cast<DeclRefExpr>(lex))
+ if (DeclRefExpr* DRR = dyn_cast<DeclRefExpr>(rex))
+ if (DRL->getDecl() == DRR->getDecl())
+ EmitWarning = false;
+
+ if (EmitWarning)
+ Diag(loc, diag::warn_floatingpoint_eq);
+ }
+
if (lType->isArithmeticType() && rType->isArithmeticType())
return Context.IntTy;
}