mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-17 03:36:37 +00:00

When two or more generic interfaces are available by declaration or by USE association at different scoping levels, we need to search the outer generic interfaces as well as the inner ones, but only after the inner ones have failed to produce a specific procedure that matches a given set of actual arguments. This means that it is possible for a specific procedure of a generic interface of an inner scope to override a conflicting specific procedure of a generic interface of an outer scope. Also cope with forward references to derived types when a generic interface is also in scope. Fixes LLVM bug https://github.com/llvm/llvm-project/issues/55240 and LLVM bug https://github.com/llvm/llvm-project/issues/55300. Differential Revision: https://reviews.llvm.org/D126587
48 lines
747 B
Fortran
48 lines
747 B
Fortran
! RUN: %python %S/test_errors.py %s %flang_fc1
|
|
subroutine s1
|
|
!OK: interface followed by type with same name
|
|
interface t
|
|
end interface
|
|
type t
|
|
end type
|
|
type(t) :: x
|
|
x = t()
|
|
end subroutine
|
|
|
|
subroutine s2
|
|
!OK: type followed by interface with same name
|
|
type t
|
|
end type
|
|
interface t
|
|
end interface
|
|
type(t) :: x
|
|
x = t()
|
|
end subroutine
|
|
|
|
subroutine s3
|
|
type t
|
|
end type
|
|
interface t
|
|
end interface
|
|
!ERROR: 't' is already declared in this scoping unit
|
|
type t
|
|
end type
|
|
type(t) :: x
|
|
x = t()
|
|
end subroutine
|
|
|
|
module m4
|
|
type t1
|
|
class(t2), pointer :: p => null()
|
|
end type
|
|
type t2
|
|
end type
|
|
interface t2
|
|
procedure ctor
|
|
end interface
|
|
contains
|
|
function ctor()
|
|
type(t2) ctor
|
|
end function
|
|
end module
|