]> granicus.if.org Git - clang/commitdiff
constexpr: remove integral conversion overflow checking introduced in r149286.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 31 Jan 2012 01:47:46 +0000 (01:47 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 31 Jan 2012 01:47:46 +0000 (01:47 +0000)
As Eli points out, this is implementation-defined, and the way we define it
makes this fine.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149327 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ExprConstant.cpp
test/CXX/expr/expr.const/p2-0x.cpp

index d2d651c97f4dcb4ce68635ab67d1b351ddcce8bd..50e96bdd4b554bd8c6f9283fdf9fbb10ff158c3b 100644 (file)
@@ -1094,13 +1094,6 @@ static APSInt HandleIntToIntCast(EvalInfo &Info, const Expr *E,
   // Figure out if this is a truncate, extend or noop cast.
   // If the input is signed, do a sign extend, noop, or truncate.
   Result = Result.extOrTrunc(DestWidth);
-
-  // Check whether we overflowed. If so, fold the cast anyway.
-  if (DestType->isSignedIntegerOrEnumerationType() &&
-      ((Result.isNegative() && Value.isUnsigned()) ||
-       Result.extOrTrunc(Value.getBitWidth()) != Value))
-    (void)HandleOverflow(Info, E, Value, DestType);
-
   Result.setIsUnsigned(DestType->isUnsignedIntegerOrEnumerationType());
   return Result;
 }
index 4b425da73c2ee0f580f43a8f5740a9211e15e911..5659273129a60450dbb0046d211dea4aa0f3093b 100644 (file)
@@ -118,8 +118,8 @@ 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)10000000000ll: // expected-error {{constant expression}} expected-note {{value 10000000000 is outside the range of representable values of type 'int'}} expected-note {{here}}
-    case (int)0x80000000u: // expected-error {{constant expression}} expected-note {{value 2147483648 is outside the range of representable values of type 'int'}}
+    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'}}