Reported by Alexei Matveev at
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/ed70666b0c90b655
* * *
The following does not make sense:
MODULE m
TYPE, PRIVATE :: type; ...
CONTAINS
SUBROUTINE foo()
TYPE :: bar
TYPE(type) :: x
The last line is rejected with "The component 'x' is a PRIVATE type and cannot
be a component of 'type', which is PUBLIC at (1)"
The error is complete nonsense - TYPE(BAR) is not even used as dummy argument
(which would be valid since F2003).
The message only makes sense for the interface part of a module:
MODULE m
TYPE, PRIVATE :: type; ...
TYPE, PUBLIC :: bar
type(type) :: x
That case is valid Fortran 2003 and invalid Fortran 95 ("Component X of type T2
exposes PRIVATE type T1" as NAG f95 states). -- gfortran rejects this
unconditionally, however.
Thus there are two bugs:
- Local TYPE declarations in procedures are wrongly rejected
- Public types with private components are allowed in F2003 only,
s/gfc_error/gfc_std_notify(GFC_STD2003/.
* * *
module m
implicit none
type :: t1
integer :: i
end type
type,public :: t2
! OK in F2003, wrong in F95
type(t1) :: j ! { dg-error "Fortran 2003: ......." }
end type
contains
subroutine sub()
type :: t3
integer x
type(t1) :: j ! OK (F95 + F2003) - no dummy argument
end type ! (dummy arg is OK only in F2003)
end subroutine
end module m
--
Summary: Rejects PRIVATE TYPE as compont of local type
declaration
Product: gcc
Version: 4.4.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=39800