case bitc::TYPE_CODE_ARRAY: // ARRAY: [numelts, eltty]
if (Record.size() < 2)
return Error("Invalid record");
- if ((ResultTy = getTypeByID(Record[1])))
+ if ((ResultTy = getTypeByID(Record[1])) &&
+ StructType::isValidElementType(ResultTy))
ResultTy = ArrayType::get(ResultTy, Record[0]);
else
return Error("Invalid type");
case bitc::TYPE_CODE_VECTOR: // VECTOR: [numelts, eltty]
if (Record.size() < 2)
return Error("Invalid record");
- if ((ResultTy = getTypeByID(Record[1])))
+ if ((ResultTy = getTypeByID(Record[1])) &&
+ StructType::isValidElementType(ResultTy))
ResultTy = VectorType::get(ResultTy, Record[0]);
else
return Error("Invalid type");
RUN: FileCheck --check-prefix=FWDREF-TYPE %s
FWDREF-TYPE: Invalid record
+
+RUN: not llvm-dis -disable-output %p/Inputs/invalid-array-element-type.bc 2>&1 | \
+RUN: FileCheck --check-prefix=ELEMENT-TYPE %s
+RUN: not llvm-dis -disable-output %p/Inputs/invalid-vector-element-type.bc 2>&1 | \
+RUN: FileCheck --check-prefix=ELEMENT-TYPE %s
+
+ELEMENT-TYPE: Invalid type