https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105024
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dmalcolm at gcc dot gnu.org,
| |jakub at gcc dot gnu.org
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
For the __builtin_stack_save, the locus comes from the bind_expr or its block:
gimplify_bind_expr has:
/* Source location wise, the cleanup code (stack_restore and clobbers)
belongs to the end of the block, so propagate what we have. The
stack_save operation belongs to the beginning of block, which we can
infer from the bind_expr directly if the block has no explicit
assignment. */
if (BIND_EXPR_BLOCK (bind_expr))
{
end_locus = BLOCK_SOURCE_END_LOCATION (BIND_EXPR_BLOCK (bind_expr));
start_locus = BLOCK_SOURCE_LOCATION (BIND_EXPR_BLOCK (bind_expr));
}
if (start_locus == 0)
start_locus = EXPR_LOCATION (bind_expr);
Apparently, neither in C nor in C++ we have BLOCK_SOURCE_*LOCATION on the
BIND_EXPR_BLOCK of this bind_expr, so it comes from EXPR_LOCATION of the
bind_expr.
The C FE sets it from:
#0 0x0000000000bc42bb in c_build_bind_expr (loc=243168, block=<block
0x7fffea380480>, body=<statement_list 0x7fffea38c200>) at
../../gcc/c-family/c-gimplify.cc:661
#1 0x0000000000aed271 in c_end_compound_stmt (loc=243168, stmt=<statement_list
0x7fffea38c200>, do_scope=true) at ../../gcc/c/c-typeck.cc:11537
#2 0x0000000000b14a8c in c_parser_compound_statement (parser=0x7fffea24db40,
endlocp=0x7fffffffd38c) at ../../gcc/c/c-parser.cc:5613
where the used location is the location of the opening {
5599 brace_loc = c_parser_peek_token (parser)->location;
5600 if (!c_parser_require (parser, CPP_OPEN_BRACE, "expected %<{%>"))
While C++ FE sets it in:
#0 0x0000000000f882a1 in c_build_bind_expr (loc=307648, block=<block
0x7fffea3ae5a0>, body=<statement_list 0x7fffea39f8e0>) at
../../gcc/c-family/c-gimplify.cc:661
#1 0x0000000000e7bcfd in do_poplevel (stmt_list=<statement_list
0x7fffea39f8e0>) at ../../gcc/cp/semantics.cc:639
#2 0x0000000000e7fdb0 in finish_compound_stmt (stmt=<statement_list
0x7fffea39f8e0>) at ../../gcc/cp/semantics.cc:1782
where do_poplevel uses input_location which is the "current" location, so the
end of the block and the location of the { is not available at that point.