b6d08173ee
When a generic or specific procedure is use-associated, make a copy of it in the current scope (replacing the symbol that has UseDetails) so that we can make changes to it. This permits a generic to be defined in one module and extended with more specific procedures in another. When a specific procedure has the same name as its generic, it can't be stored directly in the scope because that is indexed by name and the generic is already there. So instead we store the specific in the GenericDetails of the generic symbol. Enforce the rule that a generic and a procedure can only have the same name if the procedure is one of the specifics of the generic. Refactorings done is support of this change: - Add FindSymbol() and EraseSymbol() as helpers to find or erase a symbol in the current scope. Make use of FindSymbol() where appropriate. - Add SayAlreadyDeclared() to report a common error. Original-commit: flang-compiler/f18@be479b9887 Reviewed-on: https://github.com/flang-compiler/f18/pull/95
21 lines
374 B
Fortran
21 lines
374 B
Fortran
module m1
|
|
implicit none
|
|
contains
|
|
subroutine foo(x)
|
|
real :: x
|
|
end subroutine
|
|
end module
|
|
|
|
!Note: PGI, Intel, GNU, and NAG allow this; Sun does not
|
|
module m2
|
|
use m1
|
|
implicit none
|
|
!ERROR: 'foo' is already declared in this scoping unit
|
|
interface foo
|
|
module procedure s
|
|
end interface
|
|
contains
|
|
subroutine s(i)
|
|
integer :: i
|
|
end subroutine
|
|
end module
|