Bug 33117 - Improve error message for generic interface with subroutines & functions
Summary: Improve error message for generic interface with subroutines & functions
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.3.0
: P3 minor
Target Milestone: 4.6.0
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks: 29670
  Show dependency treegraph
 
Reported: 2007-08-19 21:02 UTC by Tobias Burnus
Modified: 2011-01-06 16:10 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2007-08-20 14:49:27


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2007-08-19 21:02:43 UTC
Mixing functions and subroutines in a generic interface is invalid. gfortran detects this but the error message is difficult to understand:

Error: FUNCTION at (1) does not belong in a generic subroutine interface

NAG f95:
Error: b.f90, line 10: BAR and SUB must both be SUBROUTINEs or both be FUNCTIONs for generic GEN

g95:
Error: Interfaces of generic 'gen' at (1) must all be FUNCTIONs or SUBROUTINEs

ifort -stand f95:
fortcom: Warning: b.f90, line 6: Standard Fortran requires that within a scoping unit, two procedures that have the same generic name shall both be subroutines or both be functions.   [BAR]

Example:

module mod
  implicit none
  interface gen
    subroutine sub()
    end subroutine sub
    function bar()
      real :: bar
    end function bar
  end interface gen
end module mod
Comment 1 Daniel Franke 2010-12-28 18:27:08 UTC
*** Bug 46478 has been marked as a duplicate of this bug. ***
Comment 2 Daniel Franke 2011-01-06 16:08:28 UTC
Author: dfranke
Date: Thu Jan  6 16:08:24 2011
New Revision: 168542

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=168542
Log:
gcc/fortran/:
2011-01-06  Daniel Franke  <franke.daniel@gmail.com>

	PR fortran/33117
	PR fortran/46478
	* parse.c (parse_interface): Remove check for procedure types.
	* interface.c (check_interface0): Verify that procedures are
	either all SUBROUTINEs or all FUNCTIONs.

gcc/testsuite/:
2011-01-06  Daniel Franke  <franke.daniel@gmail.com>

	PR fortran/33117
	PR fortran/46478
	* gfortran.dg/interface_33.f90: New test.


Added:
    trunk/gcc/testsuite/gfortran.dg/interface_33.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/interface.c
    trunk/gcc/fortran/parse.c
    trunk/gcc/testsuite/ChangeLog
Comment 3 Daniel Franke 2011-01-06 16:10:56 UTC
Fixed on trunk. Closing.