[cfe-commits] r82594 - in /cfe/trunk: lib/Sema/SemaExprCXX.cpp test/SemaCXX/new-delete.cpp

Anders Carlsson andersca at mac.com
Tue Sep 22 17:37:25 PDT 2009


Author: andersca
Date: Tue Sep 22 19:37:25 2009
New Revision: 82594

URL: http://llvm.org/viewvc/llvm-project?rev=82594&view=rev
Log:
Cast the array size expr to a size_t

Modified:
    cfe/trunk/lib/Sema/SemaExprCXX.cpp
    cfe/trunk/test/SemaCXX/new-delete.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=82594&r1=82593&r2=82594&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Tue Sep 22 19:37:25 2009
@@ -402,12 +402,15 @@
       llvm::APSInt Value;
       if (ArraySize->isIntegerConstantExpr(Value, Context, 0, false)) {
         if (Value < llvm::APSInt(
-                        llvm::APInt::getNullValue(Value.getBitWidth()), false))
+                        llvm::APInt::getNullValue(Value.getBitWidth()), 
+                                 Value.isUnsigned()))
           return ExprError(Diag(ArraySize->getSourceRange().getBegin(),
                            diag::err_typecheck_negative_array_size)
             << ArraySize->getSourceRange());
       }
     }
+    
+    ImpCastExprToType(ArraySize, Context.getSizeType());
   }
 
   FunctionDecl *OperatorNew = 0;

Modified: cfe/trunk/test/SemaCXX/new-delete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/new-delete.cpp?rev=82594&r1=82593&r2=82594&view=diff

==============================================================================
--- cfe/trunk/test/SemaCXX/new-delete.cpp (original)
+++ cfe/trunk/test/SemaCXX/new-delete.cpp Tue Sep 22 19:37:25 2009
@@ -42,6 +42,8 @@
   //V *pv = new (ps) V;
   
   pi = new (S(1.0f, 2)) int;
+  
+  (void)new int[true];
 }
 
 struct abstract {





More information about the cfe-commits mailing list