[flang-commits] [flang] [flang][cuda] Accept cuf kernel do without scalar (PR #205705)
via flang-commits
flang-commits at lists.llvm.org
Wed Jun 24 18:01:18 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-semantics
Author: Valentin Clement (バレンタイン クレメン) (clementval)
<details>
<summary>Changes</summary>
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`
---
Full diff: https://github.com/llvm/llvm-project/pull/205705.diff
2 Files Affected:
- (modified) flang/lib/Parser/executable-parsers.cpp (+3-1)
- (modified) flang/test/Semantics/cuf23.cuf (+5)
``````````diff
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()
``````````
</details>
https://github.com/llvm/llvm-project/pull/205705
More information about the flang-commits
mailing list