diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp --- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp +++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp @@ -1464,11 +1464,13 @@ auto &body = method.body(); const char *checkAttrSizedValueSegmentsCode = R"( - auto sizeAttr = getAttrOfType("{0}"); - auto numElements = sizeAttr.getType().cast().getNumElements(); - if (numElements != {1}) {{ - return emitOpError("'{0}' attribute for specifying {2} segments " - "must have {1} elements"); + { + auto sizeAttr = getAttrOfType("{0}"); + auto numElements = sizeAttr.getType().cast().getNumElements(); + if (numElements != {1}) {{ + return emitOpError("'{0}' attribute for specifying {2} segments " + "must have {1} elements"); + } } )";