Fix ptr vector inconsistency in CreatePointerCast
[oota-llvm.git] / unittests / IR / InstructionsTest.cpp
index c2fdceb7eb52458dda78f90260e2a4e2147cbba8..ce6c465163d91029e6200bfd5af5da15e9a361d9 100644 (file)
@@ -197,6 +197,17 @@ TEST(InstructionsTest, CastInst) {
   EXPECT_TRUE(CastInst::isBitCastable(V2Int32PtrTy, V2Int64PtrTy));
   EXPECT_FALSE(CastInst::isBitCastable(V2Int32Ty, V2Int64Ty));
   EXPECT_FALSE(CastInst::isBitCastable(V2Int64Ty, V2Int32Ty));
+
+
+  // Check that assertion is not hit when creating a cast with a vector of
+  // pointers
+  // First form
+  BasicBlock *BB = BasicBlock::Create(C);
+  Constant *NullV2I32Ptr = Constant::getNullValue(V2Int32PtrTy);
+  CastInst::CreatePointerCast(NullV2I32Ptr, V2Int32Ty, "foo", BB);
+
+  // Second form
+  CastInst::CreatePointerCast(NullV2I32Ptr, V2Int32Ty);
 }
 
 TEST(InstructionsTest, VectorGep) {