Skip to content

Commit 55913c8

Browse files
committed
implicitly set device attribute for variables have VALUE attribute inside device routine
1 parent 77c8d21 commit 55913c8

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

flang/lib/Semantics/resolve-names.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9375,8 +9375,7 @@ void ResolveNamesVisitor::CreateGeneric(const parser::GenericSpec &x) {
93759375
static void SetImplicitCUDADevice(bool inDeviceSubprogram, Symbol &symbol) {
93769376
if (inDeviceSubprogram && symbol.has<ObjectEntityDetails>()) {
93779377
auto *object{symbol.detailsIf<ObjectEntityDetails>()};
9378-
if (!object->cudaDataAttr() && !IsValue(symbol) &&
9379-
!IsFunctionResult(symbol)) {
9378+
if (!object->cudaDataAttr() && !IsFunctionResult(symbol)) {
93809379
// Implicitly set device attribute if none is set in device context.
93819380
object->set_cudaDataAttr(common::CUDADataAttr::Device);
93829381
}

flang/test/Semantics/cuf21.cuf

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
! RUN: %python %S/test_errors.py %s %flang_fc1
2-
! Test generic matching with scalars argument without device attr
2+
! Test generic matching with scalars argument and argument
3+
! with VALUE attribute without DEVICE attr inside device routine
34

45
module mlocModule
56
interface maxlocUpdate
@@ -9,19 +10,22 @@ module mlocModule
910
end interface maxlocUpdate
1011
contains
1112

12-
attributes(global) subroutine maxlocPartialMaskR_32F1D()
13+
attributes(global) subroutine maxlocPartialMaskR_32F1D(back)
1314
implicit none
15+
logical, intent(in), value :: back
1416
real(4) :: mval
1517

16-
call maxlocUpdate(mval)
18+
call maxlocUpdate(mval, back)
1719

1820
end subroutine maxlocPartialMaskR_32F1D
1921

20-
attributes(device) subroutine maxlocUpdateR_32F(mval)
22+
attributes(device) subroutine maxlocUpdateR_32F(mval, back)
2123
real(4) :: mval
24+
logical :: back
2225
end subroutine maxlocUpdateR_32F
2326

24-
attributes(device) subroutine maxlocUpdateR_64F(mval)
27+
attributes(device) subroutine maxlocUpdateR_64F(mval, back)
2528
real(8) :: mval
29+
logical :: back
2630
end subroutine maxlocUpdateR_64F
2731
end module

flang/test/Semantics/modfile55.cuf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ end
3333
!contains
3434
!attributes(global) subroutine globsub(x,y,z)
3535
!real(4),value::x
36+
!attributes(device)x
3637
!real(4)::y
3738
!attributes(device) y
3839
!real(4)::z

0 commit comments

Comments
 (0)