From ddc4860c1d6e06db2db5c08a01dc1ff3293d9daf Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 22 Nov 2004 19:15:27 +0000 Subject: [PATCH] Fix test/Regression/CFrontend/2003-11-01-EmptyStructCrash.c git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18115 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/VMCore/ConstantFold.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp index 02b7fe2975a..e2080642ca6 100644 --- a/lib/VMCore/ConstantFold.cpp +++ b/lib/VMCore/ConstantFold.cpp @@ -574,6 +574,7 @@ Constant *llvm::ConstantFoldCastInstruction(const Constant *V, const Type *ElTy = PTy->getElementType(); while (ElTy != DPTy->getElementType()) { if (const StructType *STy = dyn_cast(ElTy)) { + if (STy->getNumElements() == 0) break; ElTy = STy->getElementType(0); IdxList.push_back(Constant::getNullValue(Type::UIntTy)); } else if (const SequentialType *STy = dyn_cast(ElTy)) {