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

John McCall rjmccall at apple.com
Thu Jun 7 11:20:00 PDT 2012


On Jun 7, 2012, at 11:18 AM, jahanian wrote:
> On Jun 7, 2012, at 10:31 AM, John McCall wrote:
>> On Jun 7, 2012, at 10:07 AM, Fariborz Jahanian wrote:
>>> Author: fjahanian
>>> Date: Thu Jun  7 12:07:15 2012
>>> New Revision: 158153
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=158153&view=rev
>>> Log:
>>> When emitting compund literal of vla pointer elements, make 
>>> sure to emit vla size to prevent an irgen crash.
>>> // rdar://11485774
>>> 
>>> Modified:
>>>  cfe/trunk/lib/CodeGen/CGExpr.cpp
>>>  cfe/trunk/test/CodeGen/vla.c
>>> 
>>> Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=158153&r1=158152&r2=158153&view=diff
>>> ==============================================================================
>>> --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
>>> +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu Jun  7 12:07:15 2012
>>> @@ -2114,7 +2114,11 @@
>>>   llvm::Value *GlobalPtr = CGM.GetAddrOfConstantCompoundLiteral(E);
>>>   return MakeAddrLValue(GlobalPtr, E->getType());
>>> }
>>> -
>>> +  if (const PointerType *pointerType = E->getType()->getAs<PointerType>())
>>> +    if (pointerType->getPointeeType()->isVariableArrayType())
>>> +      // make sure to emit the VLA size.
>>> +    EmitVariablyModifiedType(pointerType->getPointeeType());
>>> +  
>> 
>> Please just test E->getType()->isVariablyModifiedType() instead of looking
> 
> Yes, in r158157.
> 
>> specifically for a pointer to VLA.  The test case here would be even more
>> contrived, but something like:
>> int n = 20, **a;
>> (int (**)[i]){&a}[0][1][5] = 0;
> 
> Also added this test.

Thanks!

John.




More information about the cfe-commits mailing list