[cfe-commits] r61301 - in /cfe/trunk: lib/CodeGen/CGExprScalar.cpp test/CodeGen/vla.c
Anders Carlsson
andersca at mac.com
Sat Dec 20 19:33:22 PST 2008
Author: andersca
Date: Sat Dec 20 21:33:21 2008
New Revision: 61301
URL: http://llvm.org/viewvc/llvm-project?rev=61301&view=rev
Log:
Make sure to emit the size expression for sizeof(type)
Modified:
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/test/CodeGen/vla.c
Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=61301&r1=61300&r2=61301&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Sat Dec 20 21:33:21 2008
@@ -663,8 +663,13 @@
if (const VariableArrayType *VAT =
CGF.getContext().getAsVariableArrayType(TypeToSize)) {
- if (E->isSizeOf())
+ if (E->isSizeOf()) {
+ if (E->isArgumentType()) {
+ // sizeof(type) - make sure to emit the VLA size.
+ CGF.EmitVLASize(TypeToSize);
+ }
return CGF.GetVLASize(VAT);
+ }
// FIXME: This should be an UNSUPPORTED error.
assert(0 && "alignof VLAs not implemented yet");
}
Modified: cfe/trunk/test/CodeGen/vla.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/vla.c?rev=61301&r1=61300&r2=61301&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/vla.c (original)
+++ cfe/trunk/test/CodeGen/vla.c Sat Dec 20 21:33:21 2008
@@ -8,3 +8,8 @@
arry[0] = 10;
b(arry);
}
+
+void b(int n)
+{
+ sizeof(int[n]);
+}
More information about the cfe-commits
mailing list