1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 ! Test 15.7 C1594 - prohibited assignments in pure subprograms
18 real, allocatable
:: co
[:]
21 integer pure
function purefunc(x
)
22 integer, intent(in
) :: x
25 integer pure
function f00(p0
)
26 procedure(purefunc
) :: p0
29 pure
function test(ptr
, in
, hpd
)
31 type(t
), pointer :: ptr
, ptr2
32 type(t
), target
, intent(in
) :: in
33 type(t
), target
:: y
, z
35 type(hasPtr
), intent(in
) :: hpd
36 type(hasPtr
), allocatable
:: alloc
37 type(hasCoarray
), pointer :: hcp
41 !ERROR: Pure subprogram 'test' may not define 'x' because it is host-associated
43 !ERROR: Pure subprogram 'test' may not define 'y' because it is in a COMMON block
45 !ERROR: Pure subprogram 'test' may not define 'useassociated' because it is USE-associated
46 useassociated
= 0. ! C1594(1)
47 !ERROR: Pure subprogram 'test' may not define 'ptr' because it is a POINTER dummy argument of a pure function
49 !ERROR: Pure subprogram 'test' may not define 'in' because it is an INTENT(IN) dummy argument
51 !ERROR: A pure subprogram may not define a coindexed object
52 hcp
%co
[1] = 0. ! C1594(1)
53 !ERROR: Pure subprogram 'test' may not define 'ptr' because it is a POINTER dummy argument of a pure function
55 !ERROR: Pure subprogram 'test' may not define 'ptr' because it is a POINTER dummy argument of a pure function
56 nullify(ptr
) ! C1594(2), 19.6.8
57 !ERROR: A pure subprogram may not use 'ptr' as the target of pointer assignment because it is a POINTER dummy argument of a pure function
58 ptr2
=> ptr
! C1594(3)
59 !ERROR: A pure subprogram may not use 'in' as the target of pointer assignment because it is an INTENT(IN) dummy argument
61 !ERROR: A pure subprogram may not use 'y' as the target of pointer assignment because it is in a COMMON block
63 !ERROR: Externally visible object 'block' may not be associated with pointer component 'p' in a pure procedure
64 n
= size([hasPtr(y
%a
)]) ! C1594(4)
65 !ERROR: Externally visible object 'x' may not be associated with pointer component 'p' in a pure procedure
66 n
= size([hasPtr(x
%a
)]) ! C1594(4)
67 !ERROR: Externally visible object 'ptr' may not be associated with pointer component 'p' in a pure procedure
68 n
= size([hasPtr(ptr
%a
)]) ! C1594(4)
69 !ERROR: Externally visible object 'in' may not be associated with pointer component 'p' in a pure procedure
70 n
= size([hasPtr(in
%a
)]) ! C1594(4)
71 !ERROR: A pure subprogram may not copy the value of 'hpd' because it is an INTENT(IN) dummy argument and has the POINTER component '%p'
73 !ERROR: A pure subprogram may not copy the value of 'hpd' because it is an INTENT(IN) dummy argument and has the POINTER component '%p'
74 allocate(alloc
, source
=hpd
)
75 !ERROR: Actual procedure argument for dummy argument 'p0=' of a PURE procedure must have an explicit interface
78 pure
subroutine internal
79 type(hasPtr
) :: localhp
80 !ERROR: Pure subprogram 'internal' may not define 'z' because it is host-associated
82 !ERROR: Externally visible object 'z' may not be associated with pointer component 'p' in a pure procedure