This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
This is a very straightforward patch for a rejects-valid and the ChangeLog and comment tell the story. The testscase is a development of the reporter's - Lahey's F95 online checker agrees with the default typing.
PS I have 1 other rejects-valid (PR30880) and 2 ICE-on-valids (PR30531/PR31086) awaiting review - can somebody take a look at them, please?
PR fortran/30883 * parse.c (parse_interface): Use the default types from the formal namespace if a function or its result do not have a type after parsing the specification statements.
PR fortran/30883 * gfortran.dg/interface_11.f90: New test.
Attachment:
Change.Logs
Description: Binary data
Index: /svn/trunk/gcc/fortran/parse.c =================================================================== *** /svn/trunk/gcc/fortran/parse.c (revision 122629) --- /svn/trunk/gcc/fortran/parse.c (working copy) *************** decl: *** 1782,1787 **** --- 1782,1801 ---- /* Read data declaration statements. */ st = parse_spec (ST_NONE); + /* Since the interface block does not permit an IMPLICIT statement, + the default type for the function or the result must be taken + from the formal namespace. */ + if (new_state == COMP_FUNCTION) + { + if (prog_unit->result == prog_unit + && prog_unit->ts.type == BT_UNKNOWN) + gfc_set_default_type (prog_unit, 1, prog_unit->formal_ns); + else if (prog_unit->result != prog_unit + && prog_unit->result->ts.type == BT_UNKNOWN) + gfc_set_default_type (prog_unit->result, 1, + prog_unit->formal_ns); + } + if (st != ST_END_SUBROUTINE && st != ST_END_FUNCTION) { gfc_error ("Unexpected %s statement at %C in INTERFACE body", Index: /svn/trunk/gcc/testsuite/gfortran.dg/interface_11.f90 =================================================================== *** /svn/trunk/gcc/testsuite/gfortran.dg/interface_11.f90 (revision 0) --- /svn/trunk/gcc/testsuite/gfortran.dg/interface_11.f90 (revision 0) *************** *** 0 **** --- 1,29 ---- + ! { dg-do compile } + ! Tests the fix for PR30883 in which interface functions and + ! their results did not get an implicit type. + ! + ! Contributed by Joost VandeVondele <jv244@cam.ac.uk> + ! + MODULE M1 + IMPLICIT NONE + CONTAINS + SUBROUTINE S1(F1, F2, G1, G2) + INTERFACE + FUNCTION F1(i, a) + END FUNCTION F1 + FUNCTION F2(i, a) + implicit complex (a-z) + END FUNCTION F2 + END INTERFACE + INTERFACE + FUNCTION g1(i, a) result(z) + END FUNCTION g1 + FUNCTION g2(i, a) result(z) + implicit complex (a-z) + END FUNCTION g2 + END INTERFACE + END SUBROUTINE S1 + END MODULE + + END + ! { dg-final { cleanup-modules "m1" } }
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |