================
@@ -2215,17 +2215,21 @@ ParseResult cir::FuncOp::parse(OpAsmParser &parser, 
OperationState &state) {
 
   // Parse CXXSpecialMember attribute
   if (parser.parseOptionalKeyword("special_member").succeeded()) {
-    cir::CXXCtorAttr ctorAttr;
-    cir::CXXDtorAttr dtorAttr;
-    cir::CXXAssignAttr assignAttr;
     if (parser.parseLess().failed())
       return failure();
-    if (parser.parseOptionalAttribute(ctorAttr).has_value())
-      state.addAttribute(specialMemberAttr, ctorAttr);
-    else if (parser.parseOptionalAttribute(dtorAttr).has_value())
-      state.addAttribute(specialMemberAttr, dtorAttr);
-    else if (parser.parseOptionalAttribute(assignAttr).has_value())
-      state.addAttribute(specialMemberAttr, assignAttr);
+
+    mlir::Attribute attr;
+    mlir::OptionalParseResult parseResult = 
parser.parseOptionalAttribute(attr);
+    if (parseResult.has_value()) {
+      if (failed(*parseResult))
+        return failure();
+      if (!mlir::isa<cir::CXXCtorAttr, cir::CXXDtorAttr, cir::CXXAssignAttr>(
+              attr))
+        return parser.emitError(parser.getCurrentLocation(),
+                                "expected a C++ special member attribute");
+      state.addAttribute(specialMemberAttr, attr);
+    }
----------------
Lancern wrote:

Updated.

https://github.com/llvm/llvm-project/pull/188069
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to