https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97927
--- Comment #13 from Tobias Burnus <burnus at gcc dot gnu.org> --- Created attachment 50313 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50313&action=edit Reduced testcase - run with 'gfortran file.f90' (seems to require --enable-checking=yes) The generated code has: __attribute__((fn spec (". "))) void zrho2 () // <<--- nested in exxengy { return; } __attribute__((fn spec (". "))) void exxengy () { static void zrho2 (void); ierror = {CLOBBER}; mpi_allreduce (&ierror); } ICE: In tree-nested.c's convert_local_reference_stmt, there is: 2524 case GIMPLE_ASSIGN: 2525 if (gimple_clobber_p (stmt)) 2526 { 2527 tree lhs = gimple_assign_lhs (stmt); 2528 if (DECL_P (lhs) 2529 && !use_pointer_in_frame (lhs) 2530 && lookup_field_for_decl (info, lhs, NO_INSERT)) with: (gdb) p debug_gimple_seq(*gsi->seq) ierror = {CLOBBER}; mpi_allreduce (&ierror); and lhs == decl in the following: #0 lookup_field_for_decl (info=0x2f28150, decl=0x7ffff7ffbab0, insert=NO_INSERT) at ../../repos/gcc/gcc/tree-nested.c:385 385 gcc_checking_assert (decl_function_context (decl) == info->context); with (gdb) p debug_tree(info->context) <function_decl 0x7ffff7668200 exxengy and (gdb) p decl_function_context (decl) $3 = (tree_node *) 0x0 (gdb) p debug_tree(decl) <var_decl 0x7ffff7ffbab0 ierror type <integer_type 0x7ffff74a95e8 integer(kind=4) public SI size <integer_cst 0x7ffff7494df8 constant 32> unit-size <integer_cst 0x7ffff7494e10 constant 4> align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7ffff74a95e8 precision:32 min <integer_cst 0x7ffff7494db0 -2147483648> max <integer_cst 0x7ffff7494dc8 2147483647> pointer_to_this <pointer_type 0x7ffff74b09d8>> addressable used public static SI exxengy4.f90:12:16 size <integer_cst 0x7ffff7494df8 32> unit-size <integer_cst 0x7ffff7494e10 4> align:32 warn_if_not_align:0 context <namespace_decl 0x7ffff7667260 modmpi> chain <function_decl 0x7ffff7668200 exxengy>> I am not quite sure whether the context is right or not: context <namespace_decl 0x7ffff7667260 modmpi> but it does not really look wrong, does it?
