public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/39800]  New: Rejects PRIVATE TYPE as compont of local type declaration
@ 2009-04-17 20:41 burnus at gcc dot gnu dot org
  2009-04-18 11:29 ` [Bug fortran/39800] " burnus at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-04-17 20:41 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-06-20  9:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-17 20:41 [Bug fortran/39800] New: Rejects PRIVATE TYPE as compont of local type declaration burnus at gcc dot gnu dot org
2009-04-18 11:29 ` [Bug fortran/39800] " burnus at gcc dot gnu dot org
2009-04-18 17:00 ` pault at gcc dot gnu dot org
2009-04-18 20:36 ` burnus at gcc dot gnu dot org
2009-04-20 21:15 ` pault at gcc dot gnu dot org
2009-04-20 21:55 ` pault at gcc dot gnu dot org
2009-06-20  9:21 ` pault at gcc dot gnu dot org
2009-06-20  9:22 ` pault at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).