On Tue, Sep 21, 2010 at 3:53 PM, Fariborz Jahanian <[email protected]> wrote: > Author: fjahanian > Date: Tue Sep 21 17:53:33 2010 > New Revision: 114495 > > URL: http://llvm.org/viewvc/llvm-project?rev=114495&view=rev > Log: > Fixes an IRgen ICE due to cast of null pointer to > a vla type (fixes pr7827). > > 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=114495&r1=114494&r2=114495&view=diff > ============================================================================== > --- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original) > +++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Tue Sep 21 17:53:33 2010 > @@ -209,8 +209,17 @@ > } > Value *VisitCastExpr(CastExpr *E) { > // Make sure to evaluate VLA bounds now so that we have them for later. > - if (E->getType()->isVariablyModifiedType()) > - CGF.EmitVLASize(E->getType()); > + if (E->getType()->isVariablyModifiedType()) { > + // Implicit cast of a null pointer to a vla type need not result in vla > + // size computation which is not always possible in any case (see > pr7827). > + bool NeedSize = true; > + if (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(E)) > + NeedSize = > + !ICE->getSubExpr()->isNullPointerConstant(CGF.getContext(), > + > Expr::NPC_ValueDependentIsNull); > + if (NeedSize) > + CGF.EmitVLASize(E->getType()); > + } > > return EmitCastExpr(E); > }
Why exactly does it matter if the subexpression is a null pointer constant? -Eli _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
