Make sure to cast the VLA size of array to the type of size_t. Fixes PR3442.

llvm-svn: 63394
This commit is contained in:
Anders Carlsson 2009-01-30 16:41:04 +00:00
parent 3b6a4bd891
commit 221483dd4e
2 changed files with 17 additions and 1 deletions

View File

@ -684,7 +684,10 @@ ScalarExprEmitter::VisitSizeOfAlignOfExpr(const SizeOfAlignOfExpr *E) {
// sizeof(type) - make sure to emit the VLA size.
CGF.EmitVLASize(TypeToSize);
}
return CGF.GetVLASize(VAT);
llvm::Value *VLASize = CGF.GetVLASize(VAT);
return Builder.CreateIntCast(VLASize, ConvertType(E->getType()),
false, "conv");
}
}

View File

@ -0,0 +1,13 @@
// RUN: clang -triple x86_64-unknown-unknown -emit-llvm -o %t %s
// PR3442
static void *g(unsigned long len);
void
f(int n)
{
unsigned begin_set[n];
g(sizeof(begin_set));
}