Bug 45086 - For whole-file checking, also check whether an INTERFACE matches
Summary: For whole-file checking, also check whether an INTERFACE matches
Status: RESOLVED DUPLICATE of bug 27318
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks: 29670
  Show dependency treegraph
 
Reported: 2010-07-26 17:00 UTC by Tobias Burnus
Modified: 2010-12-28 18:26 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2010-07-26 17:00:22 UTC
The check should be done in resolve_global_procedure.

NAG has:

Error: fjkff.f90: Inconsistent INTERFACE block for procedure FOO from $main$
       Argument X (no. 1) should be an assumed-shape array

g95 has:

Error: Passing array at (1) to assumed-shape actual argument at (2) via an implicit interface


Example:

  subroutine foo(x)
    integer :: x(:)
  end subroutine foo

interface
  subroutine foo(x)
    integer :: x(1)
  end subroutine foo
end interface
call foo([1])
end
Comment 1 Tobias Burnus 2010-07-26 19:17:43 UTC
Related - the original version of gfortran.dg/char_result_4.f90 shows:

    pure elemental function double (x)
    1
Error: ELEMENTAL procedure 'double' at (1) must have an explicit interface

Expected: This message is shown for the CALL to the procedure and not for the definition.

Note 1: I quickly tried to generate a minimal example, but I did not succeed.
Note 2: As part of PR 40873 the example will be fixed, please remember this when testing.


 * * *

Another item to do argument checking if there is an INTERFACE present. A simple use check cannot be done as the INTERFACE might have different argument names than the real procedure, which will fail. Thus gfc_procedure_use needs to be augmented by having a mode which goes trough the list one-to-one without checking the presence of other arguments. (Assumes that list has been reordered). Or, one adds a function which simply compares the formal arguments, which is probably the better approach.
Comment 2 Tobias Burnus 2010-07-27 08:29:49 UTC
  subroutine foo(x)
     integer, allocatable :: x
  end subroutine

  integer, allocatable :: ptr
  call foo(ptr)
  end

Error: Dummy argument 'x' of procedure 'foo' at (1) has an attribute that requires an explicit interface for this procedure

Expected: Could be more explicit, maybe.

 * * *

  subroutine foo(x)
     integer, allocatable :: x
  end subroutine

  interface
    subroutine foo(x)
       integer :: x
    end subroutine
  end interface
  integer, allocatable :: ptr
  call foo(ptr)
  end

Expected: Mismatched interface is detected.

 * * *

  subroutine foo(x)
     integer, allocatable :: x
  end subroutine

  interface
    subroutine foo(x)
       integer :: x
    end subroutine
  end interface
  integer :: ptr
  call foo(ptr)
  end

Expected: Mismatched actual argument is detected as well.
Comment 3 Daniel Franke 2010-12-28 18:23:56 UTC
Same as #27318.
Comment 4 Daniel Franke 2010-12-28 18:26:20 UTC
Bugger, should have been closed as dupe, 2nd try.

*** This bug has been marked as a duplicate of bug 27318 ***