When checking an actual argument for any CUDA data attributes, be sure to check the symbols in a designator like a%b%c in order, taking the last symbol that has a CUDA attribute. And be sure to interpret a function result symbol of a device function as a device object, at least for generic interface resolution for defined assignments and operators. This patch exposed errors in flang/test/Semantics/bug1214.cuf, which have been fixed.
49 lines
1.3 KiB
Text
49 lines
1.3 KiB
Text
! RUN: %flang_fc1 -fdebug-unparse %s 2>&1 | FileCheck %s
|
|
module overrides
|
|
type realResult
|
|
real a
|
|
end type
|
|
interface operator(*)
|
|
procedure :: multHostDevice, multDeviceHost
|
|
end interface
|
|
interface assignment(=)
|
|
procedure :: assignHostResult, assignDeviceResult
|
|
end interface
|
|
contains
|
|
elemental function multHostDevice(x, y) result(result)
|
|
real, intent(in) :: x
|
|
real, intent(in), device :: y
|
|
type(realResult) result
|
|
result%a = x * (y)
|
|
end
|
|
elemental function multDeviceHost(x, y) result(result)
|
|
real, intent(in), device :: x
|
|
real, intent(in) :: y
|
|
type(realResult) result
|
|
result%a = (x) * y
|
|
end
|
|
elemental subroutine assignHostResult(lhs, rhs)
|
|
real, intent(out) :: lhs
|
|
type(realResult), intent(in) :: rhs
|
|
lhs = rhs%a
|
|
end
|
|
elemental subroutine assignDeviceResult(lhs, rhs)
|
|
real, intent(out), device :: lhs
|
|
type(realResult), intent(in) :: rhs
|
|
lhs = rhs%a
|
|
end
|
|
end
|
|
|
|
program p
|
|
use overrides
|
|
real, device :: da, db
|
|
real :: ha, hb
|
|
!CHECK: CALL assigndeviceresult(db,multhostdevice(2._4,da))
|
|
db = 2. * da
|
|
!CHECK: CALL assigndeviceresult(db,multdevicehost(da,2._4))
|
|
db = da * 2.
|
|
!CHECK: CALL assignhostresult(ha,multhostdevice(2._4,da))
|
|
ha = 2. * da
|
|
!CHECK: CALL assignhostresult(ha,multdevicehost(da,2._4))
|
|
ha = da * 2.
|
|
end
|