1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 ! Test DO loop semantics for constraint C1130 --
3 ! The constraint states that "If the locality-spec DEFAULT ( NONE ) appears in a
4 ! DO CONCURRENT statement; a variable that is a local or construct entity of a
5 ! scope containing the DO CONCURRENT construct; and that appears in the block of
6 ! the construct; shall have its locality explicitly specified by that
15 integer :: i
, ivar
, jvar
, kvar
22 type, extends(point
) :: color_point
26 type(point
), target
:: c
27 class(point
), pointer :: p_or_c
33 ! References in this DO CONCURRENT are OK since there's no DEFAULT(NONE)
35 associate (avar
=> ivar
)
36 do concurrent (i
= 1:2) shared(jvar
)
50 associate (avar
=> ivar
)
51 !ERROR: DO CONCURRENT step expression may not be zero
52 do concurrent (i
= 1:2:0) default(none) shared(jvar
) local(kvar
)
53 !ERROR: Variable 'ivar' from an enclosing scope referenced in DO CONCURRENT with DEFAULT(NONE) must appear in a locality-spec
55 !ERROR: Variable 'ivar' from an enclosing scope referenced in DO CONCURRENT with DEFAULT(NONE) must appear in a locality-spec
59 !ERROR: Variable 'avar' from an enclosing scope referenced in DO CONCURRENT with DEFAULT(NONE) must appear in a locality-spec
61 !ERROR: Variable 'x' from an enclosing scope referenced in DO CONCURRENT with DEFAULT(NONE) must appear in a locality-spec
63 bvar
= 3.5 + i
! OK, bvar's scope is within the DO CONCURRENT
65 jvar
= 5 ! OK, jvar appears in a locality spec
66 kvar
= 5 ! OK, kvar appears in a locality spec
68 !ERROR: Variable 'mvar' from an enclosing scope referenced in DO CONCURRENT with DEFAULT(NONE) must appear in a locality-spec
73 select
type ( a
=> p_or_c
)
75 do concurrent (i
=1:5) local(a
)
76 ! C1130 This is OK because there's no DEFAULT(NONE) locality spec
81 select
type ( a
=> p_or_c
)
83 do concurrent (i
=1:5) default (none)
84 !ERROR: Variable 'a' from an enclosing scope referenced in DO CONCURRENT with DEFAULT(NONE) must appear in a locality-spec
89 select
type ( a
=> p_or_c
)
91 do concurrent (i
=1:5) default (none) local(a
)
92 ! C1130 This is OK because 'a' is in a locality-spec
97 x
= 5.0 ! OK, we're not in a DO CONCURRENT