Implement GCC's -Wint-to-pointer-cast.

This implementation doesn't warn on anything that GCC doesn't warn on with the
exception of templates specializations (GCC doesn't warn, Clang does). The
specific skipped cases (boolean, constant expressions, enums) are open for
debate/adjustment if anyone wants to demonstrate that GCC is being overly
conservative here. The only really obvious false positive I found was in the
Clang regression suite's MPI test - apparently MPI uses specific flag values in
pointer constants. (eg: #define FOO (void*)~0)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166039 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Sema/cast.c b/test/Sema/cast.c
index 71c44b4..25ef1d0 100644
--- a/test/Sema/cast.c
+++ b/test/Sema/cast.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only %s -verify
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-unknown-unknown %s -verify
 
 typedef struct { unsigned long bits[(((1) + (64) - 1) / (64))]; } cpumask_t;
 cpumask_t x;
@@ -52,8 +52,8 @@
   (void) (CLong) v;
   (void) (CFloat) v;
   (void) (CDouble) v;
-  (void) (VoidPtr) v;
-  (void) (CharPtr) v;
+  (void) (VoidPtr) v; // expected-warning{{cast to 'VoidPtr' (aka 'void *') from smaller integer type 'Int' (aka 'int')}}
+  (void) (CharPtr) v; // expected-warning{{cast to 'CharPtr' (aka 'char *') from smaller integer type 'Int' (aka 'int')}}
 }
 
 void testLong(Long v) {
@@ -157,3 +157,12 @@
   (void) (VoidPtr) v;
   (void) (CharPtr) v;
 }
+
+typedef enum { x_a, x_b } X;
+void *intToPointerCast2(X x) {
+  return (void*)x;
+}
+
+void *intToPointerCast3() {
+  return (void*)(1 + 3);
+}