зеркало из https://github.com/microsoft/clang-1.git
Fixes an IRgen ICE due to cast of null pointer to
a vla type (fixes pr7827). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114495 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
7ccc58f9ff
Коммит
f443570387
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -50,3 +50,12 @@ void f_8403108(unsigned x) {
|
|||
}
|
||||
// CHECK: call void @llvm.stackrestore(i8*
|
||||
}
|
||||
|
||||
// pr7827
|
||||
void function(short width, int data[][width]) {}
|
||||
|
||||
void test() {
|
||||
// CHECK: call void @function(i16 signext 1, i32* null)
|
||||
function(1, 0);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче