J3/15-160r1
To: J3
From: R. Bader & Malcolm Cohen
Subject: F2008 interp: Type extension in submodules
Date: 2015 August 03
Reference: 10-007r1
----------------------------------------------------------------------
NUMBER: F08/0138
TITLE: Type extension in submodules
KEYWORDS: submodules, deferred type-bound procedures
DEFECT TYPE: Clarification
STATUS: J3 consideration in progress
QUESTION:
Consider the following code:
module mod_a
implicit none
type, abstract :: t_a
contains
procedure(p_a), deferred :: p
end type t_a
abstract interface
subroutine p_a(this, q)
import :: t_a
class(t_a), intent(inout) :: this
class(*), intent(in) :: q
end subroutine
end interface
end module mod_a
submodule(mod_a) imp_p_a
type, extends(t_a) :: t_imp
real :: b
contains
procedure :: p => p_imp ! (A)
end type t_imp
contains
subroutine p_imp(this, q)
class(t_imp), intent(inout) :: this
class(*) :: q
... ! don't care
end subroutine p_imp
end submodule imp_p_a
Constraint C456 in 007r1 reads
"C465 (R448) The procedure-name shall be the name of an accessible
module procedure or an external procedure that has an explicit
interface."
Therefore it would appear that statement (A) above is not standard
conforming since P_IMP is not the name of a module procedure.
Q1. Is this correct?
If so, extension of a derived type with a deferred type-bound
procedure cannot be done within the specification part of a submodule.
Q2. Was this intended?
ANSWER:
A1. No, this is not correct. A module procedure is a procedure that
is defined by a module subprogram (1.3.112.4). A submodule
program unit contains a module-subprogram-part (R1116), and this
contains a (possibly-empty) sequence of module-subprogram's
(R1107). Therefore, P_IMP is defined by a module subprogram and
is therefore a module procedure. Therefore, the statement that
is commented "(A)" is standard-conforming.
A2. Moot.
EDIT: None.
SUBMITTED BY: R. Bader
HISTORY: 15-160 m207 F08/0138 Submitted
15-160r1 m207 Revised
----------------------------------------------------------------------