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

Jean-Didier PAILLEUX via flang-commits flang-commits at lists.llvm.org
Thu Jun 18 05:07:31 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 {};
----------------
JDPailleux wrote:

Yes because if we take a look in the Fortran Standard 2023 on C871 (8.5.20), the VOLATILE attribute shall not be specified for a coarray. Maybe I can add a comment on that here which points to the standard to explain the choice ?

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


More information about the flang-commits mailing list