! File: interface1.f90
! Public domain 2004 James Van Buskirk
! Preliminary to attempt to create function with
! LEN given by specification expression via function
! name, and SIZE given by specification expression
! via result name.

! g95 12/18/04: Symbol test2 has no IMPLICIT type.
! ISO/IEC 1539-1:1997(E) section 12.5.2.2:
! "The type and type parameters (if any) of the result of the
! function defined by a function subprogram may be specified
! by a type specification in the FUNCTION statement or by the
! name of the result variable appearing in a type in the
! declaration part of the function subprogram.  It shall not
! be specified both ways.  If it is not specified either way,
! it is determined by the implicit typing rules in force within
! the function subprogram."
! So g95's error message is incorrect.

! CVF 6.6C3: This name does not have a type, and must have an
! explicit type. [X]
! ISO/IEC 1539-1:1997(E) section 7.1.6.2:
! "A variable in a specification expression shall have its type
! and type parameters, if any, specified by a previous declaration
! in the same scoping unit, or by the implicit typing rules in
! effect for the scoping unit, or by host or use association."
! So CVF's (first) error message is correct.

! LF95 5.70f: No errors, no warnings, output:
! 21
! ABCDEFGHIJKLMNOPQRSTU
! So LF95 is applying an extension, and failing to warn with -f95
! in effect.

module test1
   implicit none
   contains
      function test2(x)
         implicit character(f(x)) (t)
         integer, intent(in) :: x
         interface
            pure function f(x)
               integer, intent(in) :: x
               integer f
            end function f
         end interface
         integer i

         do i = 1, len(test2)
            test2(i:i) = achar(mod(i,32)+iachar('@'))
         end do
      end function test2
end module test1

program test
   use test1
   implicit none

   write(*,*) len(test2(10))
   write(*,*) test2(10)
end program test

pure function f(x)
   integer, intent(in) :: x
   integer f

   f = 2*x+1
end function f
