[flang-commits] [flang] f9953d4 - [flang][cuda] Accept cuf kernel do without scalar (#205705)
via flang-commits
flang-commits at lists.llvm.org
Wed Jun 24 21:01:16 PDT 2026
Author: Valentin Clement (バレンタイン クレメン)
Date: 2026-06-24T21:01:10-07:00
New Revision: f9953d49dc4f2c8f747d8cbf2ed44bfdc1258b96
URL: https://github.com/llvm/llvm-project/commit/f9953d49dc4f2c8f747d8cbf2ed44bfdc1258b96
DIFF: https://github.com/llvm/llvm-project/commit/f9953d49dc4f2c8f747d8cbf2ed44bfdc1258b96.diff
LOG: [flang][cuda] Accept cuf kernel do without scalar (#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`
Added:
Modified:
flang/lib/Parser/executable-parsers.cpp
flang/test/Semantics/cuf23.cuf
Removed:
################################################################################
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