schluter@pcl247d:~> cat t.f90 program blubb call otherini(*998) stop 998 stop contains subroutine init call otherini(*999) return 999 stop end subroutine init end program blubb schluter@pcl247d:~> ~/src/gcc/build/stage3-gcc/f951 t.f90 MAIN__ init t.f90:6: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions. schluter@pcl247d:~> ~/src/gcc/build/stage3-gcc/f951 --version GNU F95 version 4.2.0 20060618 (experimental) (i686-pc-linux-gnu) compiled by GNU C version 4.2.0 20060618 (experimental). GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 schluter@pcl247d:~> Note that it seems necessary that the subroutine be called both from the program and the contained procedure.
Confirmed: #0 0x000a6560 in gfc_add_modify_expr (pblock=0xbffff300, lhs=0x0, rhs=0x42c0e1b0) at ../../gcc/fortran/trans.c:156 #1 0x000e91f8 in gfc_trans_call (code=0x42b05c40, dependency_check=0 '\0') at ../../gcc/fortran/trans-stmt.c:351 #2 0x000a7538 in gfc_trans_code (code=0x42b05c40) at ../../gcc/fortran/trans.c:509 #3 0x000c7618 in gfc_generate_function_code (ns=0x43012a00) at ../../gcc/fortran/trans-decl.c:2990 #4 0x000c6bd0 in gfc_generate_contained_functions (parent=0x43006600) at ../../gcc/fortran/trans-decl.c:2749 #5 0x000c7168 in gfc_generate_function_code (ns=0x43006600) at ../../gcc/fortran/trans-decl.c:2891
This fixes it, regtests and even produces the correct code: Index: gcc/fortran/trans-stmt.c =================================================================== *** gcc/fortran/trans-stmt.c (revision 120243) --- gcc/fortran/trans-stmt.c (working copy) *************** gfc_trans_call (gfc_code * code, bool de *** 349,354 **** --- 349,356 ---- gcc_assert(select_code->op == EXEC_SELECT); sym = select_code->expr->symtree->n.sym; se.expr = convert (gfc_typenode_for_spec (&sym->ts), se.expr); + if (sym->backend_decl == NULL) + sym->backend_decl = gfc_get_symbol_decl (sym); gfc_add_modify_expr (&se.pre, sym->backend_decl, se.expr); } else Paul
Subject: Bug 28172 Author: pault Date: Mon Jan 15 08:16:17 2007 New Revision: 120790 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=120790 Log: 2007-01-15 Paul Thomas <pault@gcc.gnu.org> PR fortran/28172 * trans-stmt.c (gfc_trans_call): If it does not have one, get a backend_decl for an alternate return. PR fortran/29389 * resolve.c (pure_function): Statement functions are pure. Note that this will have to recurse to comply fully with F95. PR fortran/29712 * resolve.c (resolve_function): Only a reference to the final dimension of an assumed size array is an error in an inquiry function. PR fortran/30283 * resolve.c (resolve_function): Make sure that the function expression has a type. 2007-01-15 Paul Thomas <pault@gcc.gnu.org> PR fortran/28172 * gfortran.dg/altreturn_4.f90: New test. PR fortran/29389 * gfortran.dg/stfunc_4.f90: New test. PR fortran/29712 * gfortran.dg/bound_2.f90: Reinstate commented out line. * gfortran.dg/initialization_1.f90: Change warning. PR fortran/30283 * gfortran.dg/specification_type_resolution_2.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/altreturn_4.f90 trunk/gcc/testsuite/gfortran.dg/specification_type_resolution_2.f90 trunk/gcc/testsuite/gfortran.dg/stfunc_4.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/resolve.c trunk/gcc/fortran/trans-stmt.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gfortran.dg/bound_2.f90 trunk/gcc/testsuite/gfortran.dg/initialization_1.f90
Subject: Bug number PR28172 A patch for this bug has been added to the patch tracker. The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2007-01/msg01196.html
Subject: Bug 28172 Author: pault Date: Tue Jan 23 05:53:14 2007 New Revision: 121077 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=121077 Log: 2007-01-23 Paul Thomas <pault@gcc.gnu.org> Backports from trunk PR fortran/28172 * trans-stmt.c (gfc_trans_call): If it does not have one, get a backend_decl for an alternate return. PR fortran/29389 * resolve.c (pure_function): Statement functions are pure. Note that this will have to recurse to comply fully with F95. PR fortran/29712 * resolve.c (resolve_function): Only a reference to the final dimension of an assumed size array is an error in an inquiry function. PR fortran/30283 * resolve.c (resolve_function): Make sure that the function expression has a type. 2007-01-23 Paul Thomas <pault@gcc.gnu.org> PR fortran/28172 * gfortran.dg/altreturn_4.f90: New test. PR fortran/29389 * gfortran.dg/stfunc_4.f90: New test. PR fortran/29712 * gfortran.dg/bound_2.f90: Reinstate commented out line. * gfortran.dg/initialization_1.f90: Change warning. PR fortran/30283 * gfortran.dg/specification_type_resolution_2.f90: New test. Added: branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/altreturn_4.f90 branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/specification_type_resolution_2.f90 branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/stfunc_4.f90 Modified: branches/gcc-4_2-branch/gcc/fortran/ChangeLog branches/gcc-4_2-branch/gcc/fortran/resolve.c branches/gcc-4_2-branch/gcc/fortran/trans-stmt.c branches/gcc-4_2-branch/gcc/testsuite/ChangeLog branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/bound_2.f90 branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/initialization_1.f90
Fixed on trunk and 4.2 Paul
It helps to mark it fixed...