[Mlir-commits] [mlir] 15543b2 - [mlir] Emit an error when dense i1 array values are not `true` or `false` (#173533)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Dec 25 17:43:04 PST 2025
Author: Longsheng Mou
Date: 2025-12-26T09:43:00+08:00
New Revision: 15543b2c0b550d3c1cf4daa5ff11179c63433fd8
URL: https://github.com/llvm/llvm-project/commit/15543b2c0b550d3c1cf4daa5ff11179c63433fd8
DIFF: https://github.com/llvm/llvm-project/commit/15543b2c0b550d3c1cf4daa5ff11179c63433fd8.diff
LOG: [mlir] Emit an error when dense i1 array values are not `true` or `false` (#173533)
Fixes #173373.
Added:
Modified:
mlir/lib/AsmParser/AttributeParser.cpp
mlir/test/IR/invalid-builtin-attributes.mlir
Removed:
################################################################################
diff --git a/mlir/lib/AsmParser/AttributeParser.cpp b/mlir/lib/AsmParser/AttributeParser.cpp
index dcb21e7d0831d..374471fd3ed41 100644
--- a/mlir/lib/AsmParser/AttributeParser.cpp
+++ b/mlir/lib/AsmParser/AttributeParser.cpp
@@ -883,6 +883,8 @@ ParseResult DenseArrayElementParser::parseIntegerElement(Parser &p) {
!type.isUnsignedInteger());
p.consumeToken();
} else if (p.consumeIf(Token::integer)) {
+ if (type.isInteger(1))
+ return p.emitError("expected 'true' or 'false' values for i1 type");
value = buildAttributeAPInt(type, isNegative, spelling);
if (!value)
return p.emitError("integer constant out of range");
diff --git a/mlir/test/IR/invalid-builtin-attributes.mlir b/mlir/test/IR/invalid-builtin-attributes.mlir
index 58d4940eaf874..0d00b3141fbc6 100644
--- a/mlir/test/IR/invalid-builtin-attributes.mlir
+++ b/mlir/test/IR/invalid-builtin-attributes.mlir
@@ -580,6 +580,16 @@ func.func @duplicate_dictionary_attr_key() {
// -----
+// expected-error at below {{expected i1 type for 'true' or 'false' values}}
+#attr = array<i8: true>
+
+// -----
+
+// expected-error at below {{expected 'true' or 'false' values for i1 type}}
+#attr = array<i1: 0>
+
+// -----
+
// expected-error at below {{expected '[' after 'distinct'}}
#attr = distinct<
More information about the Mlir-commits
mailing list