Fix test/Regression/CFrontend/2003-11-01-EmptyStructCrash.c
authorChris Lattner <sabre@nondot.org>
Mon, 22 Nov 2004 19:15:27 +0000 (19:15 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 22 Nov 2004 19:15:27 +0000 (19:15 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18115 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/ConstantFold.cpp

index 02b7fe2975a981e596c4d0e65cee1fcc7b39fea4..e2080642ca620186084321d6abc907276da2893f 100644 (file)
@@ -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<StructType>(ElTy)) {
+          if (STy->getNumElements() == 0) break;
           ElTy = STy->getElementType(0);
           IdxList.push_back(Constant::getNullValue(Type::UIntTy));
         } else if (const SequentialType *STy = dyn_cast<SequentialType>(ElTy)) {