if (getValueTypePair(Record, OpNum, NextValueNo, BasePtr))
return Error("Invalid record");
+ if (Ty &&
+ Ty !=
+ cast<SequentialType>(BasePtr->getType()->getScalarType())
+ ->getElementType())
+ return Error(
+ "Explicit gep type does not match pointee type of pointer operand");
+
SmallVector<Value*, 16> GEPIdx;
while (OpNum != Record.size()) {
Value *Op;
}
I = GetElementPtrInst::Create(Ty, BasePtr, GEPIdx);
- if (Ty && Ty != cast<GetElementPtrInst>(I)->getSourceElementType())
- return Error("Invalid record");
+
InstructionList.push_back(I);
if (InBounds)
cast<GetElementPtrInst>(I)->setIsInBounds(true);
RUN: FileCheck --check-prefix=BAD-BITWIDTH %s
RUN: not llvm-dis -disable-output %p/Inputs/invalid-align.bc 2>&1 | \
RUN: FileCheck --check-prefix=BAD-ALIGN %s
+RUN: not llvm-dis -disable-output %p/Inputs/invalid-gep-mismatched-explicit-type.bc 2>&1 | \
+RUN: FileCheck --check-prefix=MISMATCHED-EXPLICIT-GEP %s
INVALID-ENCODING: Invalid encoding
BAD-ABBREV: Abbreviation starts with an Array or a Blob
BAD-TYPE-TABLE-FORWARD-REF: Invalid TYPE table: Only named structs can be forward referenced
BAD-BITWIDTH: Bitwidth for integer type out of range
BAD-ALIGN: Invalid alignment value
+MISMATCHED-EXPLICIT-GEP: Explicit gep type does not match pointee type of pointer operand
RUN: not llvm-dis -disable-output %p/Inputs/invalid-extractval-array-idx.bc 2>&1 | \
RUN: FileCheck --check-prefix=EXTRACT-ARRAY %s