xref: /llvm-project/flang/test/Semantics/resolve97.f90 (revision 6c1ac141d3c98af9738bc77fcb55602cbff7751f)
1! RUN: %python %S/test_errors.py %s %flang_fc1
2
3! Check errors from illegal (10.1.12 para 2) forward references
4! in specification expressions to entities declared later in the
5! same specification part.
6
7module m1
8  integer :: m1j1, m1j2, m1j3, m1j4
9 contains
10  subroutine s1
11    !ERROR: Forward reference to 'm1j1' is not allowed in the same specification part
12    integer(kind=kind(m1j1)) :: t_s1m1j1
13    integer(kind=kind(m1s1j1)) :: t_s1j1 ! implicitly typed in s1
14    integer :: m1j1, m1s1j1, m1s1j2, m1s1j4
15    block
16      !ERROR: Forward reference to 'm1j2' is not allowed in the same specification part
17      integer(kind=kind(m1j2)) :: t_s1bm1j2
18      !ERROR: Forward reference to 'm1s1j2' is not allowed in the same specification part
19      integer(kind=kind(m1s1j2)) :: t_s1bm1s1j2
20      !ERROR: Forward reference to 'm1s1j3' is not allowed in the same specification part
21      integer(kind=kind(m1s1j3)) :: t_m1s1j3 ! m1s1j3 implicitly typed in s1
22      integer :: m1j2, m1s1j2, m1s1j3
23    end block
24   contains
25    subroutine s2
26      !ERROR: Forward reference to 'm1j3' is not allowed in the same specification part
27      integer(kind=kind(m1j3)) :: t_m1j3
28      !ERROR: Forward reference to 'm1s1j3' is not allowed in the same specification part
29      integer(kind=kind(m1s1j3)) :: t_m1s1j3
30      integer :: m1j3, m1s1j3, m1s2j1
31      block
32        !ERROR: Forward reference to 'm1j4' is not allowed in the same specification part
33        integer(kind=kind(m1j4)) :: t_m1j4
34        !ERROR: Forward reference to 'm1s1j4' is not allowed in the same specification part
35        integer(kind=kind(m1s1j4)) :: t_m1s1j4
36        !ERROR: Forward reference to 'm1s2j1' is not allowed in the same specification part
37        integer(kind=kind(m1s2j1)) :: t_m1s2j1
38        !ERROR: Forward reference to 'm1s2j2' is not allowed in the same specification part
39        integer(kind=kind(m1s2j2)) :: t_m1s2j2 ! m1s2j2 implicitly typed in s2
40        integer :: m1j4, m1s1j4, m1s2j1, m1s2j2
41      end block
42    end subroutine
43  end subroutine
44end module
45
46module m2
47  implicit none
48  integer :: m2j1, m2j2, m2j3, m2j4
49 contains
50  subroutine s1
51    !ERROR: Forward reference to 'm2j1' is not allowed in the same specification part
52    integer(kind=kind(m2j1)) :: t_s1m2j1
53    !ERROR: No explicit type declared for 'm2s1j1'
54    integer(kind=kind(m2s1j1)) :: t_s1j1
55    integer :: m2j1, m2s1j1, m2s1j2, m2s1j4
56    block
57      !ERROR: Forward reference to 'm2j2' is not allowed in the same specification part
58      integer(kind=kind(m2j2)) :: t_s1bm2j2
59      !ERROR: Forward reference to 'm2s1j2' is not allowed in the same specification part
60      integer(kind=kind(m2s1j2)) :: t_s1bm2s1j2
61      !ERROR: No explicit type declared for 'm2s1j3'
62      integer(kind=kind(m2s1j3)) :: t_m2s1j3
63      integer :: m2j2, m2s1j2, m2s1j3
64    end block
65   contains
66    subroutine s2
67      !ERROR: Forward reference to 'm2j3' is not allowed in the same specification part
68      integer(kind=kind(m2j3)) :: t_m2j3
69      !ERROR: No explicit type declared for 'm2s1j3'
70      integer(kind=kind(m2s1j3)) :: t_m2s1j3
71      integer :: m2j3, m2s1j3, m2s2j1
72      block
73        !ERROR: Forward reference to 'm2j4' is not allowed in the same specification part
74        integer(kind=kind(m2j4)) :: t_m2j4
75        !ERROR: Forward reference to 'm2s1j4' is not allowed in the same specification part
76        integer(kind=kind(m2s1j4)) :: t_m2s1j4
77        !ERROR: Forward reference to 'm2s2j1' is not allowed in the same specification part
78        integer(kind=kind(m2s2j1)) :: t_m2s2j1
79        !ERROR: No explicit type declared for 'm2s2j2'
80        integer(kind=kind(m2s2j2)) :: t_m2s2j2
81        integer :: m2j4, m2s1j4, m2s2j1, m2s2j2
82      end block
83    end subroutine
84  end subroutine
85end module
86
87! Case that elicited bad errors
88SUBROUTINE KEEL
89  INTEGER NODES
90 CONTAINS
91  SUBROUTINE SGEOM
92    REAL :: RADIUS(nodes)
93  END SUBROUTINE
94END SUBROUTINE KEEL
95