First pass at implementing C++ enum semantics:  calculate (and store) an
"integer promotion" type associated with an enum decl, and use this type to
determine which type to promote to.  This type obeys C++ [conv.prom]p2 and
is therefore generally signed unless the range of the enumerators forces
it to be unsigned.

Kills off a lot of false positives from -Wsign-compare in C++, addressing
rdar://7455616




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90965 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/SemaCXX/enum.cpp b/test/SemaCXX/enum.cpp
index 1aba107..3315de0 100644
--- a/test/SemaCXX/enum.cpp
+++ b/test/SemaCXX/enum.cpp
@@ -1,4 +1,5 @@
 // RUN: clang-cc -fsyntax-only -verify %s
+
 enum E {
   Val1,
   Val2
@@ -35,3 +36,32 @@
 }
 
 enum e2; // expected-error{{ISO C++ forbids forward references to 'enum' types}}
+
+namespace test1 {
+  template <class A, class B> struct is_same { static const int value = -1; };
+  template <class A> struct is_same<A,A> { static const int value = 1; };
+
+  enum enum0 { v0 };
+  int test0[is_same<typeof(+v0), int>::value];
+
+  enum enum1 { v1 = __INT_MAX__ };
+  int test1[is_same<typeof(+v1), int>::value];
+
+  enum enum2 { v2 = __INT_MAX__ * 2U };
+  int test2[is_same<typeof(+v2), unsigned int>::value];
+
+  // This kindof assumes that 'int' is smaller than 'long long'.
+#if defined(__LP64__)
+  enum enum3 { v3 = __LONG_LONG_MAX__ };
+  int test3[is_same<typeof(+v3), long>::value];
+
+  enum enum4 { v4 = __LONG_LONG_MAX__ * 2ULL };
+  int test4[is_same<typeof(+v4), unsigned long>::value];
+#else
+  enum enum3 { v3 = __LONG_LONG_MAX__ };
+  int test3[is_same<typeof(+v3), long long>::value];
+
+  enum enum4 { v4 = __LONG_LONG_MAX__ * 2ULL };
+  int test4[is_same<typeof(+v4), unsigned long long>::value];  
+#endif
+}