Don't treat overflow in floating-point conversions as a hard error in constant evaluation. <rdar://problem/11874571>.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160394 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/CXX/expr/expr.const/p2-0x.cpp b/test/CXX/expr/expr.const/p2-0x.cpp
index 054669e..9e6716d 100644
--- a/test/CXX/expr/expr.const/p2-0x.cpp
+++ b/test/CXX/expr/expr.const/p2-0x.cpp
@@ -131,14 +131,14 @@
 namespace UndefinedBehavior {
   void f(int n) {
     switch (n) {
-    case (int)4.4e9: // expected-error {{constant expression}} expected-note {{value 4.4E+9 is outside the range of representable values of type 'int'}}
+    case (int)4.4e9: // expected-error {{constant expression}} expected-note {{value 4.4E+9 is outside the range of representable values of type 'int'}} expected-note {{previous case defined here}}
     case (int)0x80000000u: // ok
     case (int)10000000000ll: // expected-note {{here}}
     case (unsigned int)10000000000ll: // expected-error {{duplicate case value}}
     case (int)(unsigned)(long long)4.4e9: // ok
-    case (int)(float)1e300: // expected-error {{constant expression}} expected-note {{value 1.0E+300 is outside the range of representable values of type 'float'}}
+    case (int)(float)1e300: // expected-error {{constant expression}} expected-note {{value 1.0E+300 is outside the range of representable values of type 'float'}} expected-error {{duplicate case value '2147483647'}} expected-note {{previous case defined here}}
     case (int)((float)1e37 / 1e30): // ok
-    case (int)(__fp16)65536: // expected-error {{constant expression}} expected-note {{value 65536 is outside the range of representable values of type 'half'}}
+    case (int)(__fp16)65536: // expected-error {{constant expression}} expected-note {{value 65536 is outside the range of representable values of type 'half'}} expected-error {{duplicate case value '2147483647'}}
       break;
     }
   }
diff --git a/test/Sema/const-eval.c b/test/Sema/const-eval.c
index bc8b227..16d028e 100644
--- a/test/Sema/const-eval.c
+++ b/test/Sema/const-eval.c
@@ -131,3 +131,6 @@
 
 extern struct Test50S Test50;
 EVAL_EXPR(50, &Test50 < (struct Test50S*)((unsigned)&Test50 + 10)) // expected-error {{must have a constant size}}
+
+// <rdar://problem/11874571>
+EVAL_EXPR(51, 0 != (float)1e99)
diff --git a/test/SemaCXX/constant-expression.cpp b/test/SemaCXX/constant-expression.cpp
index c997f3c..c06b6c0 100644
--- a/test/SemaCXX/constant-expression.cpp
+++ b/test/SemaCXX/constant-expression.cpp
@@ -115,7 +115,7 @@
 namespace FloatConvert {
   typedef int a[(int)42.3];
   typedef int a[(int)42.997];
-  typedef int b[(int)4e10]; // expected-warning {{variable length}} expected-error {{variable length}}
+  typedef int b[(int)4e10]; // expected-warning {{variable length}} expected-warning {{size of static array must be an integer constant expression}}
 }
 
 // PR12626