[flang-commits] [flang] [flang][cuda] Accept cuf kernel do without scalar (PR #205705)
Valentin Clement バレンタイン クレメン via flang-commits
flang-commits at lists.llvm.org
Wed Jun 24 18:00:40 PDT 2026
https://github.com/clementval created https://github.com/llvm/llvm-project/pull/205705
The base compiler accept `!$cuf kernel do()` instead of raising an error. Update the parser to accept the same syntax.
`!$cuf kernel do()` is equivalent to `!$cuf kernel do`
>From 57d49597251a930d9444050a9a332bbee448dc3e Mon Sep 17 00:00:00 2001
From: Valentin Clement <clementval at gmail.com>
Date: Wed, 24 Jun 2026 17:59:13 -0700
Subject: [PATCH] [flang][cuda] Accept cuf kernel do without scalar
---
flang/lib/Parser/executable-parsers.cpp | 4 +++-
flang/test/Semantics/cuf23.cuf | 5 +++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/flang/lib/Parser/executable-parsers.cpp b/flang/lib/Parser/executable-parsers.cpp
index 2241c04f5d26d..01f8d56c21723 100644
--- a/flang/lib/Parser/executable-parsers.cpp
+++ b/flang/lib/Parser/executable-parsers.cpp
@@ -583,7 +583,9 @@ TYPE_PARSER("<<<" >>
TYPE_PARSER(sourced(beginDirective >> "$CUF KERNEL DO"_tok >>
construct<CUFKernelDoConstruct::Directive>(
- maybe(parenthesized(scalarIntConstantExpr)),
+ // Accept !$CUF KERNEL DO, !$CUF KERNEL DO(), and
+ // !$CUF KERNEL DO(<scalar-int-constant-expr>).
+ defaulted(parenthesized(maybe(scalarIntConstantExpr))),
maybe(Parser<CUFKernelDoConstruct::LaunchConfiguration>{}),
many(Parser<CUFReduction>{}) / endDirective)))
TYPE_CONTEXT_PARSER("!$CUF KERNEL DO construct"_en_US,
diff --git a/flang/test/Semantics/cuf23.cuf b/flang/test/Semantics/cuf23.cuf
index 93d875d9430ae..6291fcaaa752d 100644
--- a/flang/test/Semantics/cuf23.cuf
+++ b/flang/test/Semantics/cuf23.cuf
@@ -35,6 +35,11 @@ subroutine host()
do i = 1, 10
print*, a(i) ! ok
end do
+
+ !$cuf kernel do()
+ do i = 1, 10
+ print*, a(i) ! ok
+ end do
end subroutine
attributes(global) subroutine global1()
More information about the flang-commits
mailing list