[cfe-commits] r149327 - in /cfe/trunk: lib/AST/ExprConstant.cpp test/CXX/expr/expr.const/p2-0x.cpp

Richard Smith richard-llvm at metafoo.co.uk
Mon Jan 30 17:47:46 PST 2012


Author: rsmith
Date: Mon Jan 30 19:47:46 2012
New Revision: 149327

URL: http://llvm.org/viewvc/llvm-project?rev=149327&view=rev
Log:
constexpr: remove integral conversion overflow checking introduced in r149286.
As Eli points out, this is implementation-defined, and the way we define it
makes this fine.

Modified:
    cfe/trunk/lib/AST/ExprConstant.cpp
    cfe/trunk/test/CXX/expr/expr.const/p2-0x.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=149327&r1=149326&r2=149327&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Mon Jan 30 19:47:46 2012
@@ -1094,13 +1094,6 @@
   // 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;
 }

Modified: cfe/trunk/test/CXX/expr/expr.const/p2-0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/expr/expr.const/p2-0x.cpp?rev=149327&r1=149326&r2=149327&view=diff
==============================================================================
--- cfe/trunk/test/CXX/expr/expr.const/p2-0x.cpp (original)
+++ cfe/trunk/test/CXX/expr/expr.const/p2-0x.cpp Mon Jan 30 19:47:46 2012
@@ -118,8 +118,8 @@
   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'}}





More information about the cfe-commits mailing list