return Type();
}
+ // According to the SPIR-V spec:
+ // "Length is the number of elements in the array. It must be at least 1."
+ if (!count) {
+ emitError(loc, "expected array length greater than 0");
+ return Type();
+ }
+
if (spec.trim().empty()) {
emitError(loc, "expected element type");
return Type();
};
ArrayType ArrayType::get(Type elementType, unsigned elementCount) {
+ assert(elementCount && "ArrayType needs at least one element");
return Base::get(elementType.getContext(), TypeKind::Array, elementType,
elementCount, 0);
}
ArrayType ArrayType::get(Type elementType, unsigned elementCount,
ArrayType::LayoutInfo layoutInfo) {
+ assert(elementCount && "ArrayType needs at least one element");
return Base::get(elementType.getContext(), TypeKind::Array, elementType,
elementCount, layoutInfo);
}
// -----
+// expected-error @+1 {{expected array length greater than 0}}
+func @array_type_zero_length(!spv.array<0xf32>) -> ()
+
+// -----
+
//===----------------------------------------------------------------------===//
// PointerType
//===----------------------------------------------------------------------===//