xref: /llvm-project/flang/test/Semantics/resolve20.f90 (revision 1c91d9bdea3b6c38e8fbce46ec8181a9c0aa26f8)
1! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic
2module m
3  abstract interface
4    subroutine foo
5    end subroutine
6    subroutine foo2
7    end subroutine
8  end interface
9
10  procedure() :: a
11  procedure(integer) :: b
12  procedure(foo) :: c
13  procedure(bar) :: d
14  !ERROR: 'missing' must be an abstract interface or a procedure with an explicit interface
15  procedure(missing) :: e
16  !ERROR: 'b' must be an abstract interface or a procedure with an explicit interface
17  procedure(b) :: f
18  procedure(c) :: g
19  external :: h
20  !ERROR: 'h' must be an abstract interface or a procedure with an explicit interface
21  procedure(h) :: i
22  procedure(forward) :: j
23  !ERROR: 'bad1' must be an abstract interface or a procedure with an explicit interface
24  !ERROR: Procedure 'k1' may not be an array without an explicit interface
25  procedure(bad1) :: k1
26  !ERROR: 'bad2' must be an abstract interface or a procedure with an explicit interface
27  procedure(bad2) :: k2
28  !ERROR: 'bad3' must be an abstract interface or a procedure with an explicit interface
29  procedure(bad3) :: k3
30
31  abstract interface
32    subroutine forward
33    end subroutine
34  end interface
35
36  real :: bad1(1)
37  real :: bad2
38  type :: bad3
39  end type
40
41  !PORTABILITY: Name 'm' declared in a module should not have the same name as the module
42  type :: m
43  end type m
44
45  !ERROR: EXTERNAL attribute was already specified on 'a'
46  !ERROR: EXTERNAL attribute was already specified on 'b'
47  !ERROR: EXTERNAL attribute was already specified on 'c'
48  !ERROR: EXTERNAL attribute was already specified on 'd'
49  external :: a, b, c, d
50  !ERROR: EXTERNAL attribute not allowed on 'm'
51  external :: m
52  !WARNING: EXTERNAL attribute was already specified on 'foo'
53  external :: foo
54  !ERROR: EXTERNAL attribute not allowed on 'bar'
55  external :: bar
56
57  !ERROR: An entity may not have the ASYNCHRONOUS attribute unless it is a variable
58  asynchronous :: async
59  external :: async
60
61  !ERROR: PARAMETER attribute not allowed on 'm'
62  parameter(m=2)
63  !ERROR: PARAMETER attribute not allowed on 'foo'
64  parameter(foo=2)
65  !ERROR: PARAMETER attribute not allowed on 'bar'
66  parameter(bar=2)
67
68  type, abstract :: t1
69    integer :: i
70  contains
71    !ERROR: 'proc' must be an abstract interface or a procedure with an explicit interface
72    !ERROR: Procedure component 'p1' must have NOPASS attribute or explicit interface
73    procedure(proc), deferred :: p1
74  end type t1
75
76  abstract interface
77    function f()
78    end function
79  end interface
80
81contains
82  subroutine bar
83  end subroutine
84  !ERROR: An entity may not have the ASYNCHRONOUS attribute unless it is a variable
85  subroutine test
86    asynchronous test
87    !ERROR: Abstract procedure interface 'foo2' may not be referenced
88    call foo2()
89    !ERROR: Abstract procedure interface 'f' may not be referenced
90    x = f()
91  end subroutine
92end module
93