From 856deb7287234fdc8206627327c85611fbcef1d0 Mon Sep 17 00:00:00 2001 From: Valentin Clement Date: Wed, 22 Oct 2025 10:33:12 -0700 Subject: [PATCH] [flang][cuda] Do not consider function result as host array --- flang/lib/Semantics/check-cuda.cpp | 3 +++ flang/test/Semantics/cuf09.cuf | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/flang/lib/Semantics/check-cuda.cpp b/flang/lib/Semantics/check-cuda.cpp index 3d2db6a9c8aa9..caa9bdd28f1f4 100644 --- a/flang/lib/Semantics/check-cuda.cpp +++ b/flang/lib/Semantics/check-cuda.cpp @@ -131,6 +131,9 @@ struct FindHostArray return (*this)(x.base()); } Result operator()(const Symbol &symbol) const { + if (symbol.IsFuncResult()) { + return nullptr; + } if (const auto *details{ symbol.GetUltimate().detailsIf()}) { if (details->IsArray() && diff --git a/flang/test/Semantics/cuf09.cuf b/flang/test/Semantics/cuf09.cuf index 9178b0a63adbe..df6568df9b480 100644 --- a/flang/test/Semantics/cuf09.cuf +++ b/flang/test/Semantics/cuf09.cuf @@ -36,6 +36,12 @@ module m if (i .le. N) a(i) = m(i) end subroutine + attributes(device) function devfct(r1, r2) result(res) + real(4), intent(in) :: r1(3), r2(3) + real(4) :: res(3) + res = r1 - r2 ! Do not error on function result + end function + attributes(global) subroutine hostparameter(a) integer :: a(*) i = threadIdx%x