[flang-commits] [flang] baa1e50 - [flang][cuda] Do not consider kernel result as host variable (#190626)

via flang-commits flang-commits at lists.llvm.org
Mon Apr 6 09:39:44 PDT 2026


Author: Valentin Clement (バレンタイン クレメン)
Date: 2026-04-06T16:39:38Z
New Revision: baa1e5008bba4bf9a6204b7d0620a95312cb304b

URL: https://github.com/llvm/llvm-project/commit/baa1e5008bba4bf9a6204b7d0620a95312cb304b
DIFF: https://github.com/llvm/llvm-project/commit/baa1e5008bba4bf9a6204b7d0620a95312cb304b.diff

LOG: [flang][cuda] Do not consider kernel result as host variable (#190626)

Added: 
    

Modified: 
    flang/lib/Semantics/check-cuda.cpp
    flang/test/Semantics/cuf25.cuf

Removed: 
    


################################################################################
diff  --git a/flang/lib/Semantics/check-cuda.cpp b/flang/lib/Semantics/check-cuda.cpp
index eb91eb8bac81c..e45f9fb8265e5 100644
--- a/flang/lib/Semantics/check-cuda.cpp
+++ b/flang/lib/Semantics/check-cuda.cpp
@@ -138,13 +138,13 @@ struct FindHostArray
   using Base::operator();
   Result operator()(const evaluate::Component &x) const {
     const Symbol &symbol{x.GetLastSymbol()};
-    if (symbol.IsFuncResult()) {
+    const Symbol &baseSymbol{x.base().GetFirstSymbol()};
+    if (symbol.IsFuncResult() || baseSymbol.IsFuncResult()) {
       return nullptr;
     }
     if (!IsHostArray(symbol)) {
       return nullptr;
     }
-    const Symbol &baseSymbol{x.base().GetFirstSymbol()};
     if (IsDummy(baseSymbol) && IsCUDADeviceContext(&baseSymbol.owner())) {
       return nullptr;
     }

diff  --git a/flang/test/Semantics/cuf25.cuf b/flang/test/Semantics/cuf25.cuf
index 084ad3ccd4d1c..541a67a0542b1 100644
--- a/flang/test/Semantics/cuf25.cuf
+++ b/flang/test/Semantics/cuf25.cuf
@@ -4,6 +4,9 @@ module m
   type bar
     integer, allocatable :: m(:)
   end type
+  type r1
+    real :: origin(3)
+  end type r1
 contains
   attributes(global) subroutine g1( a )
     type(bar) :: a
@@ -11,4 +14,9 @@ contains
     a%m(i) = i
     return
   end subroutine
+  attributes(device) function rayConstructor(origin, dir) result(r)
+    real :: origin(3), dir(3)
+    type(r1) :: r
+    r%origin = origin
+  end function
 end module m


        


More information about the flang-commits mailing list