Follow up to PR 36947/PR 40039. I think there was no PR yet, if not -> mark as duplicate. See also PR 40276.
I think some other checks should still be added, e.g. a) PUREness check (see example below); passing/assigning a pure to a non-pure dummy/proc-pointer is OK; doing vice versa is not. See "12.4.1.3" (dummy-actual arguments) "If the interface of the dummy argument is explicit, the characteristics listed in 12.2 shall be the same for the associated actual argument and the corresponding dummy argument, except that a pure actual argument may be associated with a dummy argument that is not pure and an elemental intrinsic actual procedure may be associated with a dummy procedure (which is prohibited from being elemental)." And also "7.4.2.2" (proc-pointer assignment): "If proc-pointer-object has an explicit interface, its characteristics shall be the same as proc-target except that proc-target may be pure even if proc-pointer-object is not pure and proc-target may be an elemental intrinsic procedure even if proc-pointer-object is not elemental." b) Similarly for ELEMENTAL. For proc-pointer assignments, use the first example with PURE changed to ELEMENTAL. That non-intrinsic elementals are not allowed as actual argument, is already checked for (cf. C1228). Except of the remark in parentheses I could not find in F2003/F2008 anything which prohibits ELEMENTAL for the dummy argument; however, the parentheses is normative. Maybe one should re-check the standard before adding an error check (see example below). c) One needs to go recursively over the arguments as the second example below shows. PROGRAM PURENESS implicit none interface subroutine one(a,b,c,d,e,f,g,h,i) implicit none integer,intent(in) :: a,b,c,d,e,f,g,h,i end subroutine one pure subroutine two(a,b,c,d,e,f,g,h,i) implicit none integer,intent(in) :: a,b,c,d,e,f,g,h,i end subroutine two end interface procedure(two), pointer :: ptr ptr => one ! Invalid: (pure) => (unpure) end program pureness program RecursiveInterface interface subroutine a(x) real :: x end subroutine a subroutine b(a) integer :: a end subroutine b subroutine c(f) procedure(a) :: f end subroutine c subroutine d(f) procedure(b) :: f end subroutine d subroutine e(f) procedure(c) :: f end subroutine e end interface call e(d) ! Argument (dummy subroutine) d has an integer argument ! but e's f expects a real argument end program RecursiveInterface interface elemental subroutine a() ! Expected: Warning: ELEMENTAL procedure ! without arguments ! (Having ELEMENTAL does not make much sense without arguments, but ! it is valid) end subroutine a subroutine sub(f) interface elemental subroutine f(a) integer,intent(IN) :: a end subroutine f end interface ! Invalid per 12.4.1.3? ! "an elemental intrinsic actual procedure may be associated with ! a dummy procedure (which is prohibited from being elemental)." ! ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ! Todo: Find it elsewhere in the standard - or in the corrigenda; ! other compilers accept it. However, the part above is normative end subroutine sub end interface end program elementalCheck -- Summary: Enhanced argument checking: Product: gcc Version: 4.5.0 Status: UNCONFIRMED Keywords: diagnostic 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=40453