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