diff --git a/flang/lib/Semantics/check-cuda.cpp b/flang/lib/Semantics/check-cuda.cpp index eb91eb8bac81..e45f9fb8265e 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 084ad3ccd4d1..541a67a0542b 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