1! RUN: %S/test_errors.sh %s %t %flang_fc1
2! REQUIRES: shell
3! Tests for the index-name of a FORALL statement
4
5module m1
6  integer modVar
7end module m1
8
9program indexName
10  common /iCommonName/ x
11  type ::  typeName
12  end type
13  iGlobalVar = 216
14
15contains
16  subroutine hostAssoc()
17    integer, dimension(4) :: table
18
19  ! iGlobalVar is host associated with the global variable
20    iGlobalVar = 1
21    FORALL (iGlobalVar=1:4) table(iGlobalVar) = 343
22  end subroutine hostAssoc
23
24  subroutine useAssoc()
25    use m1
26    integer, dimension(4) :: tab
27  ! modVar is use associated with the module variable
28    FORALL (modVar=1:4) tab(modVar) = 343
29  end subroutine useAssoc
30
31  subroutine constructAssoc()
32    integer, dimension(4) :: table
33    integer :: localVar
34    associate (assocVar => localVar)
35      ! assocVar is construct associated with localVar
36      FORALL (assocVar=1:4) table(assocVar) = 343
37    end associate
38  end subroutine constructAssoc
39
40  subroutine commonSub()
41    integer, dimension(4) :: tab
42    ! This reference is OK
43    FORALL (iCommonName=1:4) tab(iCommonName) = 343
44  end subroutine commonSub
45
46  subroutine mismatch()
47    integer, dimension(4) :: table
48    !ERROR: Index name 'typename' conflicts with existing identifier
49    FORALL (typeName=1:4) table(typeName) = 343
50  end subroutine mismatch
51end program indexName
52