From: pault Date: Sun, 11 Mar 2007 16:17:32 +0000 (+0000) Subject: 2007-03-11 Paul Thomas X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=57a93644a8e121c8884d27530dd4eb709f20569c;p=thirdparty%2Fgcc.git 2007-03-11 Paul Thomas 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. 2007-03-11 Paul Thomas PR fortran/30883 * gfortran.dg/interface_11.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@122822 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 67825bfe110f..debe01542ad5 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2007-03-11 Paul Thomas + + 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. + 2007-03-08 Brooks Moses * intrinsic.texi: (ICHAR) Improve internal I/O note. diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c index 6e36ea21a538..2d171670df38 100644 --- a/gcc/fortran/parse.c +++ b/gcc/fortran/parse.c @@ -1782,6 +1782,20 @@ decl: /* 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", diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 886bc4ea11e1..2276ea07135a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-03-11 Paul Thomas + + PR fortran/30883 + * gfortran.dg/interface_11.f90: New test. + 2007-03-11 Richard Guenther PR tree-optimization/31115 diff --git a/gcc/testsuite/gfortran.dg/interface_11.f90 b/gcc/testsuite/gfortran.dg/interface_11.f90 new file mode 100644 index 000000000000..a143bb374f2c --- /dev/null +++ b/gcc/testsuite/gfortran.dg/interface_11.f90 @@ -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 +! +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" } }