xref: /llvm-project/flang/test/Semantics/implicit11.f90 (revision d38765604f9372dab74a82b573302bd6401c6698)
16c1ac141SIvan Zhechev! RUN: %python %S/test_errors.py %s %flang_fc1
2b8bfe358STim Keith
3b8bfe358STim Keith! Test use of implicitly declared variable in specification expression
4b8bfe358STim Keith
5b8bfe358STim Keithsubroutine s1()
6b8bfe358STim Keith  m = 1
7b8bfe358STim Keithcontains
8b8bfe358STim Keith  subroutine s1a()
9b8bfe358STim Keith    implicit none
10b8bfe358STim Keith    !ERROR: No explicit type declared for 'n'
11b8bfe358STim Keith    real :: a(m, n)
12b8bfe358STim Keith  end
13b8bfe358STim Keith  subroutine s1b()
14b8bfe358STim Keith    !ERROR: Implicitly typed local entity 'n' not allowed in specification expression
15b8bfe358STim Keith    real :: a(m, n)
16b8bfe358STim Keith  end
17b8bfe358STim Keithend
18b8bfe358STim Keith
19b8bfe358STim Keithsubroutine s2()
20b8bfe358STim Keith  type :: t(m, n)
21b8bfe358STim Keith    integer, len :: m
22b8bfe358STim Keith    integer, len :: n
23b8bfe358STim Keith  end type
24b8bfe358STim Keith  n = 1
25b8bfe358STim Keithcontains
26b8bfe358STim Keith  subroutine s2a()
27b8bfe358STim Keith    !ERROR: Implicitly typed local entity 'm' not allowed in specification expression
28b8bfe358STim Keith    type(t(m, n)) :: a
29b8bfe358STim Keith  end
30b8bfe358STim Keith  subroutine s2b()
31b8bfe358STim Keith    implicit none
32b8bfe358STim Keith    !ERROR: No explicit type declared for 'm'
33b8bfe358STim Keith    character(m) :: a
34b8bfe358STim Keith  end
35b8bfe358STim Keithend
36b8bfe358STim Keith
37b8bfe358STim Keithsubroutine s3()
38b8bfe358STim Keith  m = 1
39b8bfe358STim Keithcontains
40b8bfe358STim Keith  subroutine s3a()
41b8bfe358STim Keith    implicit none
42b8bfe358STim Keith    real :: a(m, n)
43*d3876560SPeter Klausler    !WARN: '%s' was used without (or before) being explicitly typed
44b8bfe358STim Keith    !ERROR: No explicit type declared for 'n'
45b8bfe358STim Keith    common n
46b8bfe358STim Keith  end
47b8bfe358STim Keith  subroutine s3b()
48b8bfe358STim Keith    ! n is okay here because it is in a common block
49b8bfe358STim Keith    real :: a(m, n)
50b8bfe358STim Keith    common n
51b8bfe358STim Keith  end
52b8bfe358STim Keithend
53b8bfe358STim Keith
54b8bfe358STim Keithsubroutine s4()
55b8bfe358STim Keith  implicit none
56b8bfe358STim Keithcontains
57b8bfe358STim Keith  subroutine s4a()
58b8bfe358STim Keith    !ERROR: No explicit type declared for 'n'
59b8bfe358STim Keith    real :: a(n)
60b8bfe358STim Keith  end
61b8bfe358STim Keithend
62b8bfe358STim Keith
63