xref: /llvm-project/flang/test/Semantics/resolve40.f90 (revision 6b8e33822ab3825f6d42b0c3e150b61e76cad5d6)
1! RUN: %python %S/test_errors.py %s %flang_fc1
2subroutine s1
3  namelist /nl/x
4  block
5    !ERROR: NAMELIST statement is not allowed in a BLOCK construct
6    namelist /nl/y
7  end block
8end
9
10subroutine s2
11  open(12, file='nl.out')
12  !ERROR: Namelist group 'nl' not found
13  write(12, nml=nl)
14end
15
16subroutine s3
17  real :: x
18  open(12, file='nl.out')
19  !ERROR: 'x' is not the name of a namelist group
20  write(12, nml=x)
21end
22
23module m4
24  real :: x
25  namelist /nl/x
26end
27subroutine s4a
28  use m4
29  namelist /nl2/x
30  open(12, file='nl.out')
31  write(12, nml=nl)
32  write(12, nml=nl2)
33end
34subroutine s4b
35  use m4
36  real :: y
37  !ERROR: 'nl' is already declared in this scoping unit
38  namelist /nl/y
39end
40
41subroutine s5
42  namelist /nl/x
43  integer x
44end
45
46subroutine s6
47  !ERROR: 's6' is not a variable
48  namelist /nl/ s6
49  !ERROR: 'f' is not a variable
50  namelist /nl/ f
51contains
52  integer function f()
53    f = 1
54  end
55end
56
57subroutine s7
58  real x
59  !ERROR: 'x' is not a variable
60  namelist /nl/ x
61  external x
62end
63
64subroutine s8
65  data x/1.0/
66  !ERROR: The type of 'x' has already been implicitly declared
67  integer x
68end
69
70subroutine s9
71  real :: x(2,2)
72  !ERROR: 'i' is already declared in this scoping unit
73  data ((x(i,i),i=1,2),i=1,2)/4*0.0/
74end
75
76module m10
77  integer :: x
78  public :: nl
79  namelist /nl/ x
80end
81
82subroutine s11
83  integer :: nl2
84  !ERROR: 'nl2' is already declared in this scoping unit
85  namelist /nl2/x
86  namelist /nl3/x
87  !ERROR: 'nl3' is already declared in this scoping unit
88  integer :: nl3
89  nl2 = 1
90end
91
92subroutine s12(x)
93  real, intent(in) :: x
94  namelist /nl/x
95  !ERROR: NAMELIST input group must not contain undefinable item 'x'
96  !BECAUSE: 'x' is an INTENT(IN) dummy argument
97  read(*,nml=nl)
98end
99