[flang-commits] [flang] d2163f7 - [flang][cuda] Error out if pause statement is used in device code (#203642)
via flang-commits
flang-commits at lists.llvm.org
Fri Jun 12 14:52:20 PDT 2026
Author: Valentin Clement (バレンタイン クレメン)
Date: 2026-06-12T14:52:16-07:00
New Revision: d2163f7c0c21390190e1ccb91e61958ad6ecc9f9
URL: https://github.com/llvm/llvm-project/commit/d2163f7c0c21390190e1ccb91e61958ad6ecc9f9
DIFF: https://github.com/llvm/llvm-project/commit/d2163f7c0c21390190e1ccb91e61958ad6ecc9f9.diff
LOG: [flang][cuda] Error out if pause statement is used in device code (#203642)
Added:
Modified:
flang/lib/Semantics/check-cuda.cpp
flang/test/Semantics/cuf09.cuf
Removed:
################################################################################
diff --git a/flang/lib/Semantics/check-cuda.cpp b/flang/lib/Semantics/check-cuda.cpp
index 84f8e3bf2d5ed..7d2c012d3a4dc 100644
--- a/flang/lib/Semantics/check-cuda.cpp
+++ b/flang/lib/Semantics/check-cuda.cpp
@@ -298,6 +298,10 @@ template <bool CUF_KERNEL> struct ActionStmtChecker {
SemanticsContext &context, const parser::ContinueStmt &) {
return {};
}
+ static MaybeMsg WhyNotOk(SemanticsContext &, const parser::PauseStmt &) {
+ return parser::MessageFormattedText{
+ "device subprograms may not contain PAUSE statements"_err_en_US};
+ }
static MaybeMsg WhyNotOk(SemanticsContext &context, const parser::IfStmt &x) {
if (auto result{CheckUnwrappedExpr(
context, std::get<parser::ScalarLogicalExpr>(x.t))}) {
diff --git a/flang/test/Semantics/cuf09.cuf b/flang/test/Semantics/cuf09.cuf
index 4bcb47af88e1f..9f0eb8f500b6c 100644
--- a/flang/test/Semantics/cuf09.cuf
+++ b/flang/test/Semantics/cuf09.cuf
@@ -78,6 +78,13 @@ module m
stop ! ok
end subroutine
+ attributes(global) subroutine pausetest()
+ !ERROR: device subprograms may not contain PAUSE statements
+ pause
+ !ERROR: device subprograms may not contain PAUSE statements
+ pause 1
+ end subroutine
+
attributes(global) subroutine cycletest()
integer :: i
do i = 1, 10
More information about the flang-commits
mailing list