[Bug fortran/42545] New: TBP: Wrongly reject inherite TBP with types with private components
burnus at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Tue Dec 29 18:38:00 GMT 2009
Reported by Reinhold Bader.
The error occurs for inherited type-bound procedures where the extending type
has "PRIVATE" for the components and the TBP procedure is accessed using the
syntax
<type> % <extended type> % <TBP>
The error message is as follows:
mr_shorter.f90:23.14:
call obj%tt%set()
1
Error: All components of 'ttt' are PRIVATE in structure constructor at (1)
The error is wrong for two reasons:
a) There is no structure constructure visible at all
b) This TBP is public as there is no PRIVATE statement below the CONTAINS in
the type declaration.
See "4.5.4 Type-bound procedures" and esp. last two normative paragraphs of
this section. And see "4.5.6.1 Inheritance" (all refs are F2003):
"An extended type has a scalar, nonpointer, nonallocatable, parent component
with the type and type parameters of the parent type. The name of this
component is the parent type name. It has the accessibility of the parent
type."
! -----------------------------------------
module mo
implicit none
type :: tt
private
integer :: i = 1
contains
procedure :: set
end type
type, extends(tt) :: ttt
private ! <<<<<<<
real :: x = 2.0
end type
contains
subroutine set(this)
class(tt) :: this
this%i = -1
end subroutine
end module
program pr
use mo
implicit none
type(ttt) :: obj
call obj%tt%set()
end program
! -------------------
Variants to check:
type tt
...
contains
PRIVATE
! (and optionally "set" explicitly marked as public)
-- and/or --
type, extends(tt) :: t
...
contains
PRIVATE
--
Summary: TBP: Wrongly reject inherite TBP with types with private
components
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Keywords: rejects-valid
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: burnus at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42545
More information about the Gcc-bugs
mailing list