diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2012-11-14 22:09:59 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2012-11-14 22:09:59 +0000 |
commit | 1f576831c904ea460e52bb86733fa17b1aeb6a50 (patch) | |
tree | 6a9ff7e88b1c38b132bd679261b0b7d606304289 /clang | |
parent | 950d8703b1e79df72b8acda09421d1e0c9f262b8 (diff) | |
download | bcm5719-llvm-1f576831c904ea460e52bb86733fa17b1aeb6a50.tar.gz bcm5719-llvm-1f576831c904ea460e52bb86733fa17b1aeb6a50.zip |
When evaluating variably modified types for function parameters, dig out the
type as written from the ParmVarDecl; it's unclear whether the standard
(C99 6.9.1p10) requires this, but we're following the precedent set by gcc,
and hopefully nobody will ever ask about this again.
PR9559 / <rdar://problem/12621983>.
llvm-svn: 167985
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.cpp | 11 | ||||
-rw-r--r-- | clang/test/CodeGen/vla.c | 6 |
2 files changed, 15 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 18f1623d242..d7ccfc9f0b7 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -454,7 +454,16 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy, // emit the type size. for (FunctionArgList::const_iterator i = Args.begin(), e = Args.end(); i != e; ++i) { - QualType Ty = (*i)->getType(); + const VarDecl *VD = *i; + + // Dig out the type as written from ParmVarDecls; it's unclear whether + // the standard (C99 6.9.1p10) requires this, but we're following the + // precedent set by gcc. + QualType Ty; + if (const ParmVarDecl *PVD = dyn_cast<ParmVarDecl>(VD)) + Ty = PVD->getOriginalType(); + else + Ty = VD->getType(); if (Ty->isVariablyModifiedType()) EmitVariablyModifiedType(Ty); diff --git a/clang/test/CodeGen/vla.c b/clang/test/CodeGen/vla.c index e1518276270..f63796b39dc 100644 --- a/clang/test/CodeGen/vla.c +++ b/clang/test/CodeGen/vla.c @@ -190,4 +190,8 @@ void test6(void) // CHECK-NEXT: store i32 0, i32* [[IX2]], align 4 } - +// Follow gcc's behavior for VLAs in parameter lists. PR9559. +void test7(int a[b(0)]) { + // CHECK: define void @test7( + // CHECK: call i32 @b(i8* null) +} |