Skip to content

Commit 3273d0b

Browse files
authored
[flang][cuda] Apply implicit data attribute only in device context (#119919)
Fix the condition so the implicit device data attribute is not applied when the routine has `attribute(host)`
1 parent e5e0f23 commit 3273d0b

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

flang/lib/Semantics/resolve-names.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8958,9 +8958,9 @@ void ResolveNamesVisitor::FinishSpecificationPart(
89588958
? currScope().symbol()->detailsIf<SubprogramDetails>()
89598959
: nullptr}) {
89608960
if (auto attrs{subp->cudaSubprogramAttrs()}) {
8961-
if (*attrs != common::CUDASubprogramAttrs::Device ||
8962-
*attrs != common::CUDASubprogramAttrs::Global ||
8963-
*attrs != common::CUDASubprogramAttrs::Grid_Global) {
8961+
if (*attrs == common::CUDASubprogramAttrs::Device ||
8962+
*attrs == common::CUDASubprogramAttrs::Global ||
8963+
*attrs == common::CUDASubprogramAttrs::Grid_Global) {
89648964
inDeviceSubprogram = true;
89658965
}
89668966
}

flang/test/Semantics/modfile55.cuf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ module m
1414
attributes(host,device) real function foo(x)
1515
foo = x + 1.
1616
end function
17+
attributes(host) subroutine hostsub(a)
18+
integer, intent(out) :: a(14)
19+
a = 99
20+
end subroutine
1721
end
1822

1923
!Expect: m.mod
@@ -39,4 +43,7 @@ end
3943
!real(4)::x
4044
!real(4)::foo
4145
!end
46+
attributes(host)subroutinehostsub(a)
47+
integer(4),intent(out)::a(1_8:14_8)
48+
end
4249
!end

0 commit comments

Comments
 (0)