This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: host association question..
- From: "Christopher D. Rickett" <crickett at lanl dot gov>
- To: THOMAS Paul Richard 169137 <paul dot richard dot thomas at cea dot fr>
- Cc: fortran at gcc dot gnu dot org, erik dot edelmann at iki dot fi
- Date: Thu, 16 Feb 2006 09:26:49 -0700 (MST)
- Subject: Re: host association question..
- References: <756DFD3DE8F1D411A59A00306E06E84702C429F7@drfccad.cad.cea.fr>
i wasn't claiming it as valid code; i was claiming it as invalid code that
gfortran was not catching. as i mentioned in the email i just sent, i
came across this when testing the 'only' clause for the iso_c_binding
module; derived types and named constants from that module that were not
in the only list were being allowed w/o error when defining the params for
the subroutine in an interface because gfortran was pulling them from the
module level incorrectly.
Chris
On Thu, 16 Feb 2006, THOMAS Paul Richard 169137 wrote:
> The standard requires that an interface block comprises its own scoping unit.
> It does not inherit anything from its host through host association.
>
> The subprogram can contain a USE statement.
>
> Your example is therefore invalid on several levels.
> A correct version appears at the end of this message.
>
> Says Lahey:
>
> Compiling program unit myMod at line 1:
> Interface body name(blah)
> 1173-S: "SOURCE.F90", line 12: Derived type definition for 'myftype_1' missing.
> 1498-S: "SOURCE.F90", line 12, column 13: 'myftype_1' invalid as derived type name.
> 1498-S: "SOURCE.F90", line 13, column 13: 'myftype_1' invalid as derived type name.
> 1185-S: "SOURCE.F90", line 14: In an initialization or specification expression, 'mine' must be a named constant.
> 2018-S: "SOURCE.F90", line 14: When IMPLICIT NONE is specified, 'mine' must be declared in a type declaration statement.
> 1326-S: "SOURCE.F90", line 14, column 16: Type specification or length specification invalid.
> Encountered 6 errors, 0 warnings, 0 informations in file SOURCE.F90.
> Compiling file SOURCE.F90.
>
> Says DF5.0:
>
> ricket.f90(12) : Error: This derived type name has not been declared. [MYFTYPE
> _1]
> type(myftype_1) :: myStruct
> ------------^
> ricket.f90(14) : Error: A kind type parameter must be a compile-time constant.
> [MINE]
> integer(mine) :: myInt
> ---------------^
>
> gfortran gets to most of these, little by little, as the bugs are cured one after another. However, it does not correctly detect the invalid host association of the derived types - this is PR20878.
>
> This is correct and is compiled correctly by gfortran:
>
> module myMod
> implicit none
> integer, parameter :: mine = 4
> type :: MYFTYPE_1
> integer :: i, j
> real :: s
> end type MYFTYPE_1
> end module myMod
>
> module myProcs
> interface
> subroutine blah()
> use myMod
> implicit none
> type(myftype_1) :: myStruct
> type(myftype_1) :: myStruct2
> integer(mine) :: myInt
> end subroutine blah
> end interface
> end module myProcs
>
> Best regards
>
> Paul T
>