public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/40276]  New: Matching GENERIC procedure: Wrong INTENT should give directly an error message
@ 2009-05-27 18:34 burnus at gcc dot gnu dot org
  2009-05-27 21:40 ` [Bug fortran/40276] " burnus at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-05-27 18:34 UTC (permalink / raw)
  To: gcc-bugs

Starting with PR 40039, gfortran checks the INTENT of procedures. This works -
especially with the patch for PR 36947/PR 40039 - rather well if one calls a
SPECIFIC procedure.

However, if one calls a GENERIC procedure the error message is just:

  Error: There is no specific subroutine for the generic 'gen' at (1)

The issue is: There is already a matching specific procedure, it just has the
problem that the INTENT is wrong.

If one checks for GENERIC procedures, one should continue checking the
interface and if everything except of the INTENT matches, one should print an
error message. Otherwise one can search for ages for the problem.

NAG f95 prints for the example:

Error: line 14: Dummy proc A arg 1 has different INTENT from actual proc SUB
arg
Error: line 14: Incompatible procedure argument for A (no. 1) of SPECIFIC

Example:
-----------------------------
module m
  implicit none
  interface gen
    subroutine specific(a)
      interface
        subroutine a(x)
          integer, intent(in) :: x
        end subroutine a
      end interface
    end subroutine specific
  end interface gen
contains
  subroutine test()
    call gen(sub)
  end subroutine test
  subroutine sub(a)
    integer, intent(inout) :: a
  end subroutine sub
end module m
-----------------------------

 * * *

Without NAG f95 I would not have easily found the problem for the real-world
program (now fixed). To show bad the error message is, here the interface (from
octopus, see http://www.tddft.org). The problem was that the actual argument to
"f" had for "val" intent(inout) instead of "intent(out)".

  interface loct_minimize
    function oct_minimize(method, dim, x, step, tolgrad, toldr, maxiter, f, &
                          write_iter_info, minimum)
      integer :: oct_minimize
      integer, intent(in)    :: method
      integer, intent(in)    :: dim
      real(8), intent(inout) :: x
      real(8), intent(in)    :: step
      integer, intent(in)    :: maxiter
      real(8), intent(in)    :: tolgrad
      real(8), intent(in)    :: toldr
      real(8), intent(out)   :: minimum
      interface
        subroutine f(n, x, val, getgrad, grad)
          integer, intent(in) :: n
          real(8), intent(in) :: x(n)
          real(8), intent(out) :: val
          integer, intent(in)  :: getgrad
          real(8), intent(out) :: grad(n)
        end subroutine f
        subroutine write_iter_info(iter, n, val, maxdr, maxgrad, x)
          integer, intent(in) :: iter
          integer, intent(in) :: n
          real(8), intent(in) :: val
          real(8), intent(in) :: maxdr
          real(8), intent(in) :: maxgrad
          real(8), intent(in) :: x(n)
        end subroutine write_iter_info
      end interface
    end function oct_minimize
  end interface


-- 
           Summary: Matching GENERIC procedure: Wrong INTENT should give
                    directly an error message
           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=40276


^ permalink raw reply	[flat|nested] 5+ messages in thread
[parent not found: <bug-40276-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2013-07-16  6:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-27 18:34 [Bug fortran/40276] New: Matching GENERIC procedure: Wrong INTENT should give directly an error message burnus at gcc dot gnu dot org
2009-05-27 21:40 ` [Bug fortran/40276] " burnus at gcc dot gnu dot org
2009-06-15 22:40 ` burnus at gcc dot gnu dot org
2009-12-18 14:37 ` pault at gcc dot gnu dot org
     [not found] <bug-40276-4@http.gcc.gnu.org/bugzilla/>
2013-07-16  6:24 ` burnus at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).