xref: /llvm-project/flang/test/Semantics/change_team01.f90 (revision 372210308e0bd66e79d570dc11b2ed1b47a4a63c)
1! RUN: %python %S/test_errors.py %s %flang_fc1
2! Check for semantic errors in change team statements.
3! Only those semantics which differ from those of FORM TEAM statements are checked.
4
5subroutine test
6  use, intrinsic :: iso_fortran_env, only: team_type
7  type(team_type) :: team
8  integer, codimension[*] :: selector
9  integer, codimension[2,*] :: selector2d
10
11  ! Valid invocations which should produce no errors.
12  block
13  change team (team)
14  end team
15  construct1: change team (team)
16  end team construct1
17  change team (team, ca[*] => selector)
18  end team
19  change team (team, ca[2,*] => selector)
20  end team
21  change team (team, ca[*] => selector)
22  end team
23  change team (team, ca[*] => selector, ca2[2,*] => selector2d)
24  end team
25  end block
26
27  !A selector may appear only once in selector-list.
28  ! ERROR: Selector 'selector' was already used as a selector or coarray in this statement
29  change team (team, ca[*] => selector, ca2[*] => selector)
30  end team
31
32  ! Within a CHANGE TEAM construct, a CYCLE or EXIT statement is not allowed if it belongs to an outer construct.
33  block
34  outer1: if (.true.) then
35    change team (team)
36      if (.true.) then
37        ! ERROR: EXIT must not leave a CHANGE TEAM statement
38        exit outer1
39      end if
40    end team
41  end if outer1
42  end block
43  block
44  outer2: do
45    change team (team)
46      ! ERROR: CYCLE must not leave a CHANGE TEAM statement
47      cycle outer2
48    end team
49  end do outer2
50  end block
51
52  ! The construct name must not be the same as any other construct name in the scoping unit.
53  block
54  construct2: block
55  end block construct2
56  ! ERROR: 'construct2' is already declared in this scoping unit
57  construct2: change team (team)
58  end team construct2
59  end block
60
61  ! When the CHANGE TEAM statement is executed, the selectors must all be established coarrays.
62  ! ERROR: Selector in coarray association must name a coarray
63  change team (team, ca[*] => not_selector)
64  end team
65
66  ! The coarray name in a coarray-association must not be the same as the name as the name of another coarray or of a selector in the CHANGE TEAM statement.
67  ! ERROR: 'selector' is not an object that can appear in an expression
68  change team (team, selector[*] => selector)
69  end team
70end subroutine
71