Significantly rework the calculation of effective integer-expression ranges
for -Wsign-compare and -Wconversion, and use that coordinated logic to drive
both diagnostics.  The new logic works more transparently with implicit
conversions, conditional operators, etc., as well as bringing -Wconversion's
ability to deal with pseudo-closed operations (e.g. arithmetic on shorts) to
-Wsign-compare.

Fixes PRs 5887, 5937, 5938, and 5939.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92823 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Sema/compare.c b/test/Sema/compare.c
index bacd47e..a22e721 100644
--- a/test/Sema/compare.c
+++ b/test/Sema/compare.c
@@ -233,3 +233,36 @@
   enum en { zero };
   return i > zero;
 }
+
+// PR5937
+int test2(int i32) {
+  struct foo {
+    unsigned int u8 : 8;
+    unsigned long long u31 : 31;
+    unsigned long long u32 : 32;
+    unsigned long long u63 : 63;
+    unsigned long long u64 : 64;
+  } *x;
+  
+  if (x->u8 == i32) { // comparison in int32, exact
+    return 0;
+  } else if (x->u31 == i32) { // comparison in int32, exact
+    return 1;
+  } else if (x->u32 == i32) { // expected-warning {{comparison of integers of different signs}}
+    return 2;
+  } else if (x->u63 == i32) { // comparison in uint64, exact because ==
+    return 3;
+  } else if (x->u64 == i32) { // expected-warning {{comparison of integers of different signs}}
+    return 4;
+  } else {
+    return 5;
+  }
+}
+
+// PR5887
+void test3() {
+  unsigned short x, y;
+  unsigned int z;
+  if ((x > y ? x : y) > z)
+    (void) 0;
+}