[cfe-commits] r42334 - /cfe/trunk/AST/Expr.cpp

Chris Lattner sabre at nondot.org
Tue Sep 25 17:47:26 PDT 2007


Author: lattner
Date: Tue Sep 25 19:47:26 2007
New Revision: 42334

URL: http://llvm.org/viewvc/llvm-project?rev=42334&view=rev
Log:
Handle (int)1.0e40 as an i-c-e.

Modified:
    cfe/trunk/AST/Expr.cpp

Modified: cfe/trunk/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/Expr.cpp?rev=42334&r1=42333&r2=42334&view=diff

==============================================================================
--- cfe/trunk/AST/Expr.cpp (original)
+++ cfe/trunk/AST/Expr.cpp Tue Sep 25 19:47:26 2007
@@ -483,7 +483,7 @@
 /// comma, etc
 ///
 /// FIXME: This should ext-warn on overflow during evaluation!  ISO C does not
-/// permit this.
+/// permit this.  This includes things like (int)1e1000
 ///
 /// FIXME: Handle offsetof.  Two things to do:  Handle GCC's __builtin_offsetof
 /// to support gcc 4.0+  and handle the idiom GCC recognizes with a null pointer
@@ -557,7 +557,8 @@
       
       // Return the result in the right width.
       Result.zextOrTrunc(
-        static_cast<uint32_t>(Ctx.getTypeSize(getType(), Exp->getOperatorLoc())));
+        static_cast<uint32_t>(Ctx.getTypeSize(getType(),
+                                              Exp->getOperatorLoc())));
 
       // Get information about the size or align.
       if (Exp->getOpcode() == UnaryOperator::SizeOf)
@@ -570,7 +571,8 @@
     case UnaryOperator::LNot: {
       bool Val = Result != 0;
       Result.zextOrTrunc(
-        static_cast<uint32_t>(Ctx.getTypeSize(getType(), Exp->getOperatorLoc())));
+        static_cast<uint32_t>(Ctx.getTypeSize(getType(),
+                                              Exp->getOperatorLoc())));
       Result = Val;
       break;
     }
@@ -748,17 +750,12 @@
     
     // Determine whether we are converting to unsigned or signed.
     bool DestSigned = getType()->isSignedIntegerType();
-    
+
+    // TODO: Warn on overflow, but probably not here: isIntegerConstantExpr can
+    // be called multiple times per AST.
     uint64_t Space[4]; 
-    
-    llvm::APFloat::opStatus Status =
-      FL->getValue().convertToInteger(Space, DestWidth, DestSigned,
-                                      llvm::APFloat::rmTowardZero);
-    if (Status != llvm::APFloat::opOK && Status != llvm::APFloat::opInexact) {
-      if (Loc) *Loc = Operand->getLocStart();
-      return false; // FIXME: need to accept this as an extension.
-    }
-    
+    (void)FL->getValue().convertToInteger(Space, DestWidth, DestSigned,
+                                          llvm::APFloat::rmTowardZero);
     Result = llvm::APInt(DestWidth, 4, Space);
     break;
   }





More information about the cfe-commits mailing list