------- Comment #18 from burnus at gcc dot gnu dot org 2010-07-24 19:13 -------
(In reply to comment #17)
> comment 1 still fails with current trunk
(In reply to comment #1)
> subroutine two()
> call three()
> end subroutine two
>
> subroutine three()
> end subroutine three
The problem is that one first generates code for "two" and thus calls
gfc_get_extern_function_decl
to generate the decl for "three" - there is no existing declaration. As next
step, one works on "three" and calls
gfc_create_function_decl
which creates another declaration.
The test case in comment 1 and the one in comment 16 (with the bogus "use demo"
comment out) worked with an initial version of the following patch. However, it
give an ICE for the test in comment 4:
22.f90:5:0: internal compiler error: in build_function_decl, at
fortran/trans-decl.c:1599
The solution was to make the newly generated procedure as global - which it
surely is - otherwise, it were not accessible.
Index: gcc/fortran/trans-decl.c
===================================================================
--- gcc/fortran/trans-decl.c (Revision 162502)
+++ gcc/fortran/trans-decl.c (Arbeitskopie)
@@ -1411,9 +1411,19 @@ gfc_get_extern_function_decl (gfc_symbol
&& !sym->attr.use_assoc
&& !sym->backend_decl
&& gsym && gsym->ns
- && ((gsym->type == GSYM_SUBROUTINE) || (gsym->type == GSYM_FUNCTION))
- && gsym->ns->proc_name->backend_decl)
+ && ((gsym->type == GSYM_SUBROUTINE) || (gsym->type == GSYM_FUNCTION)))
{
+ if (!gsym->ns->proc_name->backend_decl)
+ {
+ tree save_fn_decl = current_function_decl;
+ /* By construction, the external function cannot be
+ a contained procedure. */
+ current_function_decl = NULL_TREE;
+ gfc_create_function_decl (gsym->ns);
+ current_function_decl = save_fn_decl;
+ gcc_assert (gsym->ns->proc_name->backend_decl);
+ }
+
/* If the namespace has entries, the proc_name is the
entry master. Find the entry and use its backend_decl.
otherwise, use the proc_name backend_decl. */
--
burnus at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|pault at gcc dot gnu dot org|burnus at gcc dot gnu dot
| |org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40873