rfc: multiple decls for functions
Daniel Franke
franke.daniel@gmail.com
Thu Dec 25 17:33:00 GMT 2008
On Tuesday 23 December 2008 01:12:24 Daniel Franke wrote:
> Currently applying the patch and dabbling with it myself ...
Looks good so far. I'm down to one kind of regressions by now :)
It turns out that backend_decls of derived types are not shared between
namespaces (symbol.c, gfc_free_dt_list()). This wasn't a problem as long as,
e.g. a function returning such a type had different decls in different places.
With a unique decl for the function (that got its TYPE in another namespace)
it appears that target and return type are not identical.
A somewhat minimal example of the problem:
MODULE m
TYPE :: t
INTEGER :: i
END TYPE
CONTAINS
FUNCTION bar ()
TYPE(t) :: bar
bar%i = 42
END FUNCTION
END MODULE
USE m
TYPE(t) :: c
c = foo () ! ICE in fold-const.c as the types of C and FOO are different
! and fold-convert doesn't know how to convert RECORD_TYPEs
END
Similar code that doesn't use a module but a main program and a contained
function works as expected.
Please find my (still experimental) patch attached. With this, the testsuite
shows 16 failing testcases [1]. All the ICEs are identical, it is triggered by
above example. The remaining ones are execution errors that might be fixed
together with the problem outlined above or may be numerical issues that
surfaced with inlining.
Cheers
Daniel
[1] List of failing tests, ICE first:
alloc_comp_assign_6.f90
extends_4.f03 -O0
function_kinds_1.f90 -O0
function_types_2.f90 -O
module_function_type_1.f90 -O
used_types_2.f90 -O
used_types_22.f90 -O
used_types_8.f90 -O
gfortran.fortran-torture/execute/entry_8.f90, -O0
default_initialization_3.f90 -O2 execution test
entry_13.f90 -O2 execution test
import.f90 -O3 -fomit-frame-pointer execution test
import4.f90 -O3 -fomit-frame-pointer execution test
integer_exponentiation_3.F90 -O execution test [numerical]
typebound_call_3.f03 -O3 -fomit-frame-pointer execution test
gfortran.fortran-torture/execute/function_module_1.f90 execution
-------------- next part --------------
A non-text attachment was scrubbed...
Name: multipl-decl.diff
Type: text/x-patch
Size: 13903 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20081225/39369171/attachment.bin>
More information about the Fortran
mailing list