[cfe-commits] r158117 - in /cfe/trunk: lib/CodeGen/CGExprScalar.cpp test/CodeGen/vla.c

Eli Friedman eli.friedman at gmail.com
Wed Jun 6 17:03:58 PDT 2012


On Wed, Jun 6, 2012 at 4:09 PM, Eli Friedman <eli.friedman at gmail.com> wrote:
> On Wed, Jun 6, 2012 at 3:58 PM, Fariborz Jahanian <fjahanian at apple.com> wrote:
>> Author: fjahanian
>> Date: Wed Jun  6 17:58:50 2012
>> New Revision: 158117
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=158117&view=rev
>> Log:
>> When doing arithmatic on vla pointer, make sure
>> to emit vla size to prevent an irgen crash.
>> // rdar://11485774
>>
>> 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=158117&r1=158116&r2=158117&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Wed Jun  6 17:58:50 2012
>> @@ -1970,6 +1970,9 @@
>>   QualType elementType = pointerType->getPointeeType();
>>   if (const VariableArrayType *vla
>>         = CGF.getContext().getAsVariableArrayType(elementType)) {
>> +    // arithmatic on VLA pointer - make sure to emit the VLA size.
>> +    CGF.EmitVariablyModifiedType(elementType);
>
> This call is in the wrong place; we should emit the type of an
> InitListExpr when we emit the expression itself, not when we use it.

Err, not the InitListExpr; the CompoundLiteralExpr, like John said.

-Eli




More information about the cfe-commits mailing list