------- Comment #5 from burnus at gcc dot gnu dot org 2009-05-27 15:06 ------- > Some tests fail such as: > /opt/gcc/_gcc_clean/gcc/testsuite/gfortran.dg/actual_procedure_1.f90 > Undefined symbols: > "_proc_ext_", referenced from: > _proc_ext_$non_lazy_ptr in ccGPjrnd.o
Ditto here: /tmp/ccu8LjG6.o: In function `MAIN__': actual_procedure_1.f90:(.text+0x1aa): undefined reference to `proc_ext_' Somehow proc_ext disappears between 003t.original and 004t.gimple. I looked at the patch, but I cannot see anything obvious which could cause this. The problem seems to be functions which are not contained functions which appear after PROGRAM (and thus also after "main()"). Shortest test case: program test call ext() end program test subroutine ext() end subroutine ext Reversing the order is a work around. It has presumably something to do with either to much or to little "poplevel" - at least there are no other obvious changes regarding. How about the following patch: Index: gcc/fortran/trans-decl.c =================================================================== --- gcc/fortran/trans-decl.c (revision 147906) +++ gcc/fortran/trans-decl.c (working copy) @@ -3838,11 +3839,20 @@ add_argument_checking (stmtblock_t *bloc static void create_main_function (tree fndecl) { - + tree old_context; tree ftn_main; tree tmp, decl, result_decl, argc, argv, typelist, arglist; stmtblock_t body; + old_context = current_function_decl; + + if (old_context) + { + push_function_context (); + saved_parent_function_decls = saved_function_decls; + saved_function_decls = NULL_TREE; + } + /* main() function must be declared with global scope. */ gcc_assert (current_function_decl == NULL_TREE); @@ -4000,6 +4010,9 @@ create_main_function (tree fndecl) tmp = build_call_expr (fndecl, 0); gfc_add_expr_to_block (&body, tmp); + /* Mark MAIN__ as used. */ + TREE_USED (fndecl) = 1; + /* "return 0". */ tmp = fold_build2 (MODIFY_EXPR, integer_type_node, DECL_RESULT (ftn_main), build_int_cst (integer_type_node, 0)); @@ -4023,6 +4036,14 @@ create_main_function (tree fndecl) gfc_gimplify_function (ftn_main); cgraph_finalize_function (ftn_main, false); + + if (old_context) + { + pop_function_context (); + saved_function_decls = saved_parent_function_decls; + } + current_function_decl = old_context; + } -- burnus at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|unassigned at gcc dot gnu |burnus at gcc dot gnu dot |dot org |org Status|NEW |ASSIGNED Last reconfirmed|2009-05-27 14:26:29 |2009-05-27 15:06:57 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40270