[mlir][IR] Diagnose index element type in DenseArrayAttr (#179075)
This commit is contained in:
parent
584bd38627
commit
7f967a9a26
2 changed files with 24 additions and 2 deletions
|
|
@ -923,7 +923,7 @@ Attribute Parser::parseDenseArrayAttr(Type attrType) {
|
|||
|
||||
// Only bool or integer and floating point elements divisible by bytes are
|
||||
// supported.
|
||||
if (!eltType.isIntOrIndexOrFloat()) {
|
||||
if (!eltType.isIntOrFloat()) {
|
||||
emitError(typeLoc, "expected integer or float type, got: ") << eltType;
|
||||
return {};
|
||||
}
|
||||
|
|
@ -940,7 +940,7 @@ Attribute Parser::parseDenseArrayAttr(Type attrType) {
|
|||
return {};
|
||||
|
||||
DenseArrayElementParser eltParser(eltType);
|
||||
if (eltType.isIntOrIndex()) {
|
||||
if (isa<IntegerType>(eltType)) {
|
||||
if (parseCommaSeparatedList(
|
||||
[&] { return eltParser.parseIntegerElement(*this); }))
|
||||
return {};
|
||||
|
|
|
|||
22
mlir/test/IR/invalid-dense-array-attr.mlir
Normal file
22
mlir/test/IR/invalid-dense-array-attr.mlir
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
// RUN: mlir-opt %s -split-input-file -verify-diagnostics
|
||||
|
||||
// -----
|
||||
// Reject index element type in dense array attribute.
|
||||
// expected-error@+1 {{expected integer or float type, got: 'index'}}
|
||||
module attributes { a = array<index: 1, 2> } {}
|
||||
|
||||
// -----
|
||||
// Reject tensor element type in dense array attribute.
|
||||
// expected-error@+1 {{expected integer or float type, got: 'tensor<2xi32>'}}
|
||||
module attributes { a = array<tensor<2xi32>: 1, 2> } {}
|
||||
|
||||
// -----
|
||||
// Reject memref element type in dense array attribute.
|
||||
// expected-error@+1 {{expected integer or float type, got: 'memref<2xi32>'}}
|
||||
module attributes { a = array<memref<2xi32>: 1, 2> } {}
|
||||
|
||||
// -----
|
||||
// Reject complex element type in dense array attribute.
|
||||
// expected-error@+1 {{expected integer or float type, got: 'complex<f32>'}}
|
||||
module attributes { a = array<complex<f32>: 1, 2> } {}
|
||||
|
||||
Loading…
Reference in a new issue