https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119604
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Nathaniel Shead from comment #2) > Maybe worth noting that the C++ frontend already uses an 'iloc_sentinel' > RAII type for this (defined in cp/cp-tree.h), maybe it would be worth moving > somewhere more general? Thanks and yes that should be moved to be more generic. I am thinking input.h which defines input_location. expand_asm_stmt in cfgexpand.cc uses a local class (save_input_location) for this. Which should also moved over to using that. The following functions does it manually: expand_call_inline (this bug report) expand_ifn_va_arg_1 expand_gimple_stmt cgraph_node::create_version_clone_with_body cgraph_node::analyze analyze_functions cgraph_node::expand expand_omp assign_assembler_name_if_needed assemble_asm force_gimple_operand_1 (though sets it to UNKNOWN_LOCATION which iloc_sentinel would have rejected) build_cxa_dtor_registrations (likewise) process_options (likewise) tree_function_versioning (likewise) lang_dependent_init (BUILTINS_LOCATION) scan_omp saves and restores it around walk_gimple_seq_mod (which sets it).