]> granicus.if.org Git - clang/commitdiff
Cast the array size expr to a size_t
authorAnders Carlsson <andersca@mac.com>
Wed, 23 Sep 2009 00:37:25 +0000 (00:37 +0000)
committerAnders Carlsson <andersca@mac.com>
Wed, 23 Sep 2009 00:37:25 +0000 (00:37 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82594 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExprCXX.cpp
test/SemaCXX/new-delete.cpp

index b11f39795da5e4ff10978ff80861e7532e5c8fcf..79909b557d307029dd47626e3d7a73a8cc64b2e0 100644 (file)
@@ -402,12 +402,15 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal,
       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;
index 0ddf24da783876231ea8da74904412fdf68afd12..50af17d2659f2ac65aa23979143584ef226c684e 100644 (file)
@@ -42,6 +42,8 @@ void good_news()
   //V *pv = new (ps) V;
   
   pi = new (S(1.0f, 2)) int;
+  
+  (void)new int[true];
 }
 
 struct abstract {