Implement a sub-group of -Wconversion: -Wliteral-conversion. This
specifically targets literals which are implicitly converted, a those
are more often unintended and trivial to fix. This can be especially
helpful for diagnosing what makes 'const int x = 1e6' not an ICE.

Original patch authored by Jim Meehan with contributions from other
Googlers and a few cleanups from myself.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125745 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
index 9913edb..a3ab52c 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/lib/Sema/SemaChecking.cpp
@@ -2799,9 +2799,15 @@
     }
 
     // If the target is integral, always warn.
-    if ((TargetBT && TargetBT->isInteger()))
-      // TODO: don't warn for integer values?
-      DiagnoseImpCast(S, E, T, CC, diag::warn_impcast_float_integer);
+    if ((TargetBT && TargetBT->isInteger())) {
+      Expr *InnerE = E->IgnoreParenImpCasts();
+      if (FloatingLiteral *LiteralExpr = dyn_cast<FloatingLiteral>(InnerE)) {
+        DiagnoseImpCast(S, LiteralExpr, T, CC,
+                        diag::warn_impcast_literal_float_to_integer);
+      } else {
+        DiagnoseImpCast(S, E, T, CC, diag::warn_impcast_float_integer);
+      }
+    }
 
     return;
   }