-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[flang] Catch name conflict between generic TBP and inherited non-gen…
…eric A generic procedure binding in an extended derived type may not have the same name as a symbol inherited from an ancestor type unless that inherited symbol is also a generic TBP. Since generic names can be things like "ASSIGNMENT(=)", name resolution doesn't use OkToAddComponent() for generic TBPs, which would have caught this error as it does for other symbols in derived types, so it must be special-cased. Differential Revision: https://reviews.llvm.org/D145109
- Loading branch information
Showing
2 changed files
with
37 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
! RUN: %python %S/test_errors.py %s %flang_fc1 | ||
! Test name conflicts with type-bound generics | ||
module m | ||
type base1(k) | ||
integer, kind :: k = 4 | ||
real x | ||
contains | ||
procedure, nopass :: tbp => sub | ||
generic :: gen => tbp | ||
end type | ||
type, extends(base1) :: ext1 | ||
contains | ||
procedure, nopass :: sub | ||
!ERROR: Type parameter, component, or procedure binding 'base1' already defined in this type | ||
generic :: base1 => sub | ||
!ERROR: Type bound generic procedure 'k' may not have the same name as a non-generic symbol inherited from an ancestor type | ||
generic :: k => sub | ||
!ERROR: Type bound generic procedure 'x' may not have the same name as a non-generic symbol inherited from an ancestor type | ||
generic :: x => sub | ||
!ERROR: Type bound generic procedure 'tbp' may not have the same name as a non-generic symbol inherited from an ancestor type | ||
generic :: tbp => sub | ||
generic :: gen => sub ! ok | ||
end type | ||
contains | ||
subroutine sub | ||
end | ||
end |