1! RUN: %S/test_errors.sh %s %t %f18
2module m1
3  implicit none
4contains
5  subroutine foo(x)
6    real :: x
7  end subroutine
8end module
9
10!Note: PGI, Intel, GNU, and NAG allow this; Sun does not
11module m2
12  use m1
13  implicit none
14  !ERROR: 'foo' may not be the name of both a generic interface and a procedure unless it is a specific procedure of the generic
15  interface foo
16    module procedure s
17  end interface
18contains
19  subroutine s(i)
20    integer :: i
21  end subroutine
22end module
23
24subroutine foo
25  !ERROR: Cannot use-associate 'foo'; it is already declared in this scope
26  use m1
27end
28
29subroutine bar
30  !ERROR: Cannot use-associate 'bar'; it is already declared in this scope
31  use m1, bar => foo
32end
33
34!OK to use-associate a type with the same name as a generic
35module m3a
36  type :: foo
37  end type
38end
39module m3b
40  use m3a
41  interface foo
42  end interface
43end
44
45! Can't have derived type and function with same name
46module m4a
47  type :: foo
48  end type
49contains
50  !ERROR: 'foo' is already declared in this scoping unit
51  function foo(x)
52  end
53end
54! Even if there is also a generic interface of that name
55module m4b
56  type :: foo
57  end type
58  !ERROR: 'foo' is already declared in this scoping unit
59  interface foo
60    procedure :: foo
61  end interface foo
62contains
63  function foo(x)
64  end
65end
66
67! Use associating a name that is a generic and a derived type
68module m5a
69  interface g
70  end interface
71  type g
72  end type
73end module
74module m5b
75  use m5a
76  interface g
77    procedure f
78  end interface
79  type(g) :: x
80contains
81  function f(i)
82  end function
83end module
84subroutine s5
85  use m5b
86  type(g) :: y
87end
88