Author: Sirui Mu
Date: 2026-03-24T22:40:13+08:00
New Revision: 0328820004d89ca9876ac75c8c55f1eb239a6be7

URL: 
https://github.com/llvm/llvm-project/commit/0328820004d89ca9876ac75c8c55f1eb239a6be7
DIFF: 
https://github.com/llvm/llvm-project/commit/0328820004d89ca9876ac75c8c55f1eb239a6be7.diff

LOG: [CIR][NFC] Fix regression in clang/test/CIR/IR/func.cir (#188069)

This patch fixes a regression in `clang/test/CIR/IR/func.cir` where the
parsing of `special_member` attributes fails.

Added: 
    

Modified: 
    clang/lib/CIR/Dialect/IR/CIRDialect.cpp
    clang/test/CIR/IR/invalid-func.cir

Removed: 
    


################################################################################
diff  --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp 
b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
index bf369bfe69991..eb322d135a804 100644
--- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
+++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
@@ -2215,17 +2215,18 @@ 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;
+    if (parser.parseAttribute(attr).failed())
+      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);
+
     if (parser.parseGreater().failed())
       return failure();
   }

diff  --git a/clang/test/CIR/IR/invalid-func.cir 
b/clang/test/CIR/IR/invalid-func.cir
index 6c06079ed8fd8..5fc1c2a53db09 100644
--- a/clang/test/CIR/IR/invalid-func.cir
+++ b/clang/test/CIR/IR/invalid-func.cir
@@ -1,4 +1,4 @@
-// RUN: cir-opt %s -verify-diagnostics
+// RUN: cir-opt %s -verify-diagnostics -split-input-file
 
 module {
   cir.func @l0() {
@@ -9,3 +9,11 @@ module {
     cir.return
   }
 }
+
+// -----
+
+module {
+  cir.func @l0() special_member<> { // expected-error {{expected attribute 
value}}
+    cir.return
+  }
+}


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

Reply via email to