Skip to content

[flang][NFC] Document an intentional violation of the standard #99073

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions flang/docs/Extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ end
implicitly simply appearing in an asynchronous data transfer statement,
without the attribute being visible in the procedure's explicit
interface.
* When the name of an extended derived type's base type is the
result of `USE` association with renaming, the name of the extended
derived type's parent component is the new name by which the base
is known in the scope of the extended derived type, not the original.
This interpretation has usability advantages and is what six other
Fortran compilers do, but is not conforming now that J3 approved an
"interp" in June 2024 to the contrary.

## Extensions, deletions, and legacy features supported by default

Expand Down
70 changes: 70 additions & 0 deletions flang/test/Semantics/parent-comp-name.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
! RUN: %python %S/test_errors.py %s %flang_fc1
! Every other Fortran compiler (but one) interprets the names of parent
! components like this when the names of their types are the product of
! USE association with renaming.

module m1
type originalName
integer m
end type
end

module m2
use m1, newName => originalName
type, extends(newName) :: extended
integer n
end type
type, extends(newName) :: extended2
integer originalName ! ok
end type
contains
subroutine s1
type(extended) x
type(extended2) x2
print *, x%newName%m ! ok
!ERROR: Component 'originalname' not found in derived type 'extended'
print *, x%originalName
print *, extended(newName=newName(m=1),n=2) ! ok
!ERROR: Structure constructor lacks a value for component 'm'
!ERROR: Keyword 'originalname=' does not name a component of derived type 'extended'
!ERROR: Keyword 'm=' may not appear in a reference to a procedure with an implicit interface
print *, extended(originalName=originalName(m=1),n=2)
!ERROR: Value in structure constructor of type 'REAL(4)' is incompatible with component 'newname' of type 'newname'
!ERROR: Keyword 'm=' may not appear in a reference to a procedure with an implicit interface
print *, extended(newName=originalName(m=1),n=2)
!ERROR: Structure constructor lacks a value for component 'm'
!ERROR: Keyword 'originalname=' does not name a component of derived type 'extended'
print *, extended(originalName=newName(m=1),n=2)
print *, x2%newName%m ! ok
print *, x2%originalName ! ok
print *, extended2(newName=newName(m=1),originalName=2) ! ok
end
end

module m3
use m2
contains
! Same as above, but not in the same module as the derived
! types' definitions.
subroutine s2
type(extended) x
type(extended2) x2
print *, x%newName%m ! ok
!ERROR: Component 'originalname' not found in derived type 'extended'
print *, x%originalName
print *, extended(newName=newName(m=1),n=2) ! ok
!ERROR: Structure constructor lacks a value for component 'm'
!ERROR: Keyword 'originalname=' does not name a component of derived type 'extended'
!ERROR: Keyword 'm=' may not appear in a reference to a procedure with an implicit interface
print *, extended(originalName=originalName(m=1),n=2)
!ERROR: Value in structure constructor of type 'REAL(4)' is incompatible with component 'newname' of type 'newname'
!ERROR: Keyword 'm=' may not appear in a reference to a procedure with an implicit interface
print *, extended(newName=originalName(m=1),n=2)
!ERROR: Structure constructor lacks a value for component 'm'
!ERROR: Keyword 'originalname=' does not name a component of derived type 'extended'
print *, extended(originalName=newName(m=1),n=2)
print *, x2%newName%m ! ok
print *, x2%originalName ! ok
print *, extended2(newName=newName(m=1),originalName=2) ! ok
end
end
Loading