https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86472

Paul Thomas <pault at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |pault at gcc dot gnu.org

--- Comment #2 from Paul Thomas <pault at gcc dot gnu.org> ---
(In reply to Jim Feng from comment #0)
> Module M1
>     implicit none
> 
>     type :: mytype
>         contains
>         procedure :: myfunc1
>     end type
> 
>     interface
> 
>     module subroutine myfunc1(self, a)
>         class(mytype), intent(in) :: self
>         real, intent(in) :: a(:)
>         real, allocatable :: t(:)
>     end subroutine myfunc1
>     end interface
> End Module M1
> ------------------------------------------
> submodule(M1) M2
>     contains
> 
>     module procedure myfunc1
> !        real, allocatable :: t(:)
>         allocate(t, source=a)
>         x=10.0
>         print *,t, a, x
>     end procedure myfunc1
> end submodule M2
> 
> =========================================
> 
> submodule M2 showed compilation error (Error: Allocate-object  is neither a
> data pointer nor an allocatable variable) without re-declare variable t.
> Also un-declared variable x gives no error.

Yes indeed with respect to the declaration of 't'. However, since the submodule
is a separate compilation unit, I believe that it also must contain an
'implicit none' to pick up the undeclared variable 'x'. I will check the
standard on this.

Thanks

Paul

Reply via email to