forked from OSchip/llvm-project
[flang] Finish test/semantics/call12.f90
Original-commit: flang-compiler/f18@d002f0ce37 Reviewed-on: https://github.com/flang-compiler/f18/pull/711 Tree-same-pre-rewrite: false
This commit is contained in:
parent
99757783d2
commit
9dee00eccc
|
@ -15,5 +15,65 @@
|
|||
! Test 15.7 C1594 - prohibited assignments in PURE subprograms
|
||||
|
||||
module m
|
||||
! TODO pmk
|
||||
type :: t
|
||||
real :: a
|
||||
end type
|
||||
type(t) :: x
|
||||
type :: hasPtr
|
||||
real, pointer :: p
|
||||
end type
|
||||
contains
|
||||
pure subroutine msubr
|
||||
! ERROR: A PURE subprogram must not define a host-associated object.
|
||||
x%a = 0.
|
||||
end subroutine
|
||||
end module
|
||||
|
||||
pure function test(ptr, in)
|
||||
use m
|
||||
type(t), pointer :: ptr, ptr2
|
||||
type(t), target, intent(in) :: in
|
||||
type(t), save :: co[*]
|
||||
type(t) :: y, z
|
||||
type(hasPtr) :: hp
|
||||
type(hasPtr) :: alloc
|
||||
integer :: n
|
||||
common /block/ y
|
||||
! ERROR: A PURE subprogram must not define an object in COMMON.
|
||||
y%a = 0. ! C1594(1)
|
||||
! ERROR: A PURE subprogram must not define a USE-associated object.
|
||||
x%a = 0. ! C1594(1)
|
||||
! ERROR: A PURE function must not define a pointer dummy argument.
|
||||
ptr%a = 0. ! C1594(1)
|
||||
! ERROR: A PURE subprogram must not define an INTENT(IN) dummy argument.
|
||||
in%a = 0. ! C1594(1)
|
||||
! ERROR: A PURE subprogram must not define a coindexed object.
|
||||
co[1]%a = 0. ! C1594(1)
|
||||
! ERROR: A PURE function must not define a pointer dummy argument.
|
||||
ptr => y ! C1594(2)
|
||||
! ERROR: A PURE subprogram must not define a pointer dummy argument.
|
||||
nullify(ptr) ! C1594(2), 19.6.8
|
||||
! ERROR: A PURE subprogram must not use a pointer dummy argument as the target of pointer assignment.
|
||||
ptr2 => ptr ! C1594(3)
|
||||
! ERROR: A PURE subprogram must not use an INTENT(IN) dummy argument as the target of pointer assignment.
|
||||
ptr2 => in ! C1594(3)
|
||||
! ERROR: A PURE subprogram must not use an object in COMMON as the target of pointer assignment.
|
||||
n = size([hasPtr(y%a)]) ! C1594(4)
|
||||
! ERROR: A PURE subprogram must not use a USE-associated object as the target of pointer assignment.
|
||||
n = size([hasPtr(x%a)]) ! C1594(4)
|
||||
! ERROR: A PURE function must not use a pointer dummy argument as the target of pointer assignment.
|
||||
n = size([hasPtr(ptr%a)]) ! C1594(4)
|
||||
! ERROR: A PURE subprogram must not use an INTENT(IN) dummy argument as the target of pointer assignment.
|
||||
n = size([hasPtr(in%a)]) ! C1594(4)
|
||||
! ERROR: A PURE subprogram must not assign to a variable with a POINTER component.
|
||||
hp = hp ! C1594(5)
|
||||
! ERROR: A PURE subprogram must not use a derived type with a POINTER component as a SOURCE=.
|
||||
allocate(alloc, source=hp)
|
||||
contains
|
||||
pure subroutine internal
|
||||
! ERROR: A PURE subprogram must not define a host-associated object.
|
||||
z%a = 0.
|
||||
! ERROR: A PURE subprogram must not use a host-associated object as the target of pointer assignment.
|
||||
hp = hasPtr(z%a)
|
||||
end subroutine
|
||||
end function
|
||||
|
|
Loading…
Reference in New Issue