1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 ! Test 15.7 C1591 & others: contexts requiring pure subprograms
8 procedure
, nopass
:: tbp_pure
=> pure
9 procedure
, nopass
:: tbp_impure
=> impure
11 type, extends(t
) :: t2
13 !ERROR: An overridden pure type-bound procedure binding must also be pure
14 procedure
, nopass
:: tbp_pure
=> impure
! 7.5.7.3
19 pure
integer function pure(n
)
23 impure
integer function impure(n
)
29 real :: a(pure(1)) ! ok
30 !ERROR: Invalid specification expression: reference to impure function 'impure'
31 real :: b(impure(1)) ! 10.1.11(4)
33 !ERROR: Impure procedure 'impure' may not be referenced in a FORALL
34 a(j
) = impure(j
) ! C1037
37 !ERROR: Impure procedure 'impure' may not be referenced in a FORALL
38 a(j
) = pure(impure(j
)) ! C1037
40 !ERROR: DO CONCURRENT mask expression may not reference impure procedure 'impure'
41 do concurrent (j
=1:1, impure(j
) /= 0) ! C1121
42 !ERROR: Call to an impure procedure is not allowed in DO CONCURRENT
43 a(j
) = impure(j
) ! C1139
49 real :: a(x
%tbp_pure(1)) ! ok
50 !ERROR: Invalid specification expression: reference to impure function 'impure'
51 real :: b(x
%tbp_impure(1))
53 a(j
) = x
%tbp_pure(j
) ! ok
56 !ERROR: Impure procedure 'impure' may not be referenced in a FORALL
57 a(j
) = x
%tbp_impure(j
) ! C1037
59 do concurrent (j
=1:1, x
%tbp_pure(j
) /= 0) ! ok
60 a(j
) = x
%tbp_pure(j
) ! ok
62 !ERROR: DO CONCURRENT mask expression may not reference impure procedure 'impure'
63 do concurrent (j
=1:1, x
%tbp_impure(j
) /= 0) ! C1121
64 !ERROR: Call to an impure procedure component is not allowed in DO CONCURRENT
65 a(j
) = x
%tbp_impure(j
) ! C1139
75 a(i
) = t(pure(i
)) ! OK
78 !ERROR: Impure procedure 'impure' may not be referenced in a FORALL
79 a(i
) = t(impure(i
)) ! C1037
85 real, allocatable
:: x
88 character(*), intent(in
) :: ch
90 ! Intrinsic functions and a couple subroutines are pure; do not emit errors
92 b(j
)%x
= cos(1.) + len(ch
)
93 call move_alloc(from
=b(j
)%x
, to=a(j
)%x
)