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

            Bug ID: 92913
           Summary: Add argument-mismatch check for INTERFACE for
                    non-module procedures in the same file
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
                CC: tkoenig at gcc dot gnu.org
  Target Milestone: ---

In the code below, there is an argument or function vs. subroutine mismatch
between stand-alone procedures and their interface blocks.

It would be very helpful to diagnose such mismatches. I have seen such code
before in some numeric programs, but it also exists as:

* libgomp/openacc.f90 – the 'module openacc_internal' has the interfaces and
the implementation is done by the stand-alone procedures at the bottom.

(libgomp/omp_lib.{h,f90}.in is different; they both only provide an interface,
except that the .h files only has 'external' and the function-result type.)



! Non-module subroutine to be compatible with Fortran 77 code
subroutine foo(x)
  integer :: x
  x = 5
end subroutine foo

! Make those procedures accessible as module
module m
  interface
    subroutine foo() ! Not diagnosed: missing argument
    end subroutine foo
    subroutine bar() ! Not diagnosed: subroutine vs. function
    end subroutine bar
  end interface
end module m

! Non-module function to be compatible with Fortran 77 code
integer function bar()
  bar = 42
end function bar



Another case would be:

subroutine sub_1()
   interface
     subroutine bar(x)
       integer :: x
     end subroutine bar
   interface
end subroutine sub_1

subroutine sub_2()
   interface
     subroutine bar()  ! arg mismatch
     end subroutine bar
   interface
end subroutine sub_2

subroutine sub_3
   external bar
   integer bar  ! function vs. subroutine mismatch
end subroutine sub_3


Such use also exists in real-world code – but it could also be used as cross
check for omp_lib.{h,f90} by temporarily adding
  subroutine sub1()
    #include <omp_lib.h>
  end
to omp_lib.f90 + compiling it.

Reply via email to