This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/39688] New: IMPORT of derived type fails
- From: "burnus at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Apr 2009 12:46:56 -0000
- Subject: [Bug fortran/39688] New: IMPORT of derived type fails
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Reported by Bob Corbett of SUN to the J3 mailing list (who was initially not
fully convinced that the code is valid). The following program is regarded as
valid but it fails with sunf95 and gfortran (4.3/4.4/4.5, no IMPORT exists in
4.2) to compile. (It works with NAG f95, ifort, g95, xlf90.) gfortran's error
message is:
TYPE(T3) X
1
Error: the type of 'x' at (1) has not been declared within the interface
"The problem, of course, is the definition of the derived
type T2 following the interface block. Section 12.3.2.1
of the Fortran 2003 standard says regarding the IMPORT
statement
If an entity that is made accessible by this means
is accessed by host association and is defined in
the host scoping unit, it shall be explicitly
declared prior to the interface body.
That clearly requires T1 and T3 to be defined prior to the
interface body, but it does not require T2 to be defined
prior to the interface body. Therefore, the program appears
to be standard conforming."
MODULE MOD
TYPE T1
SEQUENCE
TYPE(T2), POINTER :: P
END TYPE
TYPE T2
SEQUENCE
INTEGER I
END TYPE
END
PROGRAM MAIN
USE MOD, T3 => T1, T4 => T2
TYPE T1
SEQUENCE
TYPE(T2), POINTER :: P
END TYPE
INTERFACE SUBR
SUBROUTINE SUBR1(X)
IMPORT T3
TYPE(T3) X
END SUBROUTINE
SUBROUTINE SUBR2(X)
IMPORT T1
TYPE(T1) X
END SUBROUTINE
END INTERFACE
TYPE T2
SEQUENCE
REAL X
END TYPE
END
SUBROUTINE SUBR1(X)
USE MOD
TYPE(T1) X
END
SUBROUTINE SUBR2(X)
TYPE T1
SEQUENCE
TYPE(T2), POINTER :: P
END TYPE
TYPE T2
SEQUENCE
REAL X
END TYPE
TYPE(T1) X
END
--
Summary: IMPORT of derived type fails
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=39688