http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52469
Tobias Burnus <burnus at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords|rejects-valid, wrong-code |ice-on-valid-code Status|NEW |ASSIGNED --- Comment #5 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-03-08 11:32:50 UTC --- The problem already occurs for gfc_get_derived_type's call to gfc_get_ppc_type, which calls in turn gfc_get_function_type. For -fno-whole-file), gfc_get_function_type returns the function decl, for -fwhole-file it returns a pointer to the function decl. The reason is that for -fwhole-file, "sym" (sym->name == "func") already has a backend_decl - one which has a pointer. * * * Actually, the example source code is rather tricky: pointer :: func interface function func (z) real :: func real, intent (in) :: z end function func end interface This declares a procedure pointer "func", i.e. it's the same as: abstract interface function template (z) real :: template real, intent (in) :: z end function template end interface procedure(template), pointer :: func But at the same time, the original "func" is used as: type Contains_f_ptr procedure (func), pointer, nopass :: my_f_ptr end type Contains_f_ptr Where "func" denotes the interface to which the procedure pointer points to (i.e. "template" in the modified exampled). In trans-type.c, the proc pointer is completely unexpected and thus it fails. It should be possible to modify the example such that it also fails with -fno-whole-file. Draft patch: --- a/gcc/fortran/trans-types.c +++ b/gcc/fortran/trans-types.c @@ -2680,3 +2694,7 @@ gfc_get_function_type (gfc_symbol * sym) if (sym->backend_decl) - return TREE_TYPE (sym->backend_decl); + { + if (sym->attr.proc_pointer) + return TREE_TYPE (TREE_TYPE (sym->backend_decl)); + return TREE_TYPE (sym->backend_decl); + }