[flang-commits] [flang] [Flang][MIF] Adding support of intrinsics with coarray argument (PR #192944)

via flang-commits flang-commits at lists.llvm.org
Thu Jun 18 00:58:07 PDT 2026


================
@@ -792,31 +801,41 @@ static bool cannotBePointerOrHeapElementType(mlir::Type eleTy) {
 // BoxType
 //===----------------------------------------------------------------------===//
 
-// `box` `<` type (`, volatile` $volatile^)? `>`
+// `box` `<` type (`, volatile` $volatile^)? (`, corank: corank` $corank^)? `>`
 mlir::Type fir::BoxType::parse(mlir::AsmParser &parser) {
   mlir::Type eleTy;
   auto location = parser.getCurrentLocation();
   auto *context = parser.getContext();
   bool isVolatile = false;
+  int64_t corank = 0;
   if (parser.parseLess() || parser.parseType(eleTy))
     return {};
-  if (parseOptionalCommaAndKeyword(parser, getVolatileKeyword(), isVolatile))
-    return {};
+  if (mlir::succeeded(parser.parseOptionalComma())) {
+    if (mlir::succeeded(parser.parseOptionalKeyword(getVolatileKeyword())))
+      isVolatile = true;
+    else if (mlir::succeeded(parser.parseKeyword(getCorankKeyword())))
+      if (mlir::succeeded(parser.parseOptionalColon()))
+        if (!mlir::succeeded(parser.parseInteger(corank)))
+          return {};
----------------
jeanPerier wrote:

It looks like volatile and corank are exclusive in the parser here (the parser only expects one or the other). Is this in line with the Fortran standard requirements for coarrays and VOLATILE? 

https://github.com/llvm/llvm-project/pull/192944


More information about the flang-commits mailing list