[flang-commits] [flang] a309c07 - [flang][cuda] Allow if stmt in device subroutine (#89347)
via flang-commits
flang-commits at lists.llvm.org
Fri Apr 19 07:30:30 PDT 2024
Author: Valentin Clement (バレンタイン クレメン)
Date: 2024-04-19T07:30:26-07:00
New Revision: a309c07ad3fc4a9b0bf41a4e66e812b54338aa02
URL: https://github.com/llvm/llvm-project/commit/a309c07ad3fc4a9b0bf41a4e66e812b54338aa02
DIFF: https://github.com/llvm/llvm-project/commit/a309c07ad3fc4a9b0bf41a4e66e812b54338aa02.diff
LOG: [flang][cuda] Allow if stmt in device subroutine (#89347)
Added:
Modified:
flang/lib/Semantics/check-cuda.cpp
flang/test/Semantics/cuf11.cuf
Removed:
################################################################################
diff --git a/flang/lib/Semantics/check-cuda.cpp b/flang/lib/Semantics/check-cuda.cpp
index fb1ebadd378586..a9e57de7e2f2b5 100644
--- a/flang/lib/Semantics/check-cuda.cpp
+++ b/flang/lib/Semantics/check-cuda.cpp
@@ -344,6 +344,9 @@ template <bool IsCUFKernelDo> class DeviceContextChecker {
[&](const common::Indirection<parser::BackspaceStmt> &x) {
WarnOnIoStmt(source);
},
+ [&](const common::Indirection<parser::IfStmt> &x) {
+ Check(x.value());
+ },
[&](const auto &x) {
if (auto msg{ActionStmtChecker<IsCUFKernelDo>::WhyNotOk(x)}) {
context_.Say(source, std::move(*msg));
@@ -369,6 +372,13 @@ template <bool IsCUFKernelDo> class DeviceContextChecker {
Check(std::get<parser::Block>(eb->t));
}
}
+ void Check(const parser::IfStmt &is) {
+ const auto &uS{
+ std::get<parser::UnlabeledStatement<parser::ActionStmt>>(is.t)};
+ CheckUnwrappedExpr(
+ context_, uS.source, std::get<parser::ScalarLogicalExpr>(is.t));
+ Check(uS.statement, uS.source);
+ }
void Check(const parser::LoopControl::Bounds &bounds) {
Check(bounds.lower);
Check(bounds.upper);
diff --git a/flang/test/Semantics/cuf11.cuf b/flang/test/Semantics/cuf11.cuf
index de7ff29743242b..554ac258e55101 100644
--- a/flang/test/Semantics/cuf11.cuf
+++ b/flang/test/Semantics/cuf11.cuf
@@ -30,3 +30,7 @@ logical function compare_h(a,b)
!ERROR: 'b' is not an object of derived type; it is implicitly typed
compare_h = (a%h .eq. b%h)
end
+
+attributes(global) subroutine sub2()
+ if (threadIdx%x == 1) print *, "I'm number one"
+end subroutine
More information about the flang-commits
mailing list