1! RUN: %S/test_errors.sh %s %t %flang_fc1
2! REQUIRES: shell
3! C929   No specifier shall appear more than once in a given
4!   image-selector-spec-list.
5! C930 TEAM and TEAM_NUMBER shall not both appear in the same
6!   image-selector-spec-list.
7! C931 A stat-variable in an image-selector shall not be a coindexed object.
8subroutine s1()
9  use ISO_FORTRAN_ENV
10  type(team_type) :: team1, team2
11  real :: rCoarray[10,20,*]
12  real :: rVar1, rVar2
13  integer :: iVar1, iVar2
14  integer, dimension(4) :: intArray
15  integer :: intScalarCoarray[*]
16  integer :: intCoarray[3, 4, *]
17  integer :: smallIntCoarray[4, *]
18  intCoVar = 343
19  ! OK
20  rVar1 = rCoarray[1,2,3]
21  !ERROR: 'rcoarray' has corank 3, but coindexed reference has 2 cosubscripts
22  rVar1 = rCoarray[1,2]
23  !ERROR: Must have INTEGER type, but is REAL(4)
24  rVar1 = rCoarray[1,2,3.4]
25  !ERROR: Must have INTEGER type, but is REAL(4)
26  iVar1 = smallIntCoarray[3.4]
27  !ERROR: Must be a scalar value, but is a rank-1 array
28  rVar1 = rCoarray[1,intArray,3]
29  ! OK
30  rVar1 = rCoarray[1,2,3,STAT=iVar1, TEAM=team2]
31  !ERROR: Team value must be of type TEAM_TYPE from module ISO_FORTRAN_ENV
32  rVar1 = rCoarray[1,2,3,STAT=iVar1, TEAM=2]
33  ! OK
34  rVar1 = rCoarray[1,2,3,STAT=iVar1, TEAM_NUMBER=38]
35  ! OK
36  rVar1 = rCoarray[1,2,3,STAT=iVar1]
37  ! OK
38  rVar1 = rCoarray[1,2,3,STAT=intArray(2)]
39  !ERROR: Must have INTEGER type, but is REAL(4)
40  rVar1 = rCoarray[1,2,3,STAT=rVar2]
41  !ERROR: Must be a scalar value, but is a rank-1 array
42  rVar1 = rCoarray[1,2,3,STAT=intArray]
43  ! Error on C929, no specifier can appear more than once
44  !ERROR: STAT variable can only be specified once
45  rVar1 = rCoarray[1,2,3,STAT=iVar1, STAT=iVar2]
46  ! OK
47  rVar1 = rCoarray[1,2,3,TEAM=team1]
48  ! Error on C929, no specifier can appear more than once
49  !ERROR: TEAM value can only be specified once
50  rVar1 = rCoarray[1,2,3,TEAM=team1, TEAM=team2]
51  ! OK
52  rVar1 = rCoarray[1,2,3,TEAM_NUMBER=37]
53  ! OK
54  rVar1 = rCoarray[1,2,3,TEAM_NUMBER=iVar1]
55  ! Error, team number is a scalar integer expression
56  !ERROR: Must be a scalar value, but is a rank-1 array
57  rVar1 = rCoarray[1,2,3,TEAM_NUMBER=intArray]
58  ! Error, team number is a scalar integer expression
59  !ERROR: Must have INTEGER type, but is REAL(4)
60  rVar1 = rCoarray[1,2,3,TEAM_NUMBER=3.7]
61  ! Error on C929, no specifier can appear more than once
62  !ERROR: TEAM_NUMBER value can only be specified once
63  rVar1 = rCoarray[1,2,3,TEAM_NUMBER=37, TEAM_NUMBER=37]
64  !ERROR: Cannot specify both TEAM and TEAM_NUMBER
65  rVar1 = rCoarray[1,2,3,TEAM=team1, TEAM_NUMBER=37]
66  !ERROR: Cannot specify both TEAM and TEAM_NUMBER
67  rVar1 = rCoarray[1,2,3,TEAM_number=43, TEAM=team1]
68  ! OK for a STAT variable to be a coarray integer
69  rVar1 = rCoarray[1,2,3,stat=intScalarCoarray]
70  ! Error for a STAT variable to be a coindexed object
71  !ERROR: Image selector STAT variable must not be a coindexed object
72  rVar1 = rCoarray[1,2,3,stat=intCoarray[2,3, 4]]
73end subroutine s1
74