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

Fariborz Jahanian fjahanian at apple.com
Wed Jun 6 17:21:04 PDT 2012


On Jun 6, 2012, at 5:03 PM, Eli Friedman wrote:

> 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.

Thanks for 2nd'ing John's. This is where it will go.
- fariborz

> 
> -Eli




More information about the cfe-commits mailing list