1 ! RUN: %S/test_errors.sh %s %t %flang_fc1
3 ! Test 15.7 C1591 & others: contexts requiring pure subprograms
9 procedure
, nopass
:: tbp_pure
=> pure
10 procedure
, nopass
:: tbp_impure
=> impure
12 type, extends(t
) :: t2
14 !ERROR: An overridden pure type-bound procedure binding must also be pure
15 procedure
, nopass
:: tbp_pure
=> impure
! 7.5.7.3
20 pure
integer function pure(n
)
24 impure
integer function impure(n
)
30 real :: a(pure(1)) ! ok
31 !ERROR: Invalid specification expression: reference to impure function 'impure'
32 real :: b(impure(1)) ! 10.1.11(4)
34 !ERROR: Impure procedure 'impure' may not be referenced in a FORALL
35 a(j
) = impure(j
) ! C1037
38 !ERROR: Impure procedure 'impure' may not be referenced in a FORALL
39 a(j
) = pure(impure(j
)) ! C1037
41 !ERROR: DO CONCURRENT mask expression may not reference impure procedure 'impure'
42 do concurrent (j
=1:1, impure(j
) /= 0) ! C1121
43 !ERROR: Call to an impure procedure is not allowed in DO CONCURRENT
44 a(j
) = impure(j
) ! C1139
50 real :: a(x
%tbp_pure(1)) ! ok
51 !ERROR: Invalid specification expression: reference to impure function 'impure'
52 real :: b(x
%tbp_impure(1))
54 a(j
) = x
%tbp_pure(j
) ! ok
57 !ERROR: Impure procedure 'impure' may not be referenced in a FORALL
58 a(j
) = x
%tbp_impure(j
) ! C1037
60 do concurrent (j
=1:1, x
%tbp_pure(j
) /= 0) ! ok
61 a(j
) = x
%tbp_pure(j
) ! ok
63 !ERROR: DO CONCURRENT mask expression may not reference impure procedure 'impure'
64 do concurrent (j
=1:1, x
%tbp_impure(j
) /= 0) ! C1121
65 !ERROR: Call to an impure procedure component is not allowed in DO CONCURRENT
66 a(j
) = x
%tbp_impure(j
) ! C1139
76 a(i
) = t(pure(i
)) ! OK
79 !ERROR: Impure procedure 'impure' may not be referenced in a FORALL
80 a(i
) = t(impure(i
)) ! C1037
86 real, allocatable
:: x
89 character(*), intent(in
) :: ch
91 ! Intrinsic functions and a couple subroutines are pure; do not emit errors
93 b(j
)%x
= cos(1.) + len(ch
)
94 call move_alloc(from
=b(j
)%x
, to=a(j
)%x
)