diff options
| author | Fariborz Jahanian <fjahanian@apple.com> | 2010-09-21 22:53:33 +0000 | 
|---|---|---|
| committer | Fariborz Jahanian <fjahanian@apple.com> | 2010-09-21 22:53:33 +0000 | 
| commit | 521c72c756be8f8b8e13d88cb651bd9fe200202f (patch) | |
| tree | 4420277695df27b442111be0c7aba21aa16f7ad9 /clang/lib | |
| parent | 61158f98ab50402652d81c4fdb80631751913793 (diff) | |
| download | bcm5719-llvm-521c72c756be8f8b8e13d88cb651bd9fe200202f.tar.gz bcm5719-llvm-521c72c756be8f8b8e13d88cb651bd9fe200202f.zip | |
Fixes an IRgen ICE due to cast of null pointer to
a vla type (fixes pr7827).
llvm-svn: 114495
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/CodeGen/CGExprScalar.cpp | 13 | 
1 files changed, 11 insertions, 2 deletions
| diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp index 73e94d1ece1..055e3f7e679 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/lib/CodeGen/CGExprScalar.cpp @@ -209,8 +209,17 @@ public:    }    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);    } | 

