aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGDecl.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2008-12-20 20:46:34 +0000
committerAnders Carlsson <andersca@mac.com>2008-12-20 20:46:34 +0000
commit60d35413662ebdcd1d31e34a8a7c665eb6977f1e (patch)
tree3611941b067ec799cddd5b4d12c2cdb370b795d2 /lib/CodeGen/CGDecl.cpp
parentf666b7780d04186521adcaedb0e15dfa4d5e6933 (diff)
Change EmitVLASize to take a QualType that must be a variably modified type.
Emit the size even if the declared type is a variably modified type. This lets us handle void f(int n) { int (*a)[n]; printf("size: %d\n", sizeof(*a)); } git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61285 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGDecl.cpp')
-rw-r--r--lib/CodeGen/CGDecl.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp
index 7f4e34d0f9..e8084dcf17 100644
--- a/lib/CodeGen/CGDecl.cpp
+++ b/lib/CodeGen/CGDecl.cpp
@@ -160,9 +160,10 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) {
D.getStorageClass() == VarDecl::Register ? ".reg." : ".auto.";
DeclPtr = GenerateStaticBlockVarDecl(D, true, Class);
}
+
+ if (Ty->isVariablyModifiedType())
+ EmitVLASize(Ty);
} else {
- const VariableArrayType *VAT = getContext().getAsVariableArrayType(Ty);
-
if (!StackSaveValues.back()) {
// Save the stack.
const llvm::Type *LTy = llvm::PointerType::getUnqual(llvm::Type::Int8Ty);
@@ -180,7 +181,7 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) {
const llvm::Type *LElemPtrTy =
llvm::PointerType::get(LElemTy, D.getType().getAddressSpace());
- llvm::Value *VLASize = EmitVLASize(VAT);
+ llvm::Value *VLASize = EmitVLASize(Ty);
// Allocate memory for the array.
llvm::Value *VLA = Builder.CreateAlloca(llvm::Type::Int8Ty, VLASize, "vla");