Make sure to cast the VLA size of array to the type of size_t. Fixes PR3442.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63394 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp
index 1d389b6..44eefea 100644
--- a/lib/CodeGen/CGExprScalar.cpp
+++ b/lib/CodeGen/CGExprScalar.cpp
@@ -684,7 +684,10 @@
// 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");
}
}