llvm-project/flang/test/Semantics/definable05.cuf
Peter Klausler f513bd8088
[flang] CUDA Fortran - part 4/5: definability and characteristics
Extend the definability and procedure characteristics checking
infrastructure in semantics to check for context-dependent CUDA object
definability violations and problems with CUDA attribute incompatibility
in procedure interfaces.

Depends on https://reviews.llvm.org/D150159,
https://reviews.llvm.org/D150161, & https://reviews.llvm.org/D150162.

Differential Revision: https://reviews.llvm.org/D150163
2023-05-31 14:25:38 -07:00

32 lines
1.2 KiB
Plaintext

! RUN: %python %S/test_errors.py %s %flang_fc1
module m
real, constant :: rc
!ERROR: Object 'rcp' with ATTRIBUTES(CONSTANT) may not be allocatable, pointer, or target
real, constant, pointer :: rcp
!ERROR: Object 'rct' with ATTRIBUTES(CONSTANT) may not be allocatable, pointer, or target
real, constant, target :: rct
real, device, pointer :: dp(:)
real, device, target :: dt(100)
contains
attributes(device) subroutine devsub
!ERROR: Left-hand side of assignment is not definable
!BECAUSE: 'rc' has ATTRIBUTES(CONSTANT) and is not definable in a device subprogram
rc = 1.
!ERROR: The left-hand side of a pointer assignment is not definable
!BECAUSE: 'dp' is a pointer and may not be associated in a device subprogram
dp => dt
end
attributes(global) subroutine globsub
!ERROR: Left-hand side of assignment is not definable
!BECAUSE: 'rc' has ATTRIBUTES(CONSTANT) and is not definable in a device subprogram
rc = 1.
!ERROR: The left-hand side of a pointer assignment is not definable
!BECAUSE: 'dp' is a pointer and may not be associated in a device subprogram
dp => dt
end
subroutine hostsub
rc = 1.
dp => dt
end
end