diff --git a/mlir/lib/Parser/AttributeParser.cpp b/mlir/lib/Parser/AttributeParser.cpp index d7087de8aad9..9807443c7066 100644 --- a/mlir/lib/Parser/AttributeParser.cpp +++ b/mlir/lib/Parser/AttributeParser.cpp @@ -833,6 +833,7 @@ Attribute Parser::parseDenseElementsAttr(Type attrType) { /// Parse an opaque elements attribute. Attribute Parser::parseOpaqueElementsAttr(Type attrType) { + llvm::SMLoc loc = getToken().getLoc(); consumeToken(Token::kw_opaque); if (parseToken(Token::less, "expected '<' after 'opaque'")) return nullptr; @@ -857,7 +858,8 @@ Attribute Parser::parseOpaqueElementsAttr(Type attrType) { std::string data; if (parseElementAttrHexValues(*this, hexTok, data)) return nullptr; - return OpaqueElementsAttr::get(builder.getStringAttr(name), type, data); + return getChecked(loc, builder.getStringAttr(name), type, + data); } /// Shaped type for elements attribute. diff --git a/mlir/test/IR/attribute.mlir b/mlir/test/IR/attribute.mlir index 63c05c0cd057..5da93acb80ff 100644 --- a/mlir/test/IR/attribute.mlir +++ b/mlir/test/IR/attribute.mlir @@ -645,3 +645,7 @@ func @erroneous_fields() { return } +// ----- + +// expected-error @+1 {{invalid dialect namespace '"string with space"'}} +#invalid_dialect = opaque<"string with space", "0xDEADBEEF"> : tensor<100xi32>