-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[flang] Better error handling and testing of generics with homonymous…
… specifics or derived types Fortran allows a generic procedure interface to have the same name as a derived type in the same scope or the same name as one of its specific procedures. (It can't have both since a derived type and specific procedure can't have the same name in a scope.) Some popular compilers allow generic interfaces with distinct accessible homonymous specific procedures to be merged by USE association. Thsi compiler does not, and for good reason: it leads to ambiguity in cases where a procedure name appears outside a reference, such as in a PROCEDURE declaration statement as the procedure's interface, the target of a procedure pointer assignment statement, or as an actual argument. This patch cleans up the code that handles these cases, improves some error messages, and adds more tests. Resolves #60228. Differential Revision: https://reviews.llvm.org/D150915
- Loading branch information
Showing
4 changed files
with
191 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
! RUN: %python %S/test_symbols.py %s %flang_fc1 | ||
!DEF: /m1a Module | ||
module m1a | ||
!DEF: /m1a/foo PUBLIC DerivedType | ||
type :: foo | ||
!DEF: /m1a/foo/j ObjectEntity INTEGER(4) | ||
integer :: j | ||
end type | ||
end module | ||
!DEF: /m1b Module | ||
module m1b | ||
!DEF: /m1b/foo PUBLIC (Function) Generic | ||
interface foo | ||
!DEF: /m1b/bar PUBLIC (Function) Subprogram REAL(4) | ||
module procedure :: bar | ||
end interface | ||
contains | ||
!REF: /m1b/bar | ||
function bar() | ||
end function | ||
end module | ||
!DEF: /test1a (Subroutine) Subprogram | ||
subroutine test1a | ||
!REF: /m1a | ||
use :: m1a | ||
!REF: /m1b | ||
use :: m1b | ||
!DEF: /test1a/foo (Function) Generic | ||
!DEF: /test1a/x ObjectEntity TYPE(foo) | ||
type(foo) :: x | ||
!DEF: /test1a/foo Use | ||
!REF: /m1b/bar | ||
print *, foo(1), foo() | ||
end subroutine | ||
!DEF: /test1b (Subroutine) Subprogram | ||
subroutine test1b | ||
!REF: /m1b | ||
use :: m1b | ||
!REF: /m1a | ||
use :: m1a | ||
!DEF: /test1b/foo (Function) Generic | ||
!DEF: /test1b/x ObjectEntity TYPE(foo) | ||
type(foo) :: x | ||
!DEF: /test1b/foo Use | ||
!REF: /m1b/bar | ||
print *, foo(1), foo() | ||
end subroutine |